diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-11-15 11:51:49 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-02-19 14:45:55 +0100 |
commit | f3764eea1ac4a6cdb12095322a00fd93d377c2c5 (patch) | |
tree | 878cc3ba5ce98d1d7ed28e264d54f4ca4efbdf0d | |
parent | a2de2eb42009de3b8bf56f2af2a6071a4a98fd8f (diff) | |
download | Ishtar-f3764eea1ac4a6cdb12095322a00fd93d377c2c5.tar.bz2 Ishtar-f3764eea1ac4a6cdb12095322a00fd93d377c2c5.zip |
✨ adapt sheet to manage sheet filters
25 files changed, 115 insertions, 26 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index dbd7bc463..8046cef7e 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -836,6 +836,10 @@ class ContextRecord( ] UPPER_GEO = ["operation", "archaeological_site"] UPPER_PERMISSIONS = [(Operation, "operation_id")] + SHEET_EMPTY_KEYS = [ + "m2m_listing", "interpretation", "activity", "taq", "taq_estimated", "tpq", + "tpq_estimated" + ] history = HistoricalRecords(bases=[HistoryModel]) objects = UUIDModelManager() diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html index ff2877176..5c2f46664 100644 --- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html +++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html @@ -139,9 +139,10 @@ </div> </div> <hr class="clearfix"> + {% if item.excavation_technics or item.documentations or item.opening_date or item.closing_date or item.structures or item.textures or item.inclusions or item.colors or item.details_on_color or item.filling or item.description %} <h3>{% trans "Description" %}</h3> <div class="row"> - {% field_flex_multiple_obj "Excavation techniques" item 'excavation_technics' %} + {% field_flex_multiple_obj _("Excavation technics") item 'excavation_technics' %} {% field_flex_multiple_obj "Documentation" item 'documentations' %} {% field_flex "Opening date" item.opening_date|date:"DATE_FORMAT" %} {% field_flex "Closing date" item.closing_date|date:"DATE_FORMAT" %} @@ -153,6 +154,8 @@ {% field_flex_full "Filling" item.filling "<pre>" "</pre>" %} {% field_flex_full "Description" item.description "<pre>" "</pre>" %} </div> + {% endif %} + {% if item.surface or item.length or item.excavated_length or item.width or item.excavated_width or item.diameter or item.depth or item.thickness or item.depth_of_appearance %} <h3>{% trans "Dimensions" %}</h3> <div class="row"> {% if item.surface %} @@ -172,6 +175,7 @@ {% field_flex "Thickness (m)" item.thickness %} {% field_flex "Depth of appearance (m)" item.depth_of_appearance %} </div> + {% endif %} {% if item.main_geodata or item.town or item.location %} <h3>{% trans "Geographic localisation" %}</h3> @@ -186,10 +190,14 @@ </div> {% endif %} + {% if not is_external %} + {% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet" %}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> + {% endif %} + {% endif %} </div> {% if display_interpretation %} <div class="tab-pane fade" id="{{window_id}}-interpretation" diff --git a/archaeological_files/models.py b/archaeological_files/models.py index bea129ea8..3b272a333 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -620,6 +620,7 @@ class File( HISTORICAL_M2M = ["towns", "departments"] SERIALIZE_PROPERTIES = ["external_id"] + SHEET_EMPTY_KEYS = ["has_jobs", "has_ground_jobs"] QA_LINK = QuickAction( url="file-qa-link", icon_class="fa fa-link", @@ -937,6 +938,18 @@ class File( return self.update_has_admin_act(cache_key) @property + def has_equipment_costs(self): + return self.equipment_costs.exists() + + @property + def has_ground_jobs(self): + return self.ground_jobs.exists() + + @property + def has_jobs(self): + return self.jobs.exists() + + @property def get_locality(self): return " - ".join( [getattr(self, k) for k in ("locality", "address") if getattr(self, k)] diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html index 9a347c978..28f4892d1 100644 --- a/archaeological_files/templates/ishtar/sheet_file.html +++ b/archaeological_files/templates/ishtar/sheet_file.html @@ -11,7 +11,7 @@ {% with can_view_documents=permission_view_own_document|or_:permission_view_document %} {% with has_documents=item.documents.count %} {% with display_documents=can_view_documents|and_:has_documents %} -{% with has_costs=item.equipment_costs.count|or_:item.ground_jobs.count|or_:item.jobs.count %} +{% with has_costs=item.has_equipment_costs|or_:item.has_ground_jobs|or_:item.has_jobs %} {% if output != "ODT" and output != "PDF"%} <ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist"> @@ -65,12 +65,14 @@ {% field_flex "Reception date" item.reception_date|date:"DATE_FORMAT" %} {% field_flex _("Instruction deadline") item.instruction_deadline|date:"DATE_FORMAT" %} {% field_flex_detail _("File managed by") item.in_charge %} + {% if item.is_active != None %} <dl class="col-12 col-md-6 col-lg-3 flex-wrap"> <dt>{%trans "State of the file"%}</dt> <dd> {% if item.is_active %}{%trans "Active file"%}{% else %}{%trans "Closed file"%}{% endif %} </dd> </dl> + {% endif %} {% if item.closing %} <dl class="col-12 col-md-6 col-lg-3 flex-wrap"> <dt>{%trans "Closing date"%}</dt> @@ -86,6 +88,7 @@ {% include "ishtar/blocks/sheet_json.html" %} + {% if item.geodata_list or item.towns or item.departments or item.address or item.locality or item.associated_file.address_complement or item.associated_file.postal_code or item.total_surface %} <h3>{% trans "Geographic localisation" %}</h3> <div class="row"> {% field_flex_detail_multiple_full "Towns" item.towns %} @@ -103,9 +106,9 @@ </div> {% endif %} </div> + {% endif %} {% if item.is_preventive %} - <h3>{% trans "Preventive archaeological file"%}</h3> <div class="row"> @@ -143,7 +146,7 @@ </div> {% else %} - + {% if item.scientist or item.requested_operation_type or item.organization or item.cira_advised or item.mh_register or item.mh_listing or item.classified_area or item.protected_area or item.research_comment %} <h3>{% trans "Research archaeology"%}</h3> <div class="row"> {% field_flex_detail "Head scientist" item.scientist %} @@ -174,15 +177,18 @@ </div> {% endif %} + {% endif %} {% if not next %} - + {% if item.has_parcels %} {% trans "Associated parcels" as parcels_label %} {% include "ishtar/blocks/window_tables/parcels.html" %} - + {% endif %} + {% if item.administrative_act.exists %} {% trans "Administrative acts" as administrativeacts_label %} {% table_administrativact administrativeacts_label item.administrative_act.all %} - + {% endif %} + {% if item.operations.exists %} <h3>{%trans "Associated operations"%}</h3> <table class="table table-striped"> <tr> @@ -209,7 +215,9 @@ <tr><td colspan="8" class='no_items'>{% trans "No operation associated to this archaeological file" %}</td></tr> {% endfor %} </table> + {% endif %} + {% if item.operations_acts %} <h3>{%trans "Admninistrative acts linked to associated operations"%}</h3> <table class="table table-striped"> <tr> @@ -231,6 +239,7 @@ </table> {% endif %} + {% endif %} {% trans "Document for this archaeological file" as fle_docs %} {% if permission_view_own_document or permission_view_document %} @@ -240,11 +249,13 @@ {% endif %} {% if not is_external %} + {% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} + {% endif %} </div>{% if has_costs %} <div class="tab-pane fade show active" id="{{window_id}}-costs" diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index fa3bdb677..93a3286bc 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -2016,6 +2016,8 @@ class Find( (("archaeological_warehouse", "Warehouse"), "container_ref__responsibility_id"), ] SHEET_ALTERNATIVES = [("museum", "museum_find")] + SHEET_EMPTY_KEYS = ["container_ref", "upstream_treatment", "downstream_treatment", + "documents_count", "m2m_listing"] objects = UUIDModelManager() # fields diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 3adb73624..935a14f2f 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -1206,6 +1206,7 @@ class TreatmentFile( } ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES) ALT_NAMES.update(DocumentItem.ALT_NAMES) + SHEET_EMPTY_KEYS = ["name"] # fields year = models.IntegerField(_("Year"), default=get_current_year) diff --git a/archaeological_finds/templates/ishtar/sheet_basefind.html b/archaeological_finds/templates/ishtar/sheet_basefind.html index 996e8a8a6..23cccfc9d 100644 --- a/archaeological_finds/templates/ishtar/sheet_basefind.html +++ b/archaeological_finds/templates/ishtar/sheet_basefind.html @@ -68,10 +68,12 @@ {% field_flex_full "Point of topographic reference" base_find.topographic_localisation %} </div> {% if not is_external %} + {% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class='row'> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} + {% endif %} </div> diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index a3ecbdc67..787051efb 100644 --- a/archaeological_finds/templates/ishtar/sheet_find.html +++ b/archaeological_finds/templates/ishtar/sheet_find.html @@ -259,6 +259,8 @@ {% endif %} {% endwith %} + {% if not is_external %} + {% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet" %}</h3> <div class='row'> {% trans "Checked" as checked_label %} @@ -268,6 +270,8 @@ {% endwith %} {% include "ishtar/blocks/sheet_creation_section.html" %} </div> + {% endif %} + {% endif %} </div> <div class="tab-pane fade" id="{{window_id}}-warehouse" role="tabpanel" aria-labelledby="{{window_id}}-warehouse-tab"> diff --git a/archaeological_finds/templates/ishtar/sheet_findbasket.html b/archaeological_finds/templates/ishtar/sheet_findbasket.html index 4b3d9321e..c846c0494 100644 --- a/archaeological_finds/templates/ishtar/sheet_findbasket.html +++ b/archaeological_finds/templates/ishtar/sheet_findbasket.html @@ -21,9 +21,10 @@ {% field_flex_detail_multiple_full treatment_label item.treatment_files %} </div> +{% if item.items.exists %} <h3>{% trans "Content" %}</h3> {% dynamic_table_document finds 'finds' 'basket_id' item.pk 'TABLE_COLS' output %} - +{% endif %} {% endblock %} diff --git a/archaeological_finds/templates/ishtar/sheet_museum_find.html b/archaeological_finds/templates/ishtar/sheet_museum_find.html index 73e76d8bd..3c00a5d38 100644 --- a/archaeological_finds/templates/ishtar/sheet_museum_find.html +++ b/archaeological_finds/templates/ishtar/sheet_museum_find.html @@ -238,6 +238,8 @@ {% endif %} {% endwith %} + {% if not is_external %} + {% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet" %}</h3> <div class='row'> {% trans "Checked" as checked_label %} @@ -247,6 +249,8 @@ {% endwith %} {% include "ishtar/blocks/sheet_creation_section.html" %} </div> + {% endif %} + {% endif %} {% if has_image %} </div> {% endif %} diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html index ea37897b6..0a23e551a 100644 --- a/archaeological_finds/templates/ishtar/sheet_treatment.html +++ b/archaeological_finds/templates/ishtar/sheet_treatment.html @@ -1,7 +1,7 @@ {% extends "ishtar/sheet.html" %} {% load i18n l10n window_field from_dict link_to_window window_tables window_ope_tables window_header humanize %} -{% block head_title %}<strong>{% trans "Treatment" %}</strong> - {{ item|default:"" }}{% endblock %} +{% block head_title %}<strong>{% trans "Treatment" %}</strong> - {{ item.cached_label|default:"" }}{% endblock %} {% block toolbar %} {% window_nav item window_id 'show-treatment' 'treatment_modify' 'show-historized-treatment' 'revert-treatment' previous next 1 %} @@ -99,11 +99,13 @@ </div> {% if not is_external %} + {% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} + {% endif %} {% if has_image %}</div>{% endif %} </div> diff --git a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html index 952171aa1..6cca72570 100644 --- a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html +++ b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html @@ -89,11 +89,13 @@ {% endif %} {% if not is_external %} +{% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} +{% endif %} {% endwith %}{% endwith %}{% endwith %} {% endblock %} diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 9d0f8142b..84bd8ab2e 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -1555,6 +1555,7 @@ class Operation( "archaeological_sites", ] SERIALIZE_STRING = ["scientist", "in_charge", "cira_rapporteur"] + SHEET_EMPTY_KEYS = ["code_patriarche", "common_name", "short_label"] # fields definition uuid = models.UUIDField(default=uuid.uuid4) @@ -3085,6 +3086,7 @@ class AdministrativeAct(DocumentItem, BaseHistorizedItem, OwnPerms, ValueGetter, (("archaeological_finds", "treatment"), "treatment_id"), ] + SHEET_EMPTY_KEYS = ["act_type", "full_ref"] # fields act_type = models.ForeignKey( diff --git a/archaeological_operations/templates/ishtar/sheet_administrativeact.html b/archaeological_operations/templates/ishtar/sheet_administrativeact.html index 1044a3dad..f344a1fb6 100644 --- a/archaeological_operations/templates/ishtar/sheet_administrativeact.html +++ b/archaeological_operations/templates/ishtar/sheet_administrativeact.html @@ -85,10 +85,12 @@ {% endif %} {% if not is_external %} +{% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} +{% endif %} {% endblock %} diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html index be490ba28..8613d2da6 100644 --- a/archaeological_operations/templates/ishtar/sheet_operation.html +++ b/archaeological_operations/templates/ishtar/sheet_operation.html @@ -147,6 +147,7 @@ </div> <div class="row p-0 m-0"> {% if item.year %}<span class="col-4"><strong>{% trans "Year" %}</strong></span><span class="col-8">{{ item.year|unlocalize }}</span>{% endif %} + {% if next or item.cached_towns_label %} <span class="col-4"><strong>{% trans "Towns" %}</strong></span><span class="col-8"> {% if next %} {{ item|m2m_listing:'towns'|join:" ; "|default:'' }} @@ -154,6 +155,7 @@ {{ item.cached_towns_label }} {% endif %} </span> + {% endif %} {% if item.common_name %}<span class="col-4"><strong>{% trans "Name" %}</strong></span><span class="col-8">{{ item.common_name }}</span>{% endif %} {% if item.address %}<span class="col-4"><strong>{% trans "Address / Locality" %}</strong></span><span class="col-8">{{ item.address }}</span>{% endif %} </div> @@ -174,6 +176,7 @@ {% field_flex_2 date_label dates %} {% endwith %}{% endwith %}{% endwith %} {% endif %}{% endif %} + {% if item.is_active != None %} <dl class="col-12 col-md-6 col-lg-3 flex-wrap"> <dt> {% trans "State" %} @@ -187,7 +190,7 @@ {% trans "Closed operation" %} {% endif %} </dd> - </dl> + </dl>{% endif %} {% field_flex_2 "Code DRASSM" item.drassm_code %} {% field_flex_2 "Old code" item.old_code %} @@ -297,7 +300,7 @@ </div> {% endif %} - {% if not item.code_patriarche %} + {% if item.code_patriarche == "" %} <div class="alert alert-warning" role="alert"> <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> {% trans "Patriarche OA code not yet recorded!"%} @@ -328,7 +331,7 @@ {% field_flex_detail "Writer of the minutes" item.minutes_writer %} </div> {% endif %} - + {% if item.geodata_list or item.towns or item.address or item.associated_file.address or item.associated_file.address_complement or item.associated_file.postal_code %} <h3>{% trans "Geographic localisation" %}</h3> <div class="row"> @@ -339,7 +342,7 @@ <div class="row"> {% if next %} {% field_flex "Towns" item|m2m_listing:'towns'|join:" ; " %} - {% else %} + {% elif item.towns %} {% field_flex_detail_multiple_full "Towns" item.towns %} {% endif %} {% field_flex "Address" item.address %} @@ -349,12 +352,15 @@ {% field_flex "Postal code" item.associated_file.postal_code %} {% endif %} </div> + {% endif %} {% if not is_external %} + {% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} + {% endif %} </div> @@ -649,4 +655,4 @@ $(document).ready( function () { {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} -{% endblock %}
\ No newline at end of file +{% endblock %} diff --git a/archaeological_operations/templates/ishtar/sheet_site.html b/archaeological_operations/templates/ishtar/sheet_site.html index f87888655..c3154fdf5 100644 --- a/archaeological_operations/templates/ishtar/sheet_site.html +++ b/archaeological_operations/templates/ishtar/sheet_site.html @@ -118,11 +118,13 @@ {% endif %} {% if not is_external %} +{% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} +{% endif %} {% endwith %} {% endwith %} {% endwith %} {% endblock %} diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index d39e90e97..e9f012ff7 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -1583,9 +1583,9 @@ class Container( @property def associated_filename(self): filename = datetime.date.today().strftime("%Y-%m-%d") - filename += "-" + self.reference - filename += "-" + self.location.name - filename += "-" + str(self.index) + filename += "-" + (self.reference or "") + filename += "-" + (self.location.name or "") + filename += "-" + str((self.index or "")) if self.cached_division is None: self.skip_history_when_saving = True self.save() diff --git a/archaeological_warehouse/templates/ishtar/sheet_container.html b/archaeological_warehouse/templates/ishtar/sheet_container.html index a8e2ab13e..c34e5de7c 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_container.html +++ b/archaeological_warehouse/templates/ishtar/sheet_container.html @@ -2,7 +2,7 @@ {% load i18n l10n ishtar_helpers window_header window_field window_tables link_to_window %} {% block head_title %}<strong>{% trans "Container" %}</strong> - -{{ item.reference|default:"" }} ({{ item.container_type|default:"" }}) - {{item.location}} +{{ item.reference|default:"" }}{% if item.container_type %} ({{ item.container_type|default:"" }}){% endif %}{% if item.location %} - {{item.location}}{% endif %} {% endblock %} {% block toolbar %} @@ -173,11 +173,13 @@ {% endif %} {% if not is_external %} + {% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} + {% endif %} </div> <div class="tab-pane fade" id="{{window_id}}-content" diff --git a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html index 76a419e78..377f3a5d3 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html +++ b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html @@ -127,11 +127,13 @@ {% endif %} {% if not is_external %} + {% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} + {% endif %} </div> <div class="tab-pane fade" id="{{window_id}}-content" diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index e2fa9988c..ed7cae234 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -881,7 +881,7 @@ class SheetFilter(BaseSheetFilter): _("Exclude or include"), default="E", max_length=1, - choices=(("E", _("exclude")), ("I", _("Include"))) + choices=(("E", _("exclude")), ("I", _("include"))) ) class Meta: diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geographic.html b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html index ae9d2bdf5..d5f8a4d84 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_geographic.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html @@ -36,6 +36,10 @@ {% endautoescape %} </td>{% endif %} </tr> +{% empty %} + <tr> + <td colspan="10">{% trans "No geo items" %}</td> + </tr> {% endfor %} </table> {% if not IS_HISTORY and permission_change_geo and output != "ODT" and output != "PDF" %} @@ -43,4 +47,4 @@ <a class="btn btn-success" href="{% url 'create-pre-geo' item.app_label item.model_name item.pk %}{% if search_url %}?back_url={{search_url}}%3Fopen_item={{geo_item.pk|unlocalize}}{% endif %}"><i class="fa fa-plus"></i> {% trans "geo item" %}</a> </div> {% endif %} -{% endwith %}
\ No newline at end of file +{% endwith %} diff --git a/ishtar_common/templates/ishtar/sheet_organization.html b/ishtar_common/templates/ishtar/sheet_organization.html index b6d18469d..ad629b21b 100644 --- a/ishtar_common/templates/ishtar/sheet_organization.html +++ b/ishtar_common/templates/ishtar/sheet_organization.html @@ -19,6 +19,7 @@ {% field_flex_detail_multiple "Biographical notes" item.biographical_notes %} </div> +{% if item.members.count %} <h3>{%trans "Person in the organization"%}</h3> <table class='table table-striped'> @@ -39,6 +40,7 @@ <tr><td colspan="8" class='no_items'>{% trans "No person in this organization" %}</td></tr> {% endfor %} </table> +{% endif %} {% trans "Associated operations as operator" as ao %} {% if item.operator.count %} @@ -80,10 +82,12 @@ {% endif %} {% if not is_external %} +{% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} +{% endif %} {% endblock %} diff --git a/ishtar_common/templates/ishtar/sheet_person.html b/ishtar_common/templates/ishtar/sheet_person.html index c34997d30..e0ec0d887 100644 --- a/ishtar_common/templates/ishtar/sheet_person.html +++ b/ishtar_common/templates/ishtar/sheet_person.html @@ -1,7 +1,7 @@ {% extends "ishtar/sheet.html" %} {% load i18n window_field window_tables window_header %} -{% block head_title %}<strong>{% trans "Person"%}</strong> - {{item}}{% endblock %} +{% block head_title %}<strong>{% trans "Person"%}</strong> - {{item.raw_name}}{% endblock %} {% block toolbar %} {% window_nav item window_id 'show-person' 'person_modify' %} @@ -173,11 +173,13 @@ {% endif %} {% if not is_external %} +{% if item.history_creator or item.last_edition_date or item.created %} <h3>{% trans "Sheet"%}</h3> <div class="row"> {% include "ishtar/blocks/sheet_creation_section.html" %} </div> {% endif %} +{% endif %} {% endblock %} diff --git a/ishtar_common/templatetags/window_field.py b/ishtar_common/templatetags/window_field.py index 359330eb7..576a7d3cc 100644 --- a/ishtar_common/templatetags/window_field.py +++ b/ishtar_common/templatetags/window_field.py @@ -230,4 +230,6 @@ def m2m_listing(item, key): if key in item: return item[key] return [] - return item.m2m_listing(key) + if callable(item.m2m_listing): + return item.m2m_listing(key) + return [] diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 9570687bf..639af1e88 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -386,11 +386,13 @@ def filter_sheet(ishtar_user, item): if exclude is None: return item base_keys = [ - "id", "pk", "locked", "is_locked", "SLUG", "APP", "MODEL", - "HAS_QR_CODE", "get_absolute_url", "get_extra_actions", - "get_extra_templates", "can_edit", "can_delete", "DELETE_URL" + "SLUG", "APP", "MODEL", "DELETE_URL" "HAS_QR_CODE", + "id", "pk", "app_label", "model_name", "locked", "is_locked", + "get_absolute_url", "get_extra_actions", "get_extra_templates", + "can_edit", "can_delete" ] base_keys += getattr(item, "SHEET_BASE_KEYS", []) + empty_keys = getattr(item, "SHEET_EMPTY_KEYS", []) if exclude: # cannot exclude base keys len_keys = len(keys) @@ -401,9 +403,14 @@ def filter_sheet(ishtar_user, item): keys += base_keys if exclude: for key in keys: - setattr(item, key, None) + try: + setattr(item, key, None) + except TypeError: + pass return item new_item = type("BaseObject", (object,), {}) + for empty_key in empty_keys: + setattr(new_item, empty_key, None) for key in keys: setattr(new_item, key, getattr(item, key, None)) return new_item |