carom-server/billard/admin.py

46 lines
1.4 KiB
Python
Raw Normal View History

2017-01-03 19:26:51 +01:00
from django.contrib import admin
2017-01-03 19:40:35 +01:00
from .models import *
2017-02-11 18:36:32 +01:00
from django import forms
from django.core.exceptions import ValidationError
2017-01-03 19:26:51 +01:00
2017-01-03 19:40:35 +01:00
2017-01-03 19:48:00 +01:00
@admin.register(Location)
2017-01-03 19:40:35 +01:00
class LocationAdmin(admin.ModelAdmin):
2017-02-01 13:51:15 +01:00
list_display = ('code', 'name', 'city',)
2017-02-04 06:51:09 +01:00
fields = ['users', 'code', 'name', 'street', 'plz', 'city', 'phone', 'email', 'url', ]
2017-01-03 19:40:35 +01:00
2017-01-03 19:48:00 +01:00
@admin.register(Client)
2017-01-03 19:40:35 +01:00
class ClientAdmin(admin.ModelAdmin):
2017-02-10 19:39:21 +01:00
list_display = ('uuid', 'location')
fields = ['location', 'uuid']
2017-01-06 20:24:36 +01:00
@admin.register(LocationData)
class LocationDataAdmin(admin.ModelAdmin):
2017-02-10 20:49:38 +01:00
list_display = ('client_id', 'desk_no', 'tst', 'on_off', 'processed', 'error_msg')
fields = ['client_id', 'desk_no', 'tst', 'on_off', 'processed', 'error_msg']
2017-02-01 20:25:33 +01:00
2017-02-11 18:36:32 +01:00
class DeskAdminForm(forms.ModelForm):
def clean_desk_no(self):
id = self.instance.id
2017-02-11 20:10:24 +01:00
client = self.cleaned_data['client']
2017-02-11 18:36:32 +01:00
desk_no = self.cleaned_data['desk_no']
t = Desk.objects.filter(desk_no=desk_no, client=client).exclude(id=id)
if t.count() > 0:
raise ValidationError('Tischnummer bereits vergeben.')
return self.cleaned_data['desk_no']
@admin.register(Desk)
class DeskAdmin(admin.ModelAdmin):
2017-02-11 18:36:32 +01:00
form = DeskAdminForm
list_display = ('client', 'desk_no', 'name', 'enabled', 'prize', 'prize_hh')
2017-02-01 20:25:33 +01:00
@admin.register(Accounting)
class AccountingAdmin(admin.ModelAdmin):
2017-02-11 10:23:03 +01:00
list_display = ('desk', 'time_from', 'time_to', 'prize', 'billed')