Skip to content

Expand Contacts #124

Merged
merged 10 commits into from
Jan 15, 2025
71 changes: 51 additions & 20 deletions locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-03-10 19:22+0100\n"
"POT-Creation-Date: 2025-01-15 14:56+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -84,7 +84,7 @@ msgstr "Generiere Inhaltsverzeichnis"
msgid "Page not available in %s"
msgstr "Seite auf %s nicht vorhanden"

#: mpicms/base/mixins.py:94 mpicms/personal/wagtail_hooks.py:79
#: mpicms/base/mixins.py:94 mpicms/personal/wagtail_hooks.py:97
msgid "Contacts"
msgstr "Kontakte"

Expand All @@ -93,7 +93,7 @@ msgid "Sidebar Content"
msgstr "Inhalt der Seitenleiste"

#: mpicms/base/models.py:46 mpicms/personal/models.py:68
#: mpicms/personal/models.py:95 mpicms/publications/models.py:26
#: mpicms/personal/models.py:120 mpicms/publications/models.py:26
#: venv0/lib/python3.7/site-packages/wagtailvideos/models.py:84
msgid "title"
msgstr "Titel"
Expand Down Expand Up @@ -235,70 +235,101 @@ msgstr "Neuigkeit"
msgid "news entries"
msgstr "Neuigkeiten"

#: mpicms/personal/models.py:25 mpicms/personal/models.py:31
#: mpicms/publications/models.py:27
#: mpicms/personal/models.py:25 mpicms/publications/models.py:27
msgid "groups"
msgstr "Gruppen"

#: mpicms/personal/models.py:44 mpicms/personal/models.py:50
#: mpicms/personal/models.py:31
#, fuzzy
#| msgid "groups"
msgid "group"
msgstr "Gruppen"

#: mpicms/personal/models.py:44
msgid "positions"
msgstr "Positionen"

#: mpicms/personal/models.py:96
#: mpicms/personal/models.py:50
#, fuzzy
#| msgid "positions"
msgid "position"
msgstr "Positionen"

#: mpicms/personal/models.py:83
msgid "status"
msgstr ""

#: mpicms/personal/models.py:97
msgid "special function"
msgstr ""

#: mpicms/personal/models.py:121
msgid "first name"
msgstr "Vorname"

#: mpicms/personal/models.py:97
#: mpicms/personal/models.py:122
msgid "last name"
msgstr "Nachname"

#: mpicms/personal/models.py:98
#: mpicms/personal/models.py:123
msgid "academic_suffix"
msgstr ""

#: mpicms/personal/models.py:124
msgid "email"
msgstr "Email-Adresse"

#: mpicms/personal/models.py:99
#: mpicms/personal/models.py:125
msgid "phone number"
msgstr "Telefonnummer"

#: mpicms/personal/models.py:100
#: mpicms/personal/models.py:126
msgid "room"
msgstr "Raum"

#: mpicms/personal/models.py:101
#: mpicms/personal/models.py:127
msgid "is active"
msgstr "ist aktiv"

#: mpicms/personal/models.py:103 mpicms/personal/models.py:159
#: mpicms/personal/models.py:129 mpicms/personal/models.py:191
msgid "priority"
msgstr "Priorität"

#: mpicms/personal/models.py:104
#: mpicms/personal/models.py:130
msgid "Priority from 0-999 to determine the sorting order."
msgstr "Priorität von 0-999 zur Bestimmung der Reihenfolge."

#: mpicms/personal/models.py:156
#: mpicms/personal/models.py:132
msgid "special functions"
msgstr ""

#: mpicms/personal/models.py:188
msgid "slug"
msgstr "Kürzel"

#: mpicms/personal/models.py:157
#: mpicms/personal/models.py:189
msgid "name"
msgstr "Name"

#: mpicms/personal/models.py:160
#: mpicms/personal/models.py:192
msgid "Priority from 0-99 to determine the sorting order."
msgstr "Priorität von 0-99 zur Bestimmung der Reihenfolge."

