diff options
| -rw-r--r-- | archaeological_files/forms.py | 5 | ||||
| -rw-r--r-- | archaeological_files/migrations/0118_operation_name.py | 43 | ||||
| -rw-r--r-- | archaeological_files/models.py | 4 | ||||
| -rw-r--r-- | archaeological_files/templates/ishtar/sheet_file.html | 1 | ||||
| -rw-r--r-- | archaeological_operations/wizards.py | 4 | 
5 files changed, 56 insertions, 1 deletions
diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py index 82383a71d..587cb2237 100644 --- a/archaeological_files/forms.py +++ b/archaeological_files/forms.py @@ -98,6 +98,7 @@ class FileSelect(DocumentItemSelect):              label=_("Department"), choices=[]          )      name = forms.CharField(label=_("File name"), max_length=200) +    operation_name = forms.CharField(label=_("Operation name"), max_length=200)      file_type = forms.ChoiceField(label=_("File type"), choices=[])      end_date = forms.NullBooleanField(label=_("Is active?"))      development_type = forms.ChoiceField(label=_("Development type"), choices=[]) @@ -288,6 +289,8 @@ class FileFormPlanning(CustomForm, ManageOldType):      HEADERS = {}      HEADERS["town"] = FormHeader(_("Geographic localisation"))      name = forms.CharField(label=_("Planning name"), required=False, max_length=1000) +    operation_name = forms.CharField(label=_("Operation name"), required=False, max_length=1000, +                                     help_text=_("This name is used on creation for the associated operation"))      development_type = forms.ChoiceField(label=_("Development type"), choices=[], required=False)      town = widgets.Select2MultipleField( @@ -337,6 +340,8 @@ class FileFormResearchAddress(CustomForm, forms.Form):      base_models = ["town", "department"]      associated_models = {"town": Town, "department": Department}      name = forms.CharField(label=_("Project name"), required=False, max_length=100) +    operation_name = forms.CharField(label=_("Operation name"), required=False, max_length=1000, +                                     help_text=_("This name is used on creation for the associated operation"))      town = widgets.Select2MultipleField(          model=Town, label=_("Towns"), required=False, remote=True      ) diff --git a/archaeological_files/migrations/0118_operation_name.py b/archaeological_files/migrations/0118_operation_name.py new file mode 100644 index 000000000..dfbd76e99 --- /dev/null +++ b/archaeological_files/migrations/0118_operation_name.py @@ -0,0 +1,43 @@ +# Generated by Django 2.2.24 on 2024-09-27 13:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('archaeological_files', '0117_data_developmenttype_monitoring_justif'), +    ] + +    operations = [ +        migrations.AddField( +            model_name='file', +            name='operation_name', +            field=models.TextField(blank=True, default='', verbose_name='Operation name'), +        ), +        migrations.AddField( +            model_name='historicalfile', +            name='operation_name', +            field=models.TextField(blank=True, default='', verbose_name='Operation name'), +        ), +        migrations.AlterField( +            model_name='file', +            name='total_developed_surface', +            field=models.FloatField(blank=True, null=True, verbose_name='Total developed surface (m²)'), +        ), +        migrations.AlterField( +            model_name='file', +            name='total_surface', +            field=models.FloatField(blank=True, null=True, verbose_name='Total surface (m²)'), +        ), +        migrations.AlterField( +            model_name='historicalfile', +            name='total_developed_surface', +            field=models.FloatField(blank=True, null=True, verbose_name='Total developed surface (m²)'), +        ), +        migrations.AlterField( +            model_name='historicalfile', +            name='total_surface', +            field=models.FloatField(blank=True, null=True, verbose_name='Total surface (m²)'), +        ), +    ] diff --git a/archaeological_files/models.py b/archaeological_files/models.py index b6f1ee37c..c0b668514 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -532,6 +532,9 @@ class File(          "name": SearchAltName(              pgettext_lazy("key for text search", "name"), "name__iexact"          ), +        "operation_name": SearchAltName( +            pgettext_lazy("key for text search", "operation-name"), "operation_name__iexact" +        ),          "file_type": SearchAltName(              pgettext_lazy("key for text search", "type"), "file_type__label__iexact"          ), @@ -604,6 +607,7 @@ class File(          _("External ID is set automatically"), default=False      )      name = models.TextField(_("Name"), blank=True, default="") +    operation_name = models.TextField(_("Operation name"), blank=True, default="")      file_type = models.ForeignKey(FileType, verbose_name=_("File type"), on_delete=models.PROTECT)      in_charge = models.ForeignKey(          Person, diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html index b2b526453..a5e9d4013 100644 --- a/archaeological_files/templates/ishtar/sheet_file.html +++ b/archaeological_files/templates/ishtar/sheet_file.html @@ -60,6 +60,7 @@          <h3>{% trans "General"%}</h3>          <div class="row"> +            {% field_flex _("Operation name") item.operation_name %}              {% field_flex _("Creation date") item.creation_date|date:"DATE_FORMAT" %}              {% field_flex "Reception date" item.reception_date|date:"DATE_FORMAT" %}              {% field_flex _("Instruction deadline") item.instruction_deadline|date:"DATE_FORMAT" %} diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index 581652c8f..e70eea676 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -172,10 +172,12 @@ class OperationWizard(Wizard):              return initial          keys = (              (("in_charge", "pk"), "in_charge"), -            (("name",), "common_name"), +            (("operation_name",), "common_name"),              (("total_surface",), "surface"),          )          initial.update(self.__copy_fields(file, keys)) +        if not initial.get("common_name", None): +            initial["common_name"] = file.name or ""          if "town" not in initial:              initial["town"] = [idx for idx, __ in self.get_towns()]          if file.is_preventive():  | 
