old_contents: from django.contrib import admin
  from django.utils.translation import ugettext_lazy as _
  
  from waldur_core.structure import admin as structure_admin
  
  from .models import (
      Allocation,
      AllocationUsage,
      AllocationUserUsage,
      SlurmService,
      SlurmServiceProjectLink,
  )
  
  
  def get_allocation_count(self, scope):
      return scope.quotas.get(name='nc_allocation_count').usage
  
  
  get_allocation_count.short_description = _('Allocation count')
  
  for cls in (structure_admin.CustomerAdmin, structure_admin.ProjectAdmin):
      cls.get_allocation_count = get_allocation_count
      cls.list_display += ('get_allocation_count',)
  
  admin.site.register(SlurmService, structure_admin.ServiceAdmin)
  admin.site.register(SlurmServiceProjectLink, structure_admin.ServiceProjectLinkAdmin)
  admin.site.register(Allocation, structure_admin.ResourceAdmin)
  admin.site.register(AllocationUsage)
  admin.site.register(AllocationUserUsage)
  
new_contents: from django.contrib import admin
  from django.core.exceptions import ValidationError
  from django.utils.translation import ugettext_lazy as _
  
  from waldur_core.core.admin import ExecutorAdminAction
  from waldur_core.core.models import StateMixin
  from waldur_core.structure import admin as structure_admin
  
  from . import executors
  from .models import (
      Allocation,
      AllocationUsage,
      AllocationUserUsage,
      SlurmService,
      SlurmServiceProjectLink,
  )
  
  
  def get_allocation_count(self, scope):
      return scope.quotas.get(name='nc_allocation_count').usage
  
  
  get_allocation_count.short_description = _('Allocation count')
  
  for cls in (structure_admin.CustomerAdmin, structure_admin.ProjectAdmin):
      cls.get_allocation_count = get_allocation_count
      cls.list_display += ('get_allocation_count',)
  
  
  class AllocationAdmin(structure_admin.ResourceAdmin):
      class SyncAllocations(ExecutorAdminAction):
          executor = executors.AllocationPullExecutor
          short_description = _('Sync selected allocations')
  
          def validate(self, allocation):
              if allocation.state != StateMixin.States.OK:
                  raise ValidationError(_('Allocation has to be in OK state.'))
  
      sync_allocations = SyncAllocations()
      actions = ['sync_allocations']
  
  
  class AllocationUsageAdmin(admin.ModelAdmin):
      list_display = (
          'allocation',
          'cpu_usage',
          'gpu_usage',
          'ram_usage',
          'deposit_usage',
          'year',
          'month',
      )
  
  
  admin.site.register(SlurmService, structure_admin.ServiceAdmin)
  admin.site.register(SlurmServiceProjectLink, structure_admin.ServiceProjectLinkAdmin)
  admin.site.register(Allocation, AllocationAdmin)
  admin.site.register(AllocationUsage, AllocationUsageAdmin)
  admin.site.register(AllocationUserUsage)
  
subject: Add admin command "Sync usage" to Slurm allocation