parent
f8c1482ef8
commit
accdb60a8c
9 changed files with 231 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Contact
|
||||
from .models import Contact, ContactTag
|
||||
|
||||
|
||||
@admin.register(Contact)
|
||||
|
@ -13,3 +13,10 @@ class FallenBirdAdmin(admin.ModelAdmin):
|
|||
"comment",
|
||||
]
|
||||
list_filter = ("name", "phone", "email", "address", "comment")
|
||||
|
||||
@admin.register(ContactTag)
|
||||
class ContactTagAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"tag",
|
||||
]
|
||||
list_filter = ("tag",)
|
30
app/contact/migrations/0001_initial.py
Normal file
30
app/contact/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Generated by Django 4.2.6 on 2023-10-22 09:59
|
||||
|
||||
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')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Kontakt',
|
||||
'verbose_name_plural': 'Kontakte',
|
||||
},
|
||||
),
|
||||
]
|
31
app/contact/migrations/0002_contacttag_contact_tag_id.py
Normal file
31
app/contact/migrations/0002_contacttag_contact_tag_id.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Generated by Django 4.2.6 on 2023-10-22 10:14
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contact', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ContactTag',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('tag', models.CharField(blank=True, max_length=50, null=True, verbose_name='Tag')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Kontakt Tag',
|
||||
'verbose_name_plural': 'Kontakt Tags',
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='contact',
|
||||
name='tag_id',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='contact.contacttag', verbose_name='Tag'),
|
||||
),
|
||||
]
|
|
@ -21,7 +21,21 @@ class Contact(models.Model):
|
|||
comment = models.CharField(
|
||||
max_length=50, null=True, blank=True, verbose_name=_("Bemerkungen")
|
||||
)
|
||||
tag_id = models.ForeignKey("ContactTag", on_delete=models.CASCADE, null=True, blank=True, verbose_name=_("Tag"))
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Kontakt")
|
||||
verbose_name_plural = _("Kontakte")
|
||||
|
||||
class ContactTag(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
|
||||
tag = models.CharField(
|
||||
max_length=50, null=True, blank=True, verbose_name=_("Tag")
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Kontakt Tag")
|
||||
verbose_name_plural = _("Kontakt Tags")
|
||||
|
||||
def __str__(self):
|
||||
return self.tag
|
|
@ -29,7 +29,7 @@
|
|||
"pagingType": "first_last_numbers",
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
order: [[2, 'desc']],
|
||||
order: [[0, 'asc']],
|
||||
columnDefs: [
|
||||
{ responsivePriority: 1, targets: 0 },
|
||||
]
|
||||
|
@ -57,6 +57,7 @@
|
|||
<th>Email</th>
|
||||
<th>Adresse</th>
|
||||
<th>Bemerkung</th>
|
||||
<th>Kategorie</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -67,6 +68,7 @@
|
|||
<td> {{ item.email|default_if_none:"" }} </td>
|
||||
<td> {{ item.address|default_if_none:"" }} </td>
|
||||
<td> {{ item.comment|default_if_none:"" }} </td>
|
||||
<td> {{ item.tag_id|default_if_none:"" }} </td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue