From 39f55b1d8a351eba1f03089885e195684029147c Mon Sep 17 00:00:00 2001 From: HanseGucker <joniweth@gmx.de> Date: Thu, 11 Apr 2019 12:23:40 +0200 Subject: [PATCH] Work at hint form --- biscuit/apps/chronos/forms.py | 2 +- .../migrations/0004_auto_20190411_1219.py | 22 ++++++++++++++ biscuit/apps/chronos/models.py | 6 ++-- .../chronos/templates/timetable/addhint.html | 30 ++++++++++++++++++- 4 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 biscuit/apps/chronos/migrations/0004_auto_20190411_1219.py diff --git a/biscuit/apps/chronos/forms.py b/biscuit/apps/chronos/forms.py index fba3f647..4da10e16 100644 --- a/biscuit/apps/chronos/forms.py +++ b/biscuit/apps/chronos/forms.py @@ -17,4 +17,4 @@ class HintForm(ModelForm): class Meta: model = Hint - fields = ("from_date", "to_date", "text", "classes") + fields = ("from_date", "to_date", "text", "classes", "teachers") diff --git a/biscuit/apps/chronos/migrations/0004_auto_20190411_1219.py b/biscuit/apps/chronos/migrations/0004_auto_20190411_1219.py new file mode 100644 index 00000000..6ddb7b93 --- /dev/null +++ b/biscuit/apps/chronos/migrations/0004_auto_20190411_1219.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2 on 2019-04-11 10:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('timetable', '0003_auto_20190410_1634'), + ] + + operations = [ + migrations.AddField( + model_name='hint', + name='teachers', + field=models.BooleanField(default=False, verbose_name='Lehrer?'), + ), + migrations.AlterField( + model_name='hint', + name='classes', + field=models.ManyToManyField(related_name='hints', to='timetable.HintClass', verbose_name='Klassen'), + ), + ] diff --git a/biscuit/apps/chronos/models.py b/biscuit/apps/chronos/models.py index e332cc60..2ad830ce 100755 --- a/biscuit/apps/chronos/models.py +++ b/biscuit/apps/chronos/models.py @@ -35,16 +35,14 @@ class Hint(models.Model): text = MartorField(verbose_name="Hinweistext") # Relations - classes = ManyToManyField(HintClass, related_name="hints") + classes = models.ManyToManyField(HintClass, related_name="hints", verbose_name="Klassen") + teachers = models.BooleanField(verbose_name="Lehrer?", default=False) class Meta: verbose_name = "Hinweis" verbose_name_plural = "Hinweise" - - - class Timetable(models.Model): class Meta: permissions = ( diff --git a/biscuit/apps/chronos/templates/timetable/addhint.html b/biscuit/apps/chronos/templates/timetable/addhint.html index a983c184..867b943a 100755 --- a/biscuit/apps/chronos/templates/timetable/addhint.html +++ b/biscuit/apps/chronos/templates/timetable/addhint.html @@ -2,13 +2,41 @@ {% load material_form %} {% load martortags %} {% load static %} +{% load widget_tweaks %} <main> <h4>Neuen Hinweis erstellen</h4> <form method="post"> {% csrf_token %} - {{ form }} + {{ form.non_field_errors }} + <h5>Über welchen Zeitraum soll der Hinweis angezeigt werden? <span class="red-text">*</span></h5> + + <div class="row"> + <div class="col s12 m6"> + {{ form.from_date.label_tag }} + {{ form.from_date|add_class:"datepicker" }} + </div> + <div class="col s12 m6"> + {{ form.to_date.label_tag }} + {{ form.to_date|add_class:"datepicker" }} + </div> + </div> + <h5>Für wen soll der Hinweis angezeigt werden? <span class="red-text">*</span></h5> + {{ form.classes.label_tag }} + {{ form.classes }} + + <p> + <label> + {{ form.teachers }} + <span>Für Lehrer anzeigen?</span> + </label> + </p> + + <h5>Hinweistext <span class="red-text">*</span></h5> + {{ form.text }} + + <button type="submit" class="waves-effect waves-light btn green"> <i class="material-icons left">add</i> Hinweis erstellen und veröffentlichen </button> -- GitLab