From c97b77fe1b0e5b3de93e51a3a945fc46ae0c0c62 Mon Sep 17 00:00:00 2001 From: Andy Byers Date: Mon, 15 Aug 2022 15:43:39 +0100 Subject: [PATCH] #2820 add suffix to profile and snapshot it --- src/core/migrations/0074_account_suffix.py | 20 +++++++++++++++++++ src/core/models.py | 7 +++++++ .../admin/core/manager/users/edit.html | 8 ++++---- .../admin/elements/accounts/user_form.html | 7 +++++-- .../elements/accounts/user_form.html | 5 ++++- .../elements/accounts/user_form.html | 7 +++++-- .../elements/accounts/user_form.html | 5 ++++- 7 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 src/core/migrations/0074_account_suffix.py diff --git a/src/core/migrations/0074_account_suffix.py b/src/core/migrations/0074_account_suffix.py new file mode 100644 index 0000000000..7c7f56653c --- /dev/null +++ b/src/core/migrations/0074_account_suffix.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2022-08-15 11:42 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0073_auto_20220630_1608'), + ] + + operations = [ + migrations.AddField( + model_name='account', + name='suffix', + field=models.CharField(blank=True, help_text='Name suffix eg. jr', max_length=300, null=True), + ), + ] diff --git a/src/core/models.py b/src/core/models.py index 1cf8d28802..1fe66eb433 100755 --- a/src/core/models.py +++ b/src/core/models.py @@ -208,6 +208,12 @@ class Account(AbstractBaseUser, PermissionsMixin): activation_code = models.CharField(max_length=100, null=True, blank=True) salutation = models.CharField(max_length=10, choices=SALUTATION_CHOICES, null=True, blank=True, verbose_name=_('Salutation')) + suffix = models.CharField( + max_length=300, + null=True, + blank=True, + help_text=_('Name suffix eg. jr'), + ) biography = models.TextField(null=True, blank=True, verbose_name=_('Biography')) orcid = models.CharField(max_length=40, null=True, blank=True, verbose_name=_('ORCiD')) institution = models.CharField(max_length=1000, null=True, blank=True, verbose_name=_('Institution')) @@ -427,6 +433,7 @@ def snapshot_self(self, article, force_update=True): 'institution': self.institution, 'department': self.department, 'display_email': True if self == article.correspondence_author else False, + 'name_suffix': self.suffix, } frozen_author = self.frozen_author(article) diff --git a/src/templates/admin/core/manager/users/edit.html b/src/templates/admin/core/manager/users/edit.html index 3762d46512..cbad83dab5 100644 --- a/src/templates/admin/core/manager/users/edit.html +++ b/src/templates/admin/core/manager/users/edit.html @@ -19,7 +19,7 @@ {% block title-sub %}{% if active == 'add' %}Add New User{% else %}Edit User{% endif %}{% endblock %} {% block body %} -
+
@@ -58,14 +58,14 @@

{% if active == 'add' %}Add User{% else %}Edit {{ registration_form.email.va

{% endif %} - {% include "elements/forms/errors.html" with form=form %} - {% include "elements/accounts/user_form.html" with form=form %} + {% include "admin/elements/forms/errors.html" with form=form %} + {% include "admin/elements/accounts/user_form.html" with form=form %} -

+

diff --git a/src/templates/admin/elements/accounts/user_form.html b/src/templates/admin/elements/accounts/user_form.html index 184373d819..a6155ebbf1 100644 --- a/src/templates/admin/elements/accounts/user_form.html +++ b/src/templates/admin/elements/accounts/user_form.html @@ -6,18 +6,21 @@
Core Data
{{ form.email|foundation }}
-
+
{{ form.salutation|foundation }}
{{ form.first_name|foundation }}
-
+
{{ form.middle_name|foundation }}
{{ form.last_name|foundation }}
+
+ {{ form.suffix|foundation }} +
diff --git a/src/themes/OLH/templates/elements/accounts/user_form.html b/src/themes/OLH/templates/elements/accounts/user_form.html index 0e46e3e997..c13f249ef2 100644 --- a/src/themes/OLH/templates/elements/accounts/user_form.html +++ b/src/themes/OLH/templates/elements/accounts/user_form.html @@ -7,7 +7,7 @@
{% trans 'Core Data' %}
{{ form.email|foundation }}
-
+
{{ form.salutation|foundation }}
@@ -19,6 +19,9 @@
{% trans 'Core Data' %}
{{ form.last_name|foundation }}
+
+ {{ form.suffix|foundation }} +
diff --git a/src/themes/clean/templates/elements/accounts/user_form.html b/src/themes/clean/templates/elements/accounts/user_form.html index 9d2d0f1513..eae7b9bd68 100644 --- a/src/themes/clean/templates/elements/accounts/user_form.html +++ b/src/themes/clean/templates/elements/accounts/user_form.html @@ -4,7 +4,7 @@
{% trans 'Core Data' %}
-
+
{% bootstrap_field form.salutation %}
@@ -16,6 +16,9 @@
{% trans 'Core Data' %}
{% bootstrap_field form.last_name %}
+
+ {% bootstrap_field form.suffix %} +
@@ -89,7 +92,7 @@
{% trans 'Profile Image' %}
{% trans 'Options' %}
- {% bootstrap_field form.enable_digest %} + {% bootstrap_field form.enable_public_profile %}
diff --git a/src/themes/material/templates/elements/accounts/user_form.html b/src/themes/material/templates/elements/accounts/user_form.html index c14af6feb7..fee410b0e0 100644 --- a/src/themes/material/templates/elements/accounts/user_form.html +++ b/src/themes/material/templates/elements/accounts/user_form.html @@ -5,7 +5,7 @@
{% trans "Core Data" %}
-
+
{% bootstrap_field form.salutation %}
@@ -17,6 +17,9 @@
{% trans "Core Data" %}
{% bootstrap_field form.last_name %}
+
+ {% bootstrap_field form.suffix %} +