diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-02-16 15:58:53 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-04-16 16:41:51 +0200 |
commit | f6c6695b19f6d75dc5fa6da0d1389f90f24835bc (patch) | |
tree | 993de482bd8e9be26a8ac295e06b501f8a2b39dc /ishtar_common | |
parent | f05d73437dd9b7703cd225f5bf84446a3c443900 (diff) | |
download | Ishtar-f6c6695b19f6d75dc5fa6da0d1389f90f24835bc.tar.bz2 Ishtar-f6c6695b19f6d75dc5fa6da0d1389f90f24835bc.zip |
✨ Biographical note sheet
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/admin.py | 13 | ||||
-rw-r--r-- | ishtar_common/models.py | 9 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/sheet_biographicalnote.html | 23 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/sheet_biographicalnote_pdf.html | 14 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/sheet_biographicalnote_window.html | 3 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/sheet_organization.html | 1 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/sheet_person.html | 1 | ||||
-rw-r--r-- | ishtar_common/urls.py | 5 | ||||
-rw-r--r-- | ishtar_common/views.py | 2 |
9 files changed, 69 insertions, 2 deletions
diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py index 527584f39..ae521729d 100644 --- a/ishtar_common/admin.py +++ b/ishtar_common/admin.py @@ -735,11 +735,24 @@ class PersonAdmin(HistorizedObjectAdmin): admin_site.register(models.Person, PersonAdmin) +MAIN_ITEM_READONLY_FIELDS = [ + "history_creator", + "history_modifier", + "search_vector", + "history_m2m", + "imports", + "imports_updated", + "timestamp_geo", + "timestamp_label", +] + + @admin.register(models.BiographicalNote, site=admin_site) class BiographicalNoteAdmin(admin.ModelAdmin): list_display = ("denomination", "last_name", "first_name") autocomplete_fields = ["person", "organization"] model = models.BiographicalNote + readonly_fields = MAIN_ITEM_READONLY_FIELDS @admin.register(models.GDPRLog, site=admin_site) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 187df4126..a5e666b13 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3231,10 +3231,11 @@ def text_format(text, text_format): return mark_safe(markdown(text)) elif text_format == "HT": return mark_safe(bleach.clean(text)) - return text_format + return text class BiographicalNote(BaseHistorizedItem, ValueGetter, MainItem): + SLUG = "biographicalnote" denomination = models.TextField(_("Denomination")) last_name = models.TextField(_("Last name"), blank=True, default="") first_name = models.TextField(_("First name"), blank=True, default="") @@ -3244,10 +3245,14 @@ class BiographicalNote(BaseHistorizedItem, ValueGetter, MainItem): biography_format = models.CharField( _("Biography format"), blank=True, default="NO", max_length=2, choices=TEXT_FORMAT ) - person = models.ForeignKey(Person, blank=True, null=True, on_delete=models.SET_NULL, verbose_name=_("Person")) + person = models.ForeignKey( + Person, blank=True, null=True, on_delete=models.SET_NULL, verbose_name=_("Person"), + related_name="biographical_notes" + ) organization = models.ForeignKey( Organization, blank=True, null=True, on_delete=models.SET_NULL, verbose_name=_("Organization"), + related_name="biographical_notes" ) class Meta: diff --git a/ishtar_common/templates/ishtar/sheet_biographicalnote.html b/ishtar_common/templates/ishtar/sheet_biographicalnote.html new file mode 100644 index 000000000..64a6b4d9c --- /dev/null +++ b/ishtar_common/templates/ishtar/sheet_biographicalnote.html @@ -0,0 +1,23 @@ +{% extends "ishtar/sheet.html" %} +{% load i18n window_field window_tables window_header %} + +{% block head_title %}<strong>{% trans "Biographical note"%}</strong> - {{item}}{% endblock %} + +{% block toolbar %} +{% window_nav item window_id 'show-person' 'person_modify' %} +{% endblock %} + +{% block content %} + +<div class="row"> + {% field_flex "Denomination" item.denomination %} + {% field_flex "Last name" item.last_name %} + {% field_flex "First name" item.first_name %} + {% field_flex "Year of birth" item.birth_year %} + {% field_flex "Year of death" item.death_year %} + {% field_flex_detail "Person" item.person %} + {% field_flex_detail "Organization" item.organization %} + {% field_flex_full "Biography" item.formatted_biography %} +</div> + +{% endblock %} diff --git a/ishtar_common/templates/ishtar/sheet_biographicalnote_pdf.html b/ishtar_common/templates/ishtar/sheet_biographicalnote_pdf.html new file mode 100644 index 000000000..714277187 --- /dev/null +++ b/ishtar_common/templates/ishtar/sheet_biographicalnote_pdf.html @@ -0,0 +1,14 @@ +{% extends "ishtar/sheet_biographicalnote.html" %} +{% block header %} +{% endblock %} +{% block main_head %} +{{ block.super }} +<div id="pdfheader"> +Ishtar – {{APP_NAME}} – {{item}} +</div> +{% endblock %} +{%block head_sheet%}{%endblock%} +{%block main_foot%} +</body> +</html> +{%endblock%} diff --git a/ishtar_common/templates/ishtar/sheet_biographicalnote_window.html b/ishtar_common/templates/ishtar/sheet_biographicalnote_window.html new file mode 100644 index 000000000..29bbf0aa8 --- /dev/null +++ b/ishtar_common/templates/ishtar/sheet_biographicalnote_window.html @@ -0,0 +1,3 @@ +{% extends "ishtar/sheet_biographicalnote.html" %} +{% block main_head %}{%endblock%} +{% block main_foot %}{%endblock%} diff --git a/ishtar_common/templates/ishtar/sheet_organization.html b/ishtar_common/templates/ishtar/sheet_organization.html index a3c923ab8..f2618bb58 100644 --- a/ishtar_common/templates/ishtar/sheet_organization.html +++ b/ishtar_common/templates/ishtar/sheet_organization.html @@ -16,6 +16,7 @@ {% include "ishtar/blocks/sheet_address_section.html" %} {% field_flex "Phone" item.phone %} {% field_flex "Mobile phone" item.mobile_phone %} + {% field_flex_detail_multiple "Biographical notes" item.biographical_notes %} </div> <h3>{%trans "Person in the organization"%}</h3> diff --git a/ishtar_common/templates/ishtar/sheet_person.html b/ishtar_common/templates/ishtar/sheet_person.html index 46639f248..53cd7d84f 100644 --- a/ishtar_common/templates/ishtar/sheet_person.html +++ b/ishtar_common/templates/ishtar/sheet_person.html @@ -17,6 +17,7 @@ {% field_flex_detail "Created by" item.history_creator.ishtaruser.person %} {% field_flex "Email" item.email %} {% field_flex "Type(s)" item.person_types_list %} + {% field_flex_detail_multiple "Biographical notes" item.biographical_notes %} {% if ADMIN %} {% field_flex "Profile(s)" item.profiles_list %} {% endif %} diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index 86d10969d..5ce9861d1 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -405,6 +405,11 @@ urlpatterns += [ name="show-person", ), url( + r"show-biographicalnote(?:/(?P<pk>.+))?/(?P<type>.+)?$", + views.show_biographical_note, + name="show-biographicalnote", + ), + url( r"department-by-state/(?P<state_id>.+)?$", views.department_by_state, name="department-by-state", diff --git a/ishtar_common/views.py b/ishtar_common/views.py index bee4d6628..5ad14695f 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -1136,6 +1136,8 @@ show_person = show_item(models.Person, "person", callback=get_person_gdpr_log) get_person = get_item(models.Person, "get_person", "person", callback=get_person_gdpr_log) +show_biographical_note = show_item(models.BiographicalNote, "biographicalnote") + get_person_for_account = get_item( models.Person, "get_person", |