From a6ea7336a2d650044edde553789ef3e8e18a0314 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

---
 .../aub/migrations/0013_auto_20190411_1203.py | 17 +++++++++++
 schoolapps/schoolapps/settings.py             |  2 ++
 schoolapps/timetable/forms.py                 |  2 +-
 .../migrations/0004_auto_20190411_1219.py     | 22 ++++++++++++++
 schoolapps/timetable/models.py                |  6 ++--
 .../templates/timetable/addhint.html          | 30 ++++++++++++++++++-
 6 files changed, 73 insertions(+), 6 deletions(-)
 create mode 100644 schoolapps/aub/migrations/0013_auto_20190411_1203.py
 create mode 100644 schoolapps/timetable/migrations/0004_auto_20190411_1219.py

diff --git a/schoolapps/aub/migrations/0013_auto_20190411_1203.py b/schoolapps/aub/migrations/0013_auto_20190411_1203.py
new file mode 100644
index 000000000..0f4fa642c
--- /dev/null
+++ b/schoolapps/aub/migrations/0013_auto_20190411_1203.py
@@ -0,0 +1,17 @@
+# Generated by Django 2.2 on 2019-04-11 10:03
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ('aub', '0012_auto_20190410_1416'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='aub',
+            name='status',
+            field=models.ForeignKey(default=1, on_delete=models.SET(1), related_name='aubs', to='aub.Status'),
+        ),
+    ]
diff --git a/schoolapps/schoolapps/settings.py b/schoolapps/schoolapps/settings.py
index 105914410..ae40be870 100755
--- a/schoolapps/schoolapps/settings.py
+++ b/schoolapps/schoolapps/settings.py
@@ -56,6 +56,8 @@ INSTALLED_APPS = [
     'material',
     'django_react_templatetags',
     'martor',
+    'widget_tweaks',
+
 ]
 
 MIDDLEWARE = [
diff --git a/schoolapps/timetable/forms.py b/schoolapps/timetable/forms.py
index fba3f647d..4da10e161 100644
--- a/schoolapps/timetable/forms.py
+++ b/schoolapps/timetable/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/schoolapps/timetable/migrations/0004_auto_20190411_1219.py b/schoolapps/timetable/migrations/0004_auto_20190411_1219.py
new file mode 100644
index 000000000..6ddb7b934
--- /dev/null
+++ b/schoolapps/timetable/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/schoolapps/timetable/models.py b/schoolapps/timetable/models.py
index e332cc609..2ad830ce2 100755
--- a/schoolapps/timetable/models.py
+++ b/schoolapps/timetable/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/schoolapps/timetable/templates/timetable/addhint.html b/schoolapps/timetable/templates/timetable/addhint.html
index a983c1842..867b943a0 100755
--- a/schoolapps/timetable/templates/timetable/addhint.html
+++ b/schoolapps/timetable/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