diff --git a/core/migrations/0007_approval.py b/core/migrations/0007_approval.py new file mode 100755 index 0000000..6893d66 --- /dev/null +++ b/core/migrations/0007_approval.py @@ -0,0 +1,29 @@ +# Generated by Django 4.2.16 on 2024-12-03 12:41 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0006_berichtsheft_num"), + ] + + operations = [ + migrations.CreateModel( + name="Approval", + fields=[ + ("id", models.AutoField(primary_key=True, serialize=False)), + ("user", models.TextField()), + ( + "report", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="report", + to="core.berichtsheft", + ), + ), + ], + ), + ] diff --git a/core/migrations/0008_berichtsheft_needs_rewrite.py b/core/migrations/0008_berichtsheft_needs_rewrite.py new file mode 100755 index 0000000..8c5ea61 --- /dev/null +++ b/core/migrations/0008_berichtsheft_needs_rewrite.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.16 on 2024-12-03 12:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0007_approval"), + ] + + operations = [ + migrations.AddField( + model_name="berichtsheft", + name="needs_rewrite", + field=models.BooleanField(default=False), + ), + ] diff --git a/core/models.py b/core/models.py index 8a57865..b441b63 100755 --- a/core/models.py +++ b/core/models.py @@ -28,13 +28,18 @@ class Berichtsheft(models.Model): year = models.PositiveIntegerField() week = models.PositiveSmallIntegerField() content = models.JSONField() + needs_rewrite = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True) def __str__(self): return f"Berichtsheft: {self.user}, Year: {self.year}, Week: {self.week}" + def is_approved(self): + approvals = Approval.objects.filter(report=self.id) + return len(approvals) >= 2 -class Approval: + +class Approval(models.Model): id = models.AutoField(primary_key=True) user = models.TextField() report = models.ForeignKey( diff --git a/core/styles.py b/core/styles.py new file mode 100755 index 0000000..44d1780 --- /dev/null +++ b/core/styles.py @@ -0,0 +1,6 @@ +# Tailwind Styles + +STYLE = { + "red_btn": "text-white bg-red-700 hover:bg-red-800 focus:outline-none focus:ring-4 focus:ring-red-300 font-medium rounded-full text-sm px-5 py-2.5 text-center me-2 mb-2 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900", + "card": "a4-page bg-white shadow-lg p-6 mx-auto my-10", +} diff --git a/core/templates/index.html b/core/templates/index.html index ab7cf7f..fdf059f 100755 --- a/core/templates/index.html +++ b/core/templates/index.html @@ -1,17 +1,7 @@
{{ report }}
+ + + {% if forloop.last %} + {% if report.week != week_now %} +Berichtsheft {{ report.year }} / {{ report.week }}
+ +Is Approved ? {{ approved }}
+ + {% for key, value in report.content.items %} + +{{ key }} : {{ value }}
+ + {% endfor %} + + \ No newline at end of file diff --git a/core/urls.py b/core/urls.py index 6a9c653..ffbc220 100755 --- a/core/urls.py +++ b/core/urls.py @@ -4,5 +4,5 @@ from . import views urlpatterns = [ path("", views.index, name="index"), path("write", views.write_new_report, name="write"), - path("test", views.test, name="test"), + path("report/