0 and ac[0].time_to is None:
- log.error('Vorheriges Accounting nicht abgeschlossen: Desk_id {}, Accounting_id {}'
- .format(desk.id, ac[0].id))
- acc = ac[0]
- if acc is None:
- acc = Accounting(
- desk=desk,
- time_from=ld.tst,
- )
- acc.save()
- ld.delete()
else:
- if len(ac) > 0:
- acc = ac[0]
- acc.time_to = ld.tst
- acc.prize, acc.prize_normal, acc.prize_hh = utils.get_prize_for(
- start=acc.time_from,
- end=ld.tst,
- pph=desk.prize,
- hh_start=cli.location.happy_hour_start,
- hh_end=cli.location.happy_hour_end,
- pphh=desk.prize_hh,
- )
- acc.reporter_uuid = cli.uuid
+ cli = cli[0]
+ desk = cli.desks.filter(desk_no=ld.desk_no, enabled=True)
+ if desk.count() != 1:
+ ld.processed = True
+ ld.error_msg = 'No desk object found. Stopp processing! {}, {}'.format(ld.client_id, ld.desk_no)
+ ld.save()
+ log.error(ld.error_msg)
+ desk = desk[0]
+ ac = desk.accounting_set.order_by('time_from').reverse()
+ if ld.on_off:
+ acc = None
+ if ac.count() > 0 and ac[0].time_to is None:
+ log.error('Vorheriges Accounting nicht abgeschlossen: Desk_id {}, Accounting_id {}'
+ .format(desk.id, ac[0].id))
+ acc = ac[0]
+ if acc is None:
+ acc = Accounting(
+ desk=desk,
+ time_from=ld.tst,
+ )
acc.save()
ld.delete()
else:
- ld.processed = True
- ld.error_msg = 'No existing accountings found. Stopp processing! {}, {}'.format(ld.client_id, ld.desk_no)
- ld.save()
- log.error(ld.error_msg)
+ if len(ac) > 0:
+ acc = ac[0]
+ acc.time_to = ld.tst
+ acc.prize, acc.prize_normal, acc.prize_hh = utils.get_prize_for(
+ start=acc.time_from,
+ end=ld.tst,
+ pph=desk.prize,
+ hh_start=cli.location.happy_hour_start,
+ hh_end=cli.location.happy_hour_end,
+ pphh=desk.prize_hh,
+ )
+ acc.reporter_uuid = cli.uuid
+ acc.save()
+ ld.delete()
+ else:
+ ld.processed = True
+ ld.error_msg = 'No existing accountings found. Stopp processing! {}, {}'.format(ld.client_id, ld.desk_no)
+ ld.save()
+ log.error(ld.error_msg)
+ except:
+ log.exception('', exc_info=True)
diff --git a/billard/templates/admin/billard/locationdata/change_list.html b/billard/templates/admin/billard/locationdata/change_list.html
new file mode 100644
index 0000000..746f56d
--- /dev/null
+++ b/billard/templates/admin/billard/locationdata/change_list.html
@@ -0,0 +1,10 @@
+{% extends "admin/change_list.html" %}
+{% load i18n admin_urls static admin_list %}
+{% block object-tools-items %}
+
+
+ LD Verarbeiten
+
+
+{{ block.super }}
+{% endblock %}
\ No newline at end of file
diff --git a/billard/templates/billard/base.html b/billard/templates/billard/base.html
index cba7394..2e43a2d 100644
--- a/billard/templates/billard/base.html
+++ b/billard/templates/billard/base.html
@@ -6,16 +6,22 @@
carom - {% block title %}TITLE SETZEN{% endblock %}
-
-
+
+
+
{% block header %}
{% endblock %}
-
+
+
+
-
+
{% block content %}
{% endblock %}
-
-
-
+
+
+
{% block js %}
{% endblock %}
diff --git a/billard/urls.py b/billard/urls.py
index 79d842e..c9fc1e4 100644
--- a/billard/urls.py
+++ b/billard/urls.py
@@ -4,7 +4,7 @@ from rest_framework import routers
from billard import views
router = routers.DefaultRouter()
-router.register(r'location_data', views.LocationDataViewSet)
+router.register(r'locationdata', views.LocationDataViewSet)
app_name = 'billard'
urlpatterns = [
diff --git a/billard/views.py b/billard/views.py
index 087fef1..ba7a6f1 100644
--- a/billard/views.py
+++ b/billard/views.py
@@ -1,4 +1,5 @@
import ast
+import logging
from billard.serializers import LocationDataSerializer
from billard.models import LocationData, Location, Client, Accounting
@@ -13,6 +14,9 @@ from django.utils.decorators import method_decorator
from django.utils import timezone
+log = logging.getLogger(__name__)
+
+
class LocationIndexView(generic.ListView):
template_name = 'billard/location_index.html'
context_object_name = 'location_list'
@@ -43,7 +47,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 +68,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/caromserver/__init__.py b/caromserver/__init__.py
index 3b91b07..e69de29 100644
--- a/caromserver/__init__.py
+++ b/caromserver/__init__.py
@@ -1,7 +0,0 @@
-from __future__ import absolute_import, unicode_literals
-
-# This will make sure the app is always imported when
-# Django starts so that shared_task will use this app.
-from .celery import app as celery_app
-
-__all__ = ['celery_app']
diff --git a/caromserver/celery.py b/caromserver/celery.py
deleted file mode 100644
index 3e2522d..0000000
--- a/caromserver/celery.py
+++ /dev/null
@@ -1,28 +0,0 @@
-from __future__ import absolute_import, unicode_literals
-import os
-import django
-from celery import Celery
-from django.conf import settings
-
-# set the default Django settings module for the 'celery' program.
-os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'caromserver.settings')
-
-app = Celery(settings.CELERY_PREFIX)
-
-# Using a string here means the worker don't have to serialize
-# the configuration object to child processes.
-# - namespace='CELERY' means all celery-related configuration keys
-# should have a `CELERY_` prefix.
-app.config_from_object('django.conf:settings')
-
-# Load task modules from all registered Django app configs.
-
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "caromserver.settings")
-django.setup()
-
-app.autodiscover_tasks(['billard'])
-
-
-@app.task(bind=True)
-def debug_task(self):
- print('Request: {0!r}'.format(self.request))
\ No newline at end of file
diff --git a/caromserver/settings.py b/caromserver/settings.py
index d6ee8c9..4a7afc6 100644
--- a/caromserver/settings.py
+++ b/caromserver/settings.py
@@ -138,14 +138,6 @@ LOGOUT_URL = 'logout'
LOGIN_REDIRECT_URL = 'billard:location_index'
LOGOUT_REDIRECT_URL = 'billard:location_index'
-# CELERY STUFF
-BROKER_URL = 'redis://localhost:6379'
-CELERY_RESULT_BACKEND = 'redis://localhost:6379'
-CELERY_ACCEPT_CONTENT = ['application/json']
-CELERY_TASK_SERIALIZER = 'json'
-CELERY_RESULT_SERIALIZER = 'json'
-CELERY_TIMEZONE = 'Europe/Berlin'
-
# Admin eMails
ADMINS = (
('Robert Einsle', 'robert@einsle.de'),
@@ -162,8 +154,6 @@ URL_LOCATION_PROCESSOR = 'http://127.0.0.1:8000/billard/process_locationdata'
STATIC_ROOT = "/srv/carom/carom-server/static/"
-CELERY_PREFIX = 'carom'
-
try:
from local_settings import *
except ImportError:
diff --git a/requirements.txt b/requirements.txt
index fd21abf..ade0988 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,5 @@
-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
-requests==2.13.0
+django-extensions>=1.7.0
+djangorestframework>=3.6.0
+requests>=2.18.0
diff --git a/test-client.py b/test-client.py
index 2420593..d6bbe66 100644
--- a/test-client.py
+++ b/test-client.py
@@ -5,7 +5,7 @@ from datetime import datetime
import requests
-url = 'http://127.0.0.1:8000/billard/api/v1/location_data/'
+url = 'http://127.0.0.1:8000/billard/api/v1/locationdata/'
client_id = '28a34fa1-7b62-4b78-8d2a-ada4db4ac6ea'
token = '588d0f4c4b8b90b507e6d5c0ea26f0e28b021262'
default_desk_id = 2