From d651e03b12f098c74d999874e8297bf357183563 Mon Sep 17 00:00:00 2001 From: Gunther Weissenbaeck Date: Mon, 16 Oct 2023 21:05:44 +0200 Subject: [PATCH] Kontakte Fixes #63 --- app/bird/migrations/0001_initial.py | 4 +- app/contact/__init__.py | 0 app/contact/admin.py | 14 ++++ app/contact/apps.py | 8 ++ app/contact/migrations/0001_initial.py | 26 +++++++ app/contact/migrations/__init__.py | 0 app/contact/models.py | 28 +++++++ .../templates/contact/contact_all.html | 75 +++++++++++++++++++ app/contact/tests.py | 3 + app/contact/urls.py | 7 ++ app/contact/views.py | 10 +++ app/core/jazzmin.py | 2 +- app/core/settings.py | 1 + app/core/urls.py | 1 + app/costs/migrations/0001_initial.py | 4 +- app/rescuer/migrations/0001_initial.py | 50 ++++--------- .../migrations/0002_alter_rescuer_options.py | 17 ----- app/templates/partials/_navbar.html | 4 + 18 files changed, 196 insertions(+), 58 deletions(-) create mode 100644 app/contact/__init__.py create mode 100644 app/contact/admin.py create mode 100644 app/contact/apps.py create mode 100644 app/contact/migrations/0001_initial.py create mode 100644 app/contact/migrations/__init__.py create mode 100644 app/contact/models.py create mode 100644 app/contact/templates/contact/contact_all.html create mode 100644 app/contact/tests.py create mode 100644 app/contact/urls.py create mode 100644 app/contact/views.py delete mode 100644 app/rescuer/migrations/0002_alter_rescuer_options.py diff --git a/app/bird/migrations/0001_initial.py b/app/bird/migrations/0001_initial.py index b4618a1..a99d362 100644 --- a/app/bird/migrations/0001_initial.py +++ b/app/bird/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.5 on 2023-09-17 21:04 +# Generated by Django 4.2.5 on 2023-10-16 18:35 from django.conf import settings from django.db import migrations, models @@ -11,7 +11,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('rescuer', '0002_alter_rescuer_options'), + ('rescuer', '0001_initial'), ('aviary', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] diff --git a/app/contact/__init__.py b/app/contact/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/contact/admin.py b/app/contact/admin.py new file mode 100644 index 0000000..b40002d --- /dev/null +++ b/app/contact/admin.py @@ -0,0 +1,14 @@ +from django.contrib import admin + +from .models import Contact + +@admin.register(Contact) +class FallenBirdAdmin(admin.ModelAdmin): + list_display = [ + "name", + "phone", + "email", + "address", + "comment", + ] + list_filter = ("name", "phone", "email", "address", "comment") \ No newline at end of file diff --git a/app/contact/apps.py b/app/contact/apps.py new file mode 100644 index 0000000..7266e34 --- /dev/null +++ b/app/contact/apps.py @@ -0,0 +1,8 @@ +from django.apps import AppConfig +from django.utils.translation import gettext_lazy as _ + + +class ContactConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'contact' + verbose_name=_("Kontakte") \ No newline at end of file diff --git a/app/contact/migrations/0001_initial.py b/app/contact/migrations/0001_initial.py new file mode 100644 index 0000000..e486762 --- /dev/null +++ b/app/contact/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.5 on 2023-10-16 18:42 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Contact', + fields=[ + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('name', models.CharField(blank=True, max_length=50, null=True, verbose_name='Kontakt Name')), + ('phone', models.CharField(blank=True, max_length=50, null=True, verbose_name='Telefon')), + ('email', models.CharField(blank=True, max_length=50, null=True, verbose_name='Email')), + ('address', models.CharField(blank=True, max_length=50, null=True, verbose_name='Adresse')), + ('comment', models.CharField(blank=True, max_length=50, null=True, verbose_name='Bemerkungen')), + ], + ), + ] diff --git a/app/contact/migrations/__init__.py b/app/contact/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/contact/models.py b/app/contact/models.py new file mode 100644 index 0000000..8807008 --- /dev/null +++ b/app/contact/models.py @@ -0,0 +1,28 @@ +from django.db import models +from uuid import uuid4 + +from django.utils.translation import gettext_lazy as _ + + +class Contact(models.Model): + id = models.UUIDField(primary_key=True, default=uuid4, editable=False) + name = models.CharField( + max_length=50, null=True, blank=True, verbose_name=_("Kontakt Name") + ) + phone = models.CharField( + max_length=50, null=True, blank=True, verbose_name=_("Telefon") + ) + email = models.CharField( + max_length=50, null=True, blank=True, verbose_name=_("Email") + ) + address = models.CharField( + max_length=50, null=True, blank=True, verbose_name=_("Adresse") + ) + comment = models.CharField( + max_length=50, null=True, blank=True, verbose_name=_("Bemerkungen") + ) + + + class Meta: + verbose_name = _("Kontakt") + verbose_name_plural = _("Kontakte") diff --git a/app/contact/templates/contact/contact_all.html b/app/contact/templates/contact/contact_all.html new file mode 100644 index 0000000..949c475 --- /dev/null +++ b/app/contact/templates/contact/contact_all.html @@ -0,0 +1,75 @@ +{% extends "base.html" %} +{% load static %} +{% block header %} + + + + + + + + + + + + + + + + + + +{% endblock header %} + +{% block content %} +

Übersicht aller Kontakte

+

Die Übersicht aller bisher hinterlegten Kontakte.

