diff --git a/billard/admin.py b/billard/admin.py index 062d815..eeff517 100644 --- a/billard/admin.py +++ b/billard/admin.py @@ -61,4 +61,6 @@ class AccountingAdmin(admin.ModelAdmin): list_filter = ('desk__client__location', 'account_user', 'account_tst', 'billed') def has_add_permission(self, request): + if request.user.username == 'reinsle': + return True return False diff --git a/billard/models.py b/billard/models.py index 65d6875..055d03a 100644 --- a/billard/models.py +++ b/billard/models.py @@ -100,4 +100,4 @@ class Accounting(models.Model): @receiver(post_save, sender=LocationData) def test(sender, **kwargs): from .tasks import process_location_data - process_location_data.delay() + process_location_data() diff --git a/billard/tasks.py b/billard/tasks.py index e3194f0..fceae52 100644 --- a/billard/tasks.py +++ b/billard/tasks.py @@ -10,7 +10,7 @@ log = logging.getLogger(__name__) @shared_task def process_location_data(): - data = LocationData.objects.filter(processed=False) + data = LocationData.objects.filter(processed=False).order_by('tst') for ld in data: cli = Client.objects.filter(uuid=ld.client_id, desks__desk_no=ld.desk_no) if cli.count() < 1: diff --git a/billard/templates/billard/base.html b/billard/templates/billard/base.html index cba7394..2f5f70c 100644 --- a/billard/templates/billard/base.html +++ b/billard/templates/billard/base.html @@ -44,7 +44,7 @@ {% endif %} diff --git a/billard/views.py b/billard/views.py index 087fef1..818b3af 100644 --- a/billard/views.py +++ b/billard/views.py @@ -43,7 +43,8 @@ class AccountingView(generic.ListView): context_object_name = 'accounting' def get_queryset(self): - return Accounting.objects.filter(billed=False).exclude(time_to__isnull=True).order_by('time_from') + return Accounting.objects.filter(billed=False).filter(desk__client__location_id=self.kwargs['pk'])\ + .exclude(time_to__isnull=True).order_by('time_from') def dispatch(self, request, *args, **kwargs): result = super(AccountingView, self).dispatch(request, *args, **kwargs) @@ -63,9 +64,11 @@ def accounting_confirm(request, pk): if 'accountings' in request.POST: acc_ids = ast.literal_eval(request.POST['accountings']) if len(acc_ids) > 0: - Accounting.objects.filter(id__in=acc_ids).update(billed=True) - Accounting.objects.filter(id__in=acc_ids).update(account_user=request.user.username) - Accounting.objects.filter(id__in=acc_ids).update(account_tst=timezone.now()) + Accounting.objects.filter(id__in=acc_ids).update( + billed=True, + account_user=request.user.username, + account_tst=timezone.now(), + ) resp = redirect('billard:accounting_detail', pk=pk) return resp diff --git a/requirements.txt b/requirements.txt index fd21abf..1547d53 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ celery==4.0.2 -Django==1.11 +Django>=1.11 django-crispy-forms==1.6.1 -django-extensions==1.7.8 -djangorestframework==3.6.2 +django-extensions>=1.7.0 +djangorestframework>=3.6.0 requests==2.13.0