#: mpicms/personal/wagtail_hooks.py:37
#: mpicms/personal/models.py:220
msgid "valid"
msgstr ""

#: mpicms/personal/wagtail_hooks.py:40
msgid "Persons"
msgstr "Personen"

#: mpicms/personal/wagtail_hooks.py:49 mpicms/personal/wagtail_hooks.py:66
#: mpicms/personal/wagtail_hooks.py:52 mpicms/personal/wagtail_hooks.py:69
#: mpicms/templates/personal/list.html:46
#: mpicms/templates/wagtailusers/users/list.html:28
msgid "Groups"
msgstr "Gruppen"

#: mpicms/personal/wagtail_hooks.py:54 mpicms/personal/wagtail_hooks.py:73
#: mpicms/personal/wagtail_hooks.py:57 mpicms/personal/wagtail_hooks.py:76
#: mpicms/templates/personal/list.html:45
msgid "Positions"
msgstr "Positionen"
Expand Down
78 changes: 78 additions & 0 deletions mpicms/personal/migrations/0027_auto_20250115_1509.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Generated by Django 3.1.7 on 2025-01-15 14:09

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('personal', '0026_auto_20200813_1342'),
]

operations = [
migrations.CreateModel(
name='SpecialFunction',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=50, verbose_name='special function')),
('title_en', models.CharField(max_length=50, null=True, verbose_name='special function')),
('title_de', models.CharField(max_length=50, null=True, verbose_name='special function')),
],
),
migrations.CreateModel(
name='Status',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=50, verbose_name='status')),
('title_en', models.CharField(max_length=50, null=True, verbose_name='status')),
('title_de', models.CharField(max_length=50, null=True, verbose_name='status')),
],
options={
'verbose_name_plural': 'status',
},
),
migrations.AddField(
model_name='contact',
name='academic_suffix',
field=models.CharField(blank=True, max_length=50, verbose_name='academic_suffix'),
),
migrations.AlterField(
model_name='contact',
name='title',
field=models.CharField(blank=True, max_length=15, verbose_name='title'),
),
migrations.AlterField(
model_name='contactgroups',
name='group',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contacts', to='personal.group', verbose_name='group'),
),
migrations.AlterField(
model_name='contactpositions',
name='position',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contacts', to='personal.position', verbose_name='position'),
),
migrations.CreateModel(
name='WrittenConsent',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ref', models.CharField(max_length=10, unique=True, verbose_name='ID')),
('comment', models.TextField(blank=True, verbose_name='comment')),
('valid', models.BooleanField(default=True, verbose_name='valid')),
('contacts', models.ManyToManyField(blank=True, to='personal.Contact')),
],
options={
'ordering': ['ref'],
},
),
migrations.AddField(
model_name='contact',
name='special_functions',
field=models.ManyToManyField(blank=True, to='personal.SpecialFunction', verbose_name='special functions'),
),
migrations.AddField(
model_name='contact',
name='status',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='personal.status'),
),
]
53 changes: 49 additions & 4 deletions mpicms/personal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ContactGroups(Orderable, models.Model):
'personal.Group',
related_name='contacts',
on_delete=models.CASCADE,
verbose_name=_('groups')
verbose_name=_('group')
)

panels = [
Expand All @@ -47,7 +47,7 @@ class ContactPositions(Orderable, models.Model):
'personal.Position',
related_name='contacts',
on_delete=models.CASCADE,
verbose_name=_('positions')
verbose_name=_('position')
)

