parent
9df1ed5b79
commit
6d16a473bf
@ -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)
|
||||
|
25
billard/migrations/0016_auto_20170225_1822.py
Normal file
25
billard/migrations/0016_auto_20170225_1822.py
Normal file
@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-02-25 18:22
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('billard', '0015_auto_20170222_1023'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='location',
|
||||
name='happy_hour_end',
|
||||
field=models.TimeField(blank=True, null=True, verbose_name='Happy Hour Ende'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='location',
|
||||
name='happy_hour_start',
|
||||
field=models.TimeField(blank=True, null=True, verbose_name='Happy Hour Start'),
|
||||
),
|
||||
]
|
@ -36,7 +36,9 @@ class Location(models.Model):
|
||||
city = models.CharField(max_length=64, blank=True, null=True, verbose_name="Stadt")
|
||||
phone = models.CharField(max_length=64, blank=True, null=True, verbose_name="Telefon")
|
||||
email = models.EmailField(blank=True, null=True, verbose_name="Email")
|
||||
url = models.URLField(blank=True,null=True, verbose_name="URL")
|
||||
url = models.URLField(blank=True, null=True, verbose_name="URL")
|
||||
happy_hour_start = models.TimeField(blank=True, null=True, verbose_name='Happy Hour Start')
|
||||
happy_hour_end = models.TimeField(blank=True, null=True, verbose_name='Happy Hour Ende')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
Loading…
Reference in New Issue
Block a user