46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from django.contrib import admin
|
|
from .models import *
|
|
from django import forms
|
|
from django.core.exceptions import ValidationError
|
|
|
|
|
|
@admin.register(Location)
|
|
class LocationAdmin(admin.ModelAdmin):
|
|
list_display = ('code', 'name', 'city',)
|
|
fields = ['users', 'code', 'name', 'street', 'plz', 'city', 'phone', 'email', 'url', ]
|
|
|
|
|
|
@admin.register(Client)
|
|
class ClientAdmin(admin.ModelAdmin):
|
|
list_display = ('uuid', 'location')
|
|
fields = ['location', 'uuid']
|
|
|
|
|
|
@admin.register(LocationData)
|
|
class LocationDataAdmin(admin.ModelAdmin):
|
|
list_display = ('client_id', 'desk_no', 'tst', 'on_off', 'processed', 'error_msg')
|
|
fields = ['client_id', 'desk_no', 'tst', 'on_off', 'processed', 'error_msg']
|
|
|
|
|
|
class DeskAdminForm(forms.ModelForm):
|
|
|
|
def clean_desk_no(self):
|
|
id = self.instance.id
|
|
client = self.cleaned_data['client']
|
|
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):
|
|
form = DeskAdminForm
|
|
list_display = ('client', 'desk_no', 'name', 'enabled', 'prize', 'prize_hh')
|
|
|
|
|
|
@admin.register(Accounting)
|
|
class AccountingAdmin(admin.ModelAdmin):
|
|
list_display = ('desk', 'time_from', 'time_to', 'prize', 'billed')
|