parent
a6833026c0
commit
d651e03b12
18 changed files with 196 additions and 58 deletions
|
@ -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),
|
||||
]
|
||||
|
|
0
app/contact/__init__.py
Normal file
0
app/contact/__init__.py
Normal file
14
app/contact/admin.py
Normal file
14
app/contact/admin.py
Normal file
|
@ -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")
|
8
app/contact/apps.py
Normal file
8
app/contact/apps.py
Normal file
|
@ -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")
|
26
app/contact/migrations/0001_initial.py
Normal file
26
app/contact/migrations/0001_initial.py
Normal file
|
@ -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')),
|
||||
],
|
||||
),
|
||||
]
|
0
app/contact/migrations/__init__.py
Normal file
0
app/contact/migrations/__init__.py
Normal file
28
app/contact/models.py
Normal file
28
app/contact/models.py
Normal file
|
@ -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")
|
75
app/contact/templates/contact/contact_all.html
Normal file
75
app/contact/templates/contact/contact_all.html
Normal file
|
@ -0,0 +1,75 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% block header %}
|
||||
<!-- Datatable CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.4/css/dataTables.bootstrap5.min.css" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.9/css/responsive.bootstrap5.min.css">
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
|
||||
|
||||
<!-- Datatable jQuery -->
|
||||
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.3/js/dataTables.bootstrap5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/responsive/2.2.9/js/dataTables.responsive.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/responsive/2.2.9/js/responsive.bootstrap5.min.js"></script>
|
||||
|
||||
<!-- Configure the DataTable. -->
|
||||
<script nonce="{{ request.csp_nonce }}">
|
||||
$(document).ready(function () {
|
||||
let table = $('#t__contact_all').DataTable({
|
||||
language: {
|
||||
url: 'https://cdn.datatables.net/plug-ins/1.11.3/i18n/de_de.json',
|
||||
},
|
||||
paging: true,
|
||||
info: true,
|
||||
"pagingType": "first_last_numbers",
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
order: [[2, 'desc']],
|
||||
columnDefs: [
|
||||
{ responsivePriority: 1, targets: 0 },
|
||||
]
|
||||
});
|
||||
table.on( 'responsive-display', function ( e, datatable, row, showHide, update ) {
|
||||
table.rows().every( function () {
|
||||
if (showHide && row.index() !== this.index() && this.child.isShown()) {
|
||||
$('td', this.node()).eq(0).click();
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
</script>
|
||||
{% endblock header %}
|
||||
|
||||
{% block content %}
|
||||
<h3>Übersicht aller Kontakte</h3>
|
||||
<p>Die Übersicht aller bisher hinterlegten Kontakte.</p>
|
||||
|
||||
<table class="table table-striped table-hover display responsive nowrap" width="100%" id="t__contact_all">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Telefon</th>
|
||||
<th>Email</th>
|
||||
<th>Adresse</th>
|
||||
<th>Bemerkung</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in contacts %}
|
||||
<tr>
|
||||
<td> {{ item.name }} </td>
|
||||
<td> {{ item.phone|default_if_none:"" }}</td>
|
||||
<td> {{ item.email|default_if_none:"" }} </td>
|
||||
<td> {{ item.address|default_if_none:"" }} </td>
|
||||
<td> {{ item.comment|default_if_none:"" }} </td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock content %}
|
||||
|
3
app/contact/tests.py
Normal file
3
app/contact/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
7
app/contact/urls.py
Normal file
7
app/contact/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.urls import path
|
||||
|
||||
from .views import contact_all
|
||||
|
||||
urlpatterns = [
|
||||
path("", contact_all, name="contact_all"),
|
||||
]
|
10
app/contact/views.py
Normal file
10
app/contact/views.py
Normal file
|
@ -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)
|
|
@ -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
|
||||
|
|
|
@ -72,6 +72,7 @@ INSTALLED_APPS = [
|
|||
# -----------------------------------
|
||||
"aviary",
|
||||
"bird",
|
||||
"contact",
|
||||
"costs",
|
||||
"export",
|
||||
"rescuer",
|
||||
|
|
|
@ -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")),
|
||||
|
|
|
@ -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 = [
|
||||
|
|
|
@ -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'],
|
||||
},
|
||||
),
|
||||
]
|
||||
|
|
|
@ -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'},
|
||||
),
|
||||
]
|
|
@ -32,6 +32,10 @@
|
|||
<a class="nav-link {% if '/costs/all' in request.path %} active {% endif %}"
|
||||
href="{% url 'costs_all' %}">alle Kosten</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if '/contacts' in request.path %} active {% endif %}"
|
||||
href="{% url 'contact_all' %}">Kontakte</a>
|
||||
</li>
|
||||
|
||||
{% if request.user|group_check:"data-export" %}
|
||||
<li class="nav-item">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue