From 78c62d025072610c6891cd74aa6443467ae35c3f Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 8 Jan 2022 18:49:13 +0100 Subject: [PATCH 01/10] personal: Add model WrittenConsent --- mpicms/personal/models.py | 13 +++++++++++++ mpicms/personal/wagtail_hooks.py | 9 ++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mpicms/personal/models.py b/mpicms/personal/models.py index e7c8035..c1b12bd 100644 --- a/mpicms/personal/models.py +++ b/mpicms/personal/models.py @@ -180,3 +180,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'] diff --git a/mpicms/personal/wagtail_hooks.py b/mpicms/personal/wagtail_hooks.py index 0548aa9..bc588ab 100644 --- a/mpicms/personal/wagtail_hooks.py +++ b/mpicms/personal/wagtail_hooks.py @@ -6,6 +6,7 @@ from wagtail.contrib.modeladmin.views import EditView, InspectView, DeleteView, InstanceSpecificView from .models import Contact, Group, Position +from .models import WrittenConsent class ContactInstanceView(InstanceSpecificView): @@ -75,13 +76,19 @@ class PositionAdmin(ModelAdmin): search_fields = ['title'] +class WrittenConsentAdmin(ModelAdmin): + model = WrittenConsent + menu_icon='doc-full' + + class ContactGroup(ModelAdminGroup): menu_label = _('Contacts') menu_icon = 'user' items = [ ContactAdmin, GroupAdmin, - PositionAdmin + PositionAdmin, + WrittenConsentAdmin, ] From efd06cf1dbfd324ba7c7750c547b1e12dfaa84b0 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 8 Jan 2022 19:18:24 +0100 Subject: [PATCH 02/10] personal: Add academic_suffix --- mpicms/personal/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mpicms/personal/models.py b/mpicms/personal/models.py index c1b12bd..64b9a47 100644 --- a/mpicms/personal/models.py +++ b/mpicms/personal/models.py @@ -95,6 +95,7 @@ class Contact(index.Indexed, ClusterableModel): title = models.CharField(_("title"), max_length=5, 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) @@ -110,6 +111,7 @@ class Contact(index.Indexed, ClusterableModel): FieldPanel('title', classname=''), FieldPanel('first_name'), FieldPanel('last_name'), + FieldPanel('academic_suffix'), ], heading='Name'), InlinePanel( 'positions', label="Positions", From fc7c957d5ffd7ec2547d2e99e823ca94dcd44de4 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 8 Jan 2022 19:33:49 +0100 Subject: [PATCH 03/10] personal: Add Status, SpecialFunction --- mpicms/personal/models.py | 25 +++++++++++++++++++++++++ mpicms/personal/wagtail_hooks.py | 14 ++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/mpicms/personal/models.py b/mpicms/personal/models.py index 64b9a47..bbf9e55 100644 --- a/mpicms/personal/models.py +++ b/mpicms/personal/models.py @@ -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): """ diff --git a/mpicms/personal/wagtail_hooks.py b/mpicms/personal/wagtail_hooks.py index bc588ab..8e3565b 100644 --- a/mpicms/personal/wagtail_hooks.py +++ b/mpicms/personal/wagtail_hooks.py @@ -6,6 +6,8 @@ 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 @@ -76,6 +78,16 @@ 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' @@ -88,6 +100,8 @@ class ContactGroup(ModelAdminGroup): ContactAdmin, GroupAdmin, PositionAdmin, + StatusAdmin, + SpecialFunctionAdmin, WrittenConsentAdmin, ] From a59d086bf946a2b0fa19e485af3369c2af5b56a7 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 8 Jan 2022 20:37:24 +0100 Subject: [PATCH 04/10] personal: Add status and special_functions to Contact --- mpicms/personal/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mpicms/personal/models.py b/mpicms/personal/models.py index bbf9e55..6c1d657 100644 --- a/mpicms/personal/models.py +++ b/mpicms/personal/models.py @@ -128,6 +128,8 @@ class Contact(index.Indexed, ClusterableModel): 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, blank=True) objects = ContactManager() @@ -138,9 +140,12 @@ class Contact(index.Indexed, ClusterableModel): 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'), @@ -213,7 +218,7 @@ 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) + contacts = models.ManyToManyField(Contact, blank=True) def __str__(self): return "Written Consent #" + self.ref + " (" + ", ".join(str(c) for c in self.contacts.all()) + ")" From 90102a48df0cc8472cddbcfd80cd56bc14cbb785 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Tue, 11 Jan 2022 14:06:34 +0100 Subject: [PATCH 05/10] personal: Add modeltranslations for new models --- mpicms/personal/translation.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mpicms/personal/translation.py b/mpicms/personal/translation.py index bf716aa..156b175 100644 --- a/mpicms/personal/translation.py +++ b/mpicms/personal/translation.py @@ -2,6 +2,8 @@ from modeltranslation.decorators import register from .models import Position, Group +from .models import Status +from .models import SpecialFunction @register(Position) @@ -16,3 +18,17 @@ class GroupTR(TranslationOptions): fields = ( 'name', ) + + +@register(Status) +class StatusTR(TranslationOptions): + fields = ( + 'title', + ) + + +@register(SpecialFunction) +class SpecialFunctionTR(TranslationOptions): + fields = ( + 'title', + ) From ae6dd7b36e940a465e30e0f15eb90cfaf9e6c184 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Tue, 11 Jan 2022 16:19:33 +0100 Subject: [PATCH 06/10] personal: fix name of group and position field to singular --- mpicms/personal/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mpicms/personal/models.py b/mpicms/personal/models.py index 6c1d657..c78989f 100644 --- a/mpicms/personal/models.py +++ b/mpicms/personal/models.py @@ -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 = [ @@ -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 = [ From ede5d4bb87c93492f30b009fe3397eb28e83627d Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Tue, 11 Jan 2022 16:23:50 +0100 Subject: [PATCH 07/10] Contact: make "special functions" attribute translatable --- mpicms/personal/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpicms/personal/models.py b/mpicms/personal/models.py index c78989f..9eb5967 100644 --- a/mpicms/personal/models.py +++ b/mpicms/personal/models.py @@ -129,7 +129,7 @@ class Contact(index.Indexed, ClusterableModel): _("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, blank=True) + special_functions = models.ManyToManyField(SpecialFunction, verbose_name=_('special functions'), blank=True) objects = ContactManager() From ddcce045ffa196642a9c4a6376669511a8b87d79 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 15 Jan 2025 15:01:22 +0100 Subject: [PATCH 08/10] personal: Increase length of title --- mpicms/personal/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpicms/personal/models.py b/mpicms/personal/models.py index 9eb5967..27d77ca 100644 --- a/mpicms/personal/models.py +++ b/mpicms/personal/models.py @@ -117,7 +117,7 @@ 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) From 0eaa5f14f1adafc406a257a26e6ff95da1ef43cf Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 15 Jan 2025 15:13:46 +0100 Subject: [PATCH 09/10] Update translations Run ./manage.py makemessages -l de --ignore venv0/lib/python3.7/site-packages/xlwt --- locale/de/LC_MESSAGES/django.po | 71 +++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index b47c033..e5d61e9 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \n" @@ -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" @@ -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" @@ -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" From 221b7ffb0a09ae527532a002e26b7721ab004371 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 15 Jan 2025 15:14:51 +0100 Subject: [PATCH 10/10] Add migration after schema change Create migration with ./manage.py makemigrations --- .../migrations/0027_auto_20250115_1509.py | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 mpicms/personal/migrations/0027_auto_20250115_1509.py diff --git a/mpicms/personal/migrations/0027_auto_20250115_1509.py b/mpicms/personal/migrations/0027_auto_20250115_1509.py new file mode 100644 index 0000000..f3a266b --- /dev/null +++ b/mpicms/personal/migrations/0027_auto_20250115_1509.py @@ -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'), + ), + ]