diff --git a/billard/admin.py b/billard/admin.py index 970cd8d..ba4744f 100644 --- a/billard/admin.py +++ b/billard/admin.py @@ -27,8 +27,8 @@ class LocationAdmin(admin.ModelAdmin): @admin.register(Client) class ClientAdmin(admin.ModelAdmin): - list_display = ('uuid', 'location') - fields = ['location', 'uuid'] + list_display = ('uuid', 'location', 'report_user') + fields = ['location', 'uuid', 'report_user'] @admin.register(LocationData) diff --git a/billard/migrations/0017_accounting_reporter_uuid.py b/billard/migrations/0017_accounting_reporter_uuid.py new file mode 100644 index 0000000..e4c09fa --- /dev/null +++ b/billard/migrations/0017_accounting_reporter_uuid.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-02-27 07:57 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('billard', '0016_auto_20170225_1822'), + ] + + operations = [ + migrations.AddField( + model_name='accounting', + name='reporter_uuid', + field=models.UUIDField(blank=True, null=True, verbose_name='Reporter UUID'), + ), + ] diff --git a/billard/migrations/0018_auto_20170302_2058.py b/billard/migrations/0018_auto_20170302_2058.py new file mode 100644 index 0000000..ba2c4a7 --- /dev/null +++ b/billard/migrations/0018_auto_20170302_2058.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-03-02 20:58 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('billard', '0017_accounting_reporter_uuid'), + ] + + operations = [ + migrations.AddField( + model_name='accounting', + name='prize_hh', + field=models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True, verbose_name='Preis Happy Hour'), + ), + migrations.AddField( + model_name='accounting', + name='prize_normal', + field=models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True, verbose_name='Preis Normalzeit'), + ), + migrations.AddField( + model_name='client', + name='report_user', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reporting_clients', to=settings.AUTH_USER_MODEL, verbose_name='Reporting Benutzer'), + ), + ] diff --git a/billard/models.py b/billard/models.py index 824e825..33aedfe 100644 --- a/billard/models.py +++ b/billard/models.py @@ -51,6 +51,7 @@ class Location(models.Model): class Client(models.Model): uuid = models.UUIDField(unique=True, default=uuid.uuid4, verbose_name="Identifier") location = models.ForeignKey(Location, verbose_name="Standort") + report_user = models.ForeignKey(User, blank=True, null=True, verbose_name="Reporting Benutzer", related_name='reporting_clients') def __str__(self): return '{}, {}'.format(self.location.name, self.uuid) @@ -69,24 +70,6 @@ class Desk(models.Model): prize_hh = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True, verbose_name="Preis Happy Hour") - def accounting_for(self): - t = Accounting.objects.filter(client=self.client, desk_no=self.desk_no)[:3][::-1] - client = self.client - location = client.location - if t.__len__() > 0: - a = t[t.__len__() - 1] - if a.time_to is None: - prize = utils.get_prize_for( - start=a.time_from, - end=datetime.now(timezone.utc), - pph=self.prize, - hh_start=location.happy_hour_start, - hh_end=location.happy_hour_end, - pphh=self.prize_hh, - ) - if prize != a.prize: - a.prize = prize - return t def __str__(self): return '{}, {}'.format(self.client.uuid, self.name) @@ -102,6 +85,9 @@ class Accounting(models.Model): time_to = models.DateTimeField(blank=True, null=True, verbose_name="Ende") prize = models.DecimalField(max_digits=6, decimal_places=2, blank=True, null=True, verbose_name="Preis") billed = models.BooleanField(default=False, verbose_name="Abgerechnet") + reporter_uuid = models.UUIDField(blank=True, null=True, verbose_name='Reporter UUID') + prize_normal = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True, verbose_name="Preis Normalzeit") + prize_hh = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True, verbose_name="Preis Happy Hour") def __str__(self): return '{}: {} -> {}, {}, {}'.format(self.desk, self.time_from, self.time_to, self.prize, self.billed) @@ -116,5 +102,3 @@ class Accounting(models.Model): def test(sender, **kwargs): from .tasks import process_location_data process_location_data.delay() - - diff --git a/billard/serializers.py b/billard/serializers.py index 8cccd42..fcf57e7 100644 --- a/billard/serializers.py +++ b/billard/serializers.py @@ -1,4 +1,4 @@ -from billard.models import * +from billard.models import LocationData from rest_framework import serializers diff --git a/billard/templates/billard/accountmodal.html b/billard/templates/billard/accountmodal.html new file mode 100644 index 0000000..9d0b008 --- /dev/null +++ b/billard/templates/billard/accountmodal.html @@ -0,0 +1,30 @@ +{% if account %} +