panels = [
Expand Down Expand Up @@ -79,6 +79,31 @@ def __str__(self):
return self.title


class Status(models.Model):
title = models.CharField(_("status"), max_length=50)

panels = [
FieldPanel('title')
]

def __str__(self):
return self.title

class Meta:
verbose_name_plural = "status"


class SpecialFunction(models.Model):
title = models.CharField(_("special function"), max_length=50)

panels = [
FieldPanel('title')
]

def __str__(self):
return self.title


@register_snippet
class Contact(index.Indexed, ClusterableModel):
"""
Expand All @@ -92,16 +117,19 @@ class Contact(index.Indexed, ClusterableModel):
to the database.
https://github.com/wagtail/django-modelcluster
"""
title = models.CharField(_("title"), max_length=5, blank=True)
title = models.CharField(_("title"), max_length=15, blank=True)
first_name = models.CharField(_("first name"), max_length=50, blank=True)
last_name = models.CharField(_("last name"), max_length=50, blank=True)
academic_suffix = models.CharField(_("academic_suffix"), max_length=50, blank=True)
email = models.EmailField(_("email"), blank=True)
phone = models.CharField(_("phone number"), blank=True, max_length=50)
room = models.CharField(_("room"), max_length=50, blank=True)
is_active = models.BooleanField(_("is active"), default=True)
priority = models.PositiveSmallIntegerField(
_("priority"), blank=True, default=0, validators=[MaxValueValidator(999)],
help_text=_("Priority from 0-999 to determine the sorting order."))
status = models.ForeignKey(Status, on_delete=models.SET_NULL, blank=True, null=True)
special_functions = models.ManyToManyField(SpecialFunction, verbose_name=_('special functions'), blank=True)

objects = ContactManager()

Expand All @@ -110,10 +138,14 @@ class Contact(index.Indexed, ClusterableModel):
FieldPanel('title', classname=''),
FieldPanel('first_name'),
FieldPanel('last_name'),
FieldPanel('academic_suffix'),
], heading='Name'),
FieldPanel('status'),
InlinePanel(
'positions', label="Positions",
panels=None),
panels=None
),
FieldPanel('special_functions'),
FieldPanel('email'),
FieldPanel('phone'),
FieldPanel('room'),
Expand Down Expand Up @@ -180,3 +212,16 @@ class Meta: # noqa
verbose_name = 'Group'
verbose_name_plural = 'Groups'
ordering = ['-priority']


class WrittenConsent(models.Model):
ref = models.CharField("ID", max_length=10, unique=True)
comment = models.TextField("comment", blank=True)
valid = models.BooleanField(_("valid"), default=True)
contacts = models.ManyToManyField(Contact, blank=True)

def __str__(self):
return "Written Consent #" + self.ref + " (" + ", ".join(str(c) for c in self.contacts.all()) + ")"

class Meta:
ordering = ['ref']
16 changes: 16 additions & 0 deletions mpicms/personal/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from modeltranslation.decorators import register

from .models import Position, Group
from .models import Status
from .models import SpecialFunction


@register(Position)
Expand All @@ -16,3 +18,17 @@ class GroupTR(TranslationOptions):
fields = (
'name',
)


@register(Status)
class StatusTR(TranslationOptions):
fields = (
'title',
)


@register(SpecialFunction)
class SpecialFunctionTR(TranslationOptions):
fields = (
'title',
)
23 changes: 22 additions & 1 deletion mpicms/personal/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from wagtail.contrib.modeladmin.views import EditView, InspectView, DeleteView, InstanceSpecificView

from .models import Contact, Group, Position
from .models import Status
from .models import SpecialFunction
from .models import WrittenConsent


class ContactInstanceView(InstanceSpecificView):
Expand Down Expand Up @@ -75,13 +78,31 @@ class PositionAdmin(ModelAdmin):
search_fields = ['title']


class StatusAdmin(ModelAdmin):
model = Status
menu_icon = 'tag'


class SpecialFunctionAdmin(ModelAdmin):
model = SpecialFunction
menu_icon = 'tag'


class WrittenConsentAdmin(ModelAdmin):
model = WrittenConsent
menu_icon='doc-full'


class ContactGroup(ModelAdminGroup):
menu_label = _('Contacts')
menu_icon = 'user'
items = [
ContactAdmin,
GroupAdmin,
PositionAdmin
PositionAdmin,
StatusAdmin,
SpecialFunctionAdmin,
WrittenConsentAdmin,
]


Expand Down