From 4e7482c127cc93647975438a45dca5ed796fdaeb Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 16 Feb 2024 15:58:53 +0100 Subject: ✨ Biographical note sheet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/admin.py | 13 ++++++++++++ ishtar_common/models.py | 9 +++++++-- .../templates/ishtar/sheet_biographicalnote.html | 23 ++++++++++++++++++++++ .../ishtar/sheet_biographicalnote_pdf.html | 14 +++++++++++++ .../ishtar/sheet_biographicalnote_window.html | 3 +++ .../templates/ishtar/sheet_organization.html | 1 + ishtar_common/templates/ishtar/sheet_person.html | 1 + ishtar_common/urls.py | 5 +++++ ishtar_common/views.py | 2 ++ 9 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 ishtar_common/templates/ishtar/sheet_biographicalnote.html create mode 100644 ishtar_common/templates/ishtar/sheet_biographicalnote_pdf.html create mode 100644 ishtar_common/templates/ishtar/sheet_biographicalnote_window.html (limited to 'ishtar_common') 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 %}{% trans "Biographical note"%} - {{item}}{% endblock %} + +{% block toolbar %} +{% window_nav item window_id 'show-person' 'person_modify' %} +{% endblock %} + +{% block content %} + +
+ {% 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 %} +
+ +{% 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 }} +
+Ishtar – {{APP_NAME}} – {{item}} +
+{% endblock %} +{%block head_sheet%}{%endblock%} +{%block main_foot%} + + +{%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 %}

{%trans "Person in the organization"%}

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 @@ -404,6 +404,11 @@ urlpatterns += [ views.show_person, name="show-person", ), + url( + r"show-biographicalnote(?:/(?P.+))?/(?P.+)?$", + views.show_biographical_note, + name="show-biographicalnote", + ), url( r"department-by-state/(?P.+)?$", views.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", -- cgit v1.2.3