@@ -4,10 +4,25 @@ from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
|
||||
class LocationAdminForm(forms.ModelForm):
|
||||
|
||||
def clean_happy_hour_end(self):
|
||||
hh_start = self.cleaned_data['happy_hour_start']
|
||||
hh_end = self.cleaned_data['happy_hour_end']
|
||||
if hh_start is None and hh_end is not None:
|
||||
raise ValidationError('Start und Ende Zeit muss angegeben werden')
|
||||
if hh_start is not None and hh_end is None:
|
||||
raise ValidationError('Start und Ende Zeit muss angegeben werden')
|
||||
if not (hh_end > hh_start):
|
||||
raise ValidationError('Ende-Zeit muss nach Start-Zeit liegen')
|
||||
return self.cleaned_data['happy_hour_end']
|
||||
|
||||
|
||||
@admin.register(Location)
|
||||
class LocationAdmin(admin.ModelAdmin):
|
||||
list_display = ('code', 'name', 'city',)
|
||||
fields = ['users', 'code', 'name', 'street', 'plz', 'city', 'phone', 'email', 'url', ]
|
||||
form = LocationAdminForm
|
||||
list_display = ('code', 'name', 'city', 'happy_hour_start', 'happy_hour_end')
|
||||
fields = ['users', 'code', 'happy_hour_start', 'happy_hour_end', 'name', 'street', 'plz', 'city', 'phone', 'email', 'url', ]
|
||||
|
||||
|
||||
@admin.register(Client)
|
||||
|
||||
Reference in New Issue
Block a user