+ + + + + + + + + + + + + {% for item in contacts %} + + + + + + + + {% endfor %} + +
NameTelefonEmailAdresseBemerkung
{{ item.name }} {{ item.phone|default_if_none:"" }} {{ item.email|default_if_none:"" }} {{ item.address|default_if_none:"" }} {{ item.comment|default_if_none:"" }}
+{% endblock content %} + diff --git a/app/contact/tests.py b/app/contact/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/app/contact/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/contact/urls.py b/app/contact/urls.py new file mode 100644 index 0000000..aece6bf --- /dev/null +++ b/app/contact/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from .views import contact_all + +urlpatterns = [ + path("", contact_all, name="contact_all"), +] diff --git a/app/contact/views.py b/app/contact/views.py new file mode 100644 index 0000000..20cdcb5 --- /dev/null +++ b/app/contact/views.py @@ -0,0 +1,10 @@ +from django.shortcuts import render +from django.contrib.auth.decorators import login_required + +from .models import Contact + +@login_required(login_url="account_login") +def contact_all(request): + contacts = Contact.objects.all() + context = {"contacts": contacts} + return render(request, "contact/contact_all.html", context) \ No newline at end of file diff --git a/app/core/jazzmin.py b/app/core/jazzmin.py index 55a540b..df462c6 100644 --- a/app/core/jazzmin.py +++ b/app/core/jazzmin.py @@ -25,7 +25,7 @@ JAZZMIN_SETTINGS = { "search_model": [ "aviary.Aviary", "bird.FallenBird", - "bird.User", + # "bird.User", "rescuer.Rescuer", ], # Field name on user model that contains avatar ImageField/URLField/Charfield or a callable that receives the user diff --git a/app/core/settings.py b/app/core/settings.py index e9bea9a..6559171 100644 --- a/app/core/settings.py +++ b/app/core/settings.py @@ -72,6 +72,7 @@ INSTALLED_APPS = [ # ----------------------------------- "aviary", "bird", + "contact", "costs", "export", "rescuer", diff --git a/app/core/urls.py b/app/core/urls.py index a4ecb8c..2bbe8c0 100644 --- a/app/core/urls.py +++ b/app/core/urls.py @@ -7,6 +7,7 @@ urlpatterns = [ path("", views.bird_all, name="index"), path("aviary/", include("aviary.urls")), path("bird/", include("bird.urls")), + path("contacts/", include("contact.urls")), path("costs/", include("costs.urls")), path("export/", include("export.urls")), path("rescuer/", include("rescuer.urls")), diff --git a/app/costs/migrations/0001_initial.py b/app/costs/migrations/0001_initial.py index f6298de..7df588e 100644 --- a/app/costs/migrations/0001_initial.py +++ b/app/costs/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.5 on 2023-09-17 21:04 +# Generated by Django 4.2.5 on 2023-10-16 18:35 from django.conf import settings from django.db import migrations, models @@ -11,8 +11,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('bird', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('bird', '0001_initial'), ] operations = [ diff --git a/app/rescuer/migrations/0001_initial.py b/app/rescuer/migrations/0001_initial.py index bf3fe0d..971cb88 100644 --- a/app/rescuer/migrations/0001_initial.py +++ b/app/rescuer/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.3 on 2023-07-28 14:09 +# Generated by Django 4.2.5 on 2023-10-16 18:19 from django.conf import settings from django.db import migrations, models @@ -16,44 +16,22 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name="Rescuer", + name='Rescuer', fields=[ - ( - "id", - models.UUIDField( - default=uuid.uuid4, - editable=False, - primary_key=True, - serialize=False, - ), - ), - ( - "first_name", - models.CharField(max_length=200, verbose_name="Vorname"), - ), - ( - "last_name", - models.CharField(max_length=200, verbose_name="Nachname"), - ), - ("street", models.CharField(max_length=200, verbose_name="Straße")), - ( - "street_number", - models.CharField(max_length=20, verbose_name="Nummer"), - ), - ("city", models.CharField(max_length=200, verbose_name="Stadt")), - ("zip_code", models.CharField(max_length=200, verbose_name="PLZ")), - ("phone", models.CharField(max_length=200, verbose_name="Telefon")), - ( - "user", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, - to=settings.AUTH_USER_MODEL, - ), - ), + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('first_name', models.CharField(max_length=200, verbose_name='Vorname')), + ('last_name', models.CharField(max_length=200, verbose_name='Nachname')), + ('street', models.CharField(max_length=200, verbose_name='Straße')), + ('street_number', models.CharField(max_length=20, verbose_name='Nummer')), + ('city', models.CharField(max_length=200, verbose_name='Stadt')), + ('zip_code', models.CharField(max_length=200, verbose_name='PLZ')), + ('phone', models.CharField(max_length=200, verbose_name='Telefon')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ - "verbose_name": "Finder", - "verbose_name_plural": "Finder", + 'verbose_name': 'Finder', + 'verbose_name_plural': 'Finder', + 'ordering': ['last_name'], }, ), ] diff --git a/app/rescuer/migrations/0002_alter_rescuer_options.py b/app/rescuer/migrations/0002_alter_rescuer_options.py deleted file mode 100644 index 4164a0c..0000000 --- a/app/rescuer/migrations/0002_alter_rescuer_options.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 4.2.4 on 2023-08-12 12:57 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('rescuer', '0001_initial'), - ] - - operations = [ - migrations.AlterModelOptions( - name='rescuer', - options={'ordering': ['last_name'], 'verbose_name': 'Finder', 'verbose_name_plural': 'Finder'}, - ), - ] diff --git a/app/templates/partials/_navbar.html b/app/templates/partials/_navbar.html index bef0e2c..4b45395 100644 --- a/app/templates/partials/_navbar.html +++ b/app/templates/partials/_navbar.html @@ -32,6 +32,10 @@ alle Kosten + {% if request.user|group_check:"data-export" %}