diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-12-04 11:43:19 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:22 +0100 |
commit | d992bb445b8ceea253fec86a45cc11a736cfa876 (patch) | |
tree | 6a626221e6949e5ae72aea334b4c7520496aaec0 | |
parent | e19f6a8d40fa81f4985179b2d1b53b208273e754 (diff) | |
download | Ishtar-d992bb445b8ceea253fec86a45cc11a736cfa876.tar.bz2 Ishtar-d992bb445b8ceea253fec86a45cc11a736cfa876.zip |
File: add edit button on sheet - fix research forms
-rw-r--r-- | archaeological_files/forms.py | 44 | ||||
-rw-r--r-- | archaeological_files/templates/ishtar/sheet_file.html | 5 | ||||
-rw-r--r-- | archaeological_files_pdl/forms.py | 3 | ||||
-rw-r--r-- | archaeological_warehouse/models.py | 5 | ||||
-rw-r--r-- | ishtar_common/models.py | 13 |
5 files changed, 44 insertions, 26 deletions
diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py index 71de4d891..6e52bcff1 100644 --- a/archaeological_files/forms.py +++ b/archaeological_files/forms.py @@ -26,12 +26,14 @@ from django import forms from django.conf import settings from django.core import validators from django.forms.formsets import formset_factory -from ishtar_common.utils import ugettext_lazy as _ +from django.utils.functional import lazy from django.utils.safestring import mark_safe +from ishtar_common.utils import ugettext_lazy as _ from ishtar_common.models import Person, Organization, \ valid_id, valid_ids, person_type_pks_lazy, \ - person_type_pk_lazy, organization_type_pks_lazy + person_type_pk_lazy, organization_type_pks_lazy, \ + get_sra_agent_head_scientist_label from ishtar_common.models_common import Department from archaeological_operations.models import ActType, AdministrativeAct, \ OperationType @@ -50,11 +52,11 @@ from bootstrap_datepicker.widgets import DatePicker class FileSelect(DocumentItemSelect): _model = models.File - form_admin_name = _(u"File - 001 - Search") + form_admin_name = _("File - 001 - Search") form_slug = "file-001-search" search_vector = forms.CharField( - label=_(u"Full text search"), widget=widgets.SearchWidget( + label=_("Full text search"), widget=widgets.SearchWidget( 'archaeological-files', 'file' )) year = forms.IntegerField(label=_("Year")) @@ -293,13 +295,13 @@ ParcelFormset.form_slug = "file-020-parcels" class FileFormPreventive(ManageOldType, forms.Form): - form_label = _(u"Preventive informations") + form_label = _("Preventive informations") associated_models = {'general_contractor': Person, 'saisine_type': models.SaisineType, 'permit_type': models.PermitType, 'responsible_town_planning_service': Person} general_contractor = forms.IntegerField( - label=_(u"General contractor"), + label=_("General contractor"), widget=widgets.JQueryAutoComplete( reverse_lazy( 'autocomplete-person', @@ -311,7 +313,7 @@ class FileFormPreventive(ManageOldType, forms.Form): validators=[valid_id(Person)]) responsible_town_planning_service = forms.IntegerField( required=False, - label=_(u"Responsible for planning service"), + label=_("Responsible for planning service"), widget=widgets.JQueryAutoComplete( reverse_lazy( 'autocomplete-person', @@ -354,6 +356,7 @@ class FileFormResearch(CustomForm, ManageOldType, forms.Form): form_label = _("Research archaeology") form_admin_name = _("Archaeological file - 045 - Research - General") form_slug = "file-045-research-general" + extra_form_modals = ["person", "organization"] base_model = 'department' associated_models = {'scientist': Person, 'requested_operation_type': OperationType, @@ -365,19 +368,28 @@ class FileFormResearch(CustomForm, ManageOldType, forms.Form): widget=widgets.JQueryAutoComplete( reverse_lazy( 'autocomplete-person', - args=[person_type_pks_lazy(['head_scientist', 'sra_agent'])]), - limit={'person_types': [person_type_pk_lazy('head_scientist'), - person_type_pk_lazy('sra_agent')]}, - associated_model=Person, new=True), - label=_(u"Scientist in charge")) + args=[person_type_pks_lazy(['head_scientist', 'sra_agent'])] + ), + limit={'person_types': [person_type_pk_lazy('head_scientist'), + person_type_pk_lazy('sra_agent')]}, + tips=lazy(get_sra_agent_head_scientist_label), + associated_model=Person, new=True, + detail=True, + modify=True + ), + label=_("Scientist in charge")) requested_operation_type = forms.ChoiceField( - label=_(u"Requested operation type"), choices=[]) + label=_("Requested operation type"), choices=[]) organization = forms.IntegerField( - label=_(u"Lead organization"), + label=_("Lead organization"), widget=widgets.JQueryAutoComplete( reverse_lazy('autocomplete-organization'), - associated_model=Organization, new=True), - validators=[valid_id(Organization)], required=False) + associated_model=Organization, new=True, + detail=True, + modify=True + ), + validators=[valid_id(Organization)], required=False, + ) if settings.COUNTRY == 'fr': cira_advised = forms.NullBooleanField(label=u"Passage en CIRA", required=False) diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html index 955dbc32a..f5a3ac6d3 100644 --- a/archaeological_files/templates/ishtar/sheet_file.html +++ b/archaeological_files/templates/ishtar/sheet_file.html @@ -4,12 +4,7 @@ {% block head_title %}<strong>{% trans "Archaeological file" %}</strong> - {{item.full_internal_ref|default:''}}{% endblock %} {% block toolbar %} -{% if can_add_operation %} -{% window_file_nav item window_id previous next %} -{% else %} {% window_nav item window_id 'show-file' 'file_modify' 'show-historized-file' 'revert-file' previous next 1 %} -{% endif %} - {% endblock %} {% block content %} diff --git a/archaeological_files_pdl/forms.py b/archaeological_files_pdl/forms.py index fc10d5ddc..d8cfd8fb8 100644 --- a/archaeological_files_pdl/forms.py +++ b/archaeological_files_pdl/forms.py @@ -269,7 +269,8 @@ class FileFormGeneralContractor(CustomForm, ManageOldType): ] }, tips=lazy(get_orga_general_contractor_label), - associated_model=models.Organization, new=True, + associated_model=models.Organization, + new=True, detail=True, modify=True ), diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 71d9afd2f..8d06d0e2b 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -1360,10 +1360,7 @@ class Container(DocumentItem, Merge, LightHistorizedItem, self.skip_history_when_saving = True q = Container.objects.filter(responsible=self.responsible).exclude( pk=self.pk).order_by('-index') - if q.count(): - self.index = q.all()[0].index + 1 - else: - self.index = 1 + self.index = q.all()[0].index + 1 if q.count() else 1 updated = True self.skip_history_when_saving = True diff --git a/ishtar_common/models.py b/ishtar_common/models.py index b728b5387..c7406acfa 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1790,6 +1790,19 @@ person_type_pk_lazy = lazy(PersonType.get_or_create_pk, str) person_type_pks_lazy = lazy(PersonType.get_or_create_pks, str) +def get_sra_agent_head_scientist_label(): + if apps.ready: + lbl = get_general_type_label(PersonType, "head_scientist") + if lbl: + lbl += str(_("/")) + lbl2 = get_general_type_label(PersonType, "sra_agent") + if lbl2: + lbl += lbl2 + if lbl: + return lbl + return _("Error: sra_agent and head_scientist types are missing") + + def get_sra_agent_label(): if apps.ready: lbl = get_general_type_label(PersonType, "sra_agent") |