From eb5168a1bdf3fd1c7f349c081a368a4fc5e42a52 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Sat, 29 Apr 2017 11:24:57 +0200 Subject: [PATCH 01/15] set version info --- billard/templates/billard/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/billard/templates/billard/base.html b/billard/templates/billard/base.html index cba7394..b50a707 100644 --- a/billard/templates/billard/base.html +++ b/billard/templates/billard/base.html @@ -44,7 +44,7 @@ {% endif %} From 9fb04c661d5f2a4c68dd004f57b64dc894c92842 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Sat, 29 Apr 2017 11:34:18 +0200 Subject: [PATCH 02/15] set add info for reinsle --- billard/admin.py | 2 ++ 1 file changed, 2 insertions(+) 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 From 50823e56888745d630af767b92eafc88ba10e0b8 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Sat, 29 Apr 2017 11:38:52 +0200 Subject: [PATCH 03/15] do multiple update at once --- billard/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/billard/views.py b/billard/views.py index 087fef1..41e3e17 100644 --- a/billard/views.py +++ b/billard/views.py @@ -63,9 +63,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 From bc89db6179063237af2fa30194d0e4363cdb85e0 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Wed, 17 May 2017 09:57:56 +0200 Subject: [PATCH 04/15] carom/carom-doc#13 fix access accounting objects --- billard/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/billard/views.py b/billard/views.py index 41e3e17..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) From dd85fcb6ea791f84f0e1bf4ce6c63c6d77e70835 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Wed, 21 Jun 2017 20:59:04 +0200 Subject: [PATCH 05/15] update requirements --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 From 9dd2d30dcfea0a39d61be8e4f5254ca273192b76 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Tue, 1 Aug 2017 07:46:24 +0200 Subject: [PATCH 06/15] disable cmd sceduler --- billard/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() From 294b189a92b2b8b03fc75d2a3d505fb2cdf346f1 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Tue, 1 Aug 2017 07:48:41 +0200 Subject: [PATCH 07/15] add order by --- billard/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From dd28964bf96cd166705ebee6794d1c152ae57bd9 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Tue, 1 Aug 2017 07:57:00 +0200 Subject: [PATCH 08/15] set version info --- billard/templates/billard/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/billard/templates/billard/base.html b/billard/templates/billard/base.html index b50a707..2f5f70c 100644 --- a/billard/templates/billard/base.html +++ b/billard/templates/billard/base.html @@ -44,7 +44,7 @@ {% endif %} From 222367a6a26731a0471fc64befaa6f846b03edba Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Thu, 3 Aug 2017 19:10:15 +0200 Subject: [PATCH 09/15] update requirements --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 1547d53..9163f14 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ Django>=1.11 django-crispy-forms==1.6.1 django-extensions>=1.7.0 djangorestframework>=3.6.0 -requests==2.13.0 +requests>=2.18.0 From 81d9b7f29c78e97e967fc56018ac8df55040b378 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Thu, 3 Aug 2017 19:52:43 +0200 Subject: [PATCH 10/15] add command to process location data --- billard/admin.py | 16 +++++++++++++++- .../admin/billard/locationdata/change_list.html | 10 ++++++++++ billard/urls.py | 2 +- billard/views.py | 4 ++++ test-client.py | 2 +- 5 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 billard/templates/admin/billard/locationdata/change_list.html diff --git a/billard/admin.py b/billard/admin.py index eeff517..aad12ea 100644 --- a/billard/admin.py +++ b/billard/admin.py @@ -1,4 +1,8 @@ -from django.contrib import admin +from django.conf.urls import url +from django.contrib import admin, messages +from django.shortcuts import redirect +from django.template.response import TemplateResponse + from .models import * from django import forms from django.core.exceptions import ValidationError @@ -33,6 +37,16 @@ class ClientAdmin(admin.ModelAdmin): @admin.register(LocationData) class LocationDataAdmin(admin.ModelAdmin): + def get_urls(self): + urls = super().get_urls() + my_urls = [ + url(r'^process_locationdata/$', self.admin_site.admin_view(self.process_locationdata), name='process_locationdata'), + ] + return my_urls + urls + + def process_locationdata(self, request): + messages.success(request, '2739847239847298374982374 Items prozessiert.') + return redirect('admin:billard_locationdata_changelist') list_display = ('client_id', 'desk_no', 'tst', 'on_off', 'processed', 'error_msg') fields = ['client_id', 'desk_no', 'tst', 'on_off', 'processed', 'error_msg'] 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/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 818b3af..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' 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 From 79233c408e445329c058f67978234aeae07ef054 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Fri, 4 Aug 2017 17:49:33 +0200 Subject: [PATCH 11/15] remove celery from project --- billard/tasks.py | 3 +-- caromserver/__init__.py | 7 ------- caromserver/celery.py | 28 ---------------------------- caromserver/settings.py | 10 ---------- requirements.txt | 1 - 5 files changed, 1 insertion(+), 48 deletions(-) delete mode 100644 caromserver/celery.py diff --git a/billard/tasks.py b/billard/tasks.py index fceae52..0f2ecfc 100644 --- a/billard/tasks.py +++ b/billard/tasks.py @@ -2,13 +2,12 @@ from __future__ import absolute_import, unicode_literals import logging import billard.utils as utils -from celery import shared_task from billard.models import LocationData, Client, Accounting log = logging.getLogger(__name__) -@shared_task + def process_location_data(): data = LocationData.objects.filter(processed=False).order_by('tst') for ld in data: 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 9163f14..ade0988 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -celery==4.0.2 Django>=1.11 django-crispy-forms==1.6.1 django-extensions>=1.7.0 From 091723d2ac48b56033bf3f55b073360c71ea5f25 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Fri, 4 Aug 2017 19:22:46 +0200 Subject: [PATCH 12/15] changes to make ie8 ready --- billard/static/billard/js/html5shiv.min.js | 4 ++++ billard/static/billard/js/respond.min.js | 6 ++++++ billard/templates/billard/base.html | 22 ++++++++++++++-------- 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 billard/static/billard/js/html5shiv.min.js create mode 100644 billard/static/billard/js/respond.min.js diff --git a/billard/static/billard/js/html5shiv.min.js b/billard/static/billard/js/html5shiv.min.js new file mode 100644 index 0000000..355afd1 --- /dev/null +++ b/billard/static/billard/js/html5shiv.min.js @@ -0,0 +1,4 @@ +/** +* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document); \ No newline at end of file diff --git a/billard/static/billard/js/respond.min.js b/billard/static/billard/js/respond.min.js new file mode 100644 index 0000000..e349d67 --- /dev/null +++ b/billard/static/billard/js/respond.min.js @@ -0,0 +1,6 @@ +/*! Respond.js v1.4.2: min/max-width media query polyfill + * Copyright 2014 Scott Jehl + * Licensed under MIT + * https://j.mp/respondjs */ + +!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){v(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))},g=function(a){return a.replace(c.regex.minmaxwh,"").match(c.regex.other)};if(c.ajax=f,c.queue=d,c.unsupportedmq=g,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var h,i,j,k=a.document,l=k.documentElement,m=[],n=[],o=[],p={},q=30,r=k.getElementsByTagName("head")[0]||l,s=k.getElementsByTagName("base")[0],t=r.getElementsByTagName("link"),u=function(){var a,b=k.createElement("div"),c=k.body,d=l.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=k.createElement("body"),c.style.background="none"),l.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&l.insertBefore(c,l.firstChild),a=b.offsetWidth,f?l.removeChild(c):c.removeChild(b),l.style.fontSize=d,e&&(c.style.fontSize=e),a=j=parseFloat(a)},v=function(b){var c="clientWidth",d=l[c],e="CSS1Compat"===k.compatMode&&d||k.body[c]||d,f={},g=t[t.length-1],p=(new Date).getTime();if(b&&h&&q>p-h)return a.clearTimeout(i),i=a.setTimeout(v,q),void 0;h=p;for(var s in m)if(m.hasOwnProperty(s)){var w=m[s],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?j||u():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?j||u():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(n[w.rules]))}for(var C in o)o.hasOwnProperty(C)&&o[C]&&o[C].parentNode===r&&r.removeChild(o[C]);o.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=k.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,r.insertBefore(E,g.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(k.createTextNode(F)),o.push(E)}},w=function(a,b,d){var e=a.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var h=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},i=!f&&d;b.length&&(b+="/"),i&&(f=1);for(var j=0;f>j;j++){var k,l,o,p;i?(k=d,n.push(h(a))):(k=e[j].match(c.regex.findStyles)&&RegExp.$1,n.push(RegExp.$2&&h(RegExp.$2))),o=k.split(","),p=o.length;for(var q=0;p>q;q++)l=o[q],g(l)||m.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:n.length-1,hasquery:l.indexOf("(")>-1,minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}v()},x=function(){if(d.length){var b=d.shift();f(b.href,function(c){w(c,b.href,b.media),p[b.href]=!0,a.setTimeout(function(){x()},0)})}},y=function(){for(var b=0;b carom - {% block title %}TITLE SETZEN{% endblock %} - - + + + {% block header %} {% endblock %} - + + + - +
    {% block content %} {% endblock %}
    - - - + + + {% block js %} {% endblock %} From e16872effefda2c13a02e0fb3902f382b66f8cf7 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Fri, 4 Aug 2017 19:31:46 +0200 Subject: [PATCH 13/15] add error logging while processing location data --- billard/tasks.py | 87 +++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/billard/tasks.py b/billard/tasks.py index 0f2ecfc..5fc22dd 100644 --- a/billard/tasks.py +++ b/billard/tasks.py @@ -11,52 +11,55 @@ log = logging.getLogger(__name__) def process_location_data(): 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: - ld.processed = True - ld.error_msg = 'No client object found. Stopp processing! {}, {}'.format(ld.client_id, ld.desk_no) - ld.save() - log.error(ld.error_msg) - else: - cli = cli[0] - desk = cli.desks.filter(desk_no=ld.desk_no, enabled=True) - if desk.count() != 1: + try: + cli = Client.objects.filter(uuid=ld.client_id, desks__desk_no=ld.desk_no) + if cli.count() < 1: ld.processed = True - ld.error_msg = 'No desk object found. Stopp processing! {}, {}'.format(ld.client_id, ld.desk_no) + ld.error_msg = 'No client 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: - 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) From e5d9d61211eb603fbceb0dc25416b0792adb6da9 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Fri, 4 Aug 2017 19:41:44 +0200 Subject: [PATCH 14/15] messages fixed --- billard/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/billard/admin.py b/billard/admin.py index aad12ea..98e7484 100644 --- a/billard/admin.py +++ b/billard/admin.py @@ -45,7 +45,7 @@ class LocationDataAdmin(admin.ModelAdmin): return my_urls + urls def process_locationdata(self, request): - messages.success(request, '2739847239847298374982374 Items prozessiert.') + messages.success(request, 'Items processed.') return redirect('admin:billard_locationdata_changelist') list_display = ('client_id', 'desk_no', 'tst', 'on_off', 'processed', 'error_msg') fields = ['client_id', 'desk_no', 'tst', 'on_off', 'processed', 'error_msg'] From a4e999ac52687b77f954f2c0c0c84c87c4fbefe2 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Fri, 18 Aug 2017 10:41:15 +0200 Subject: [PATCH 15/15] set version information --- billard/templates/billard/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/billard/templates/billard/base.html b/billard/templates/billard/base.html index 9836cdb..2e43a2d 100644 --- a/billard/templates/billard/base.html +++ b/billard/templates/billard/base.html @@ -50,7 +50,7 @@ {% endif %}