summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_operations/forms.py27
-rw-r--r--archaeological_operations/migrations/0068_auto_20190918_1508.py39
-rw-r--r--archaeological_operations/migrations/0069_auto_20190918_1520.py47
-rw-r--r--archaeological_operations/models.py21
-rw-r--r--archaeological_operations/templates/ishtar/sheet_operation.html6
5 files changed, 122 insertions, 18 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index d86eb2085..a03513861 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -1015,9 +1015,15 @@ OperationFormModifGeneral.associated_models['associated_file'] = File
class CourtOrderedSeizureForm(CustomForm, IshtarForm):
- form_label = _(u"Court-ordered seizure")
- form_admin_name = _(u"Operation - 015 - Court-ordered seizure")
+ form_label = _("Court-ordered seizure")
+ form_admin_name = _("Operation - 015 - Court-ordered seizure")
form_slug = "operation-015-court-ordered-seizure"
+ extra_form_modals = ["person", "organization"]
+ associated_models = {
+ 'protagonist': Person,
+ 'applicant_authority': Organization,
+ 'minutes_writer': Person,
+ }
seizure_name = forms.CharField(
label=_(u"Seizure name"), required=False,
@@ -1025,13 +1031,22 @@ class CourtOrderedSeizureForm(CustomForm, IshtarForm):
official_report_number = forms.CharField(
label=_(u"Official report number"), required=False,
)
- name_of_the_protagonist = forms.CharField(
- label=_(u"Name of the protagonist"), required=False,
+ protagonist = forms.IntegerField(
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-person-permissive'),
+ associated_model=Person, new=True),
+ label=_(u"Protagonist"), required=False,
)
- applicant_authority = forms.CharField(
+ applicant_authority = forms.IntegerField(
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-organization'),
+ associated_model=Organization, new=True),
label=_("Applicant authority"), required=False,
)
- minutes_writer = forms.CharField(
+ minutes_writer = forms.IntegerField(
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-person-permissive'),
+ associated_model=Person, new=True),
label=_("Writer of the minutes"), required=False,
)
diff --git a/archaeological_operations/migrations/0068_auto_20190918_1508.py b/archaeological_operations/migrations/0068_auto_20190918_1508.py
new file mode 100644
index 000000000..fab9d26bf
--- /dev/null
+++ b/archaeological_operations/migrations/0068_auto_20190918_1508.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.18 on 2019-09-18 15:08
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_operations', '0067_auto_20190915_1856'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='historicaloperation',
+ name='applicant_authority',
+ ),
+ migrations.RemoveField(
+ model_name='historicaloperation',
+ name='minutes_writer',
+ ),
+ migrations.RemoveField(
+ model_name='historicaloperation',
+ name='name_of_the_protagonist',
+ ),
+ migrations.RemoveField(
+ model_name='operation',
+ name='applicant_authority',
+ ),
+ migrations.RemoveField(
+ model_name='operation',
+ name='minutes_writer',
+ ),
+ migrations.RemoveField(
+ model_name='operation',
+ name='name_of_the_protagonist',
+ ),
+ ]
diff --git a/archaeological_operations/migrations/0069_auto_20190918_1520.py b/archaeological_operations/migrations/0069_auto_20190918_1520.py
new file mode 100644
index 000000000..5c380d5a1
--- /dev/null
+++ b/archaeological_operations/migrations/0069_auto_20190918_1520.py
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.18 on 2019-09-18 15:20
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0112_document_qrcode'),
+ ('archaeological_operations', '0068_auto_20190918_1508'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='historicaloperation',
+ name='applicant_authority',
+ field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='ishtar_common.Organization'),
+ ),
+ migrations.AddField(
+ model_name='historicaloperation',
+ name='minutes_writer',
+ field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='ishtar_common.Person'),
+ ),
+ migrations.AddField(
+ model_name='historicaloperation',
+ name='protagonist',
+ field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='ishtar_common.Person'),
+ ),
+ migrations.AddField(
+ model_name='operation',
+ name='applicant_authority',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='operation_applicant_authority', to='ishtar_common.Organization', verbose_name='Applicant authority'),
+ ),
+ migrations.AddField(
+ model_name='operation',
+ name='minutes_writer',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='minutes_writer', to='ishtar_common.Person', verbose_name='Writer of the minutes'),
+ ),
+ migrations.AddField(
+ model_name='operation',
+ name='protagonist',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='operation_protagonist', to='ishtar_common.Person', verbose_name='Name of the protagonist'),
+ ),
+ ]
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 07016a5e8..55594bcd9 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -693,7 +693,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
SearchVectorConfig("common_name"),
SearchVectorConfig("common_name", "local"),
SearchVectorConfig("in_charge__cached_label"),
- SearchVectorConfig("name_of_the_protagonist"),
+ SearchVectorConfig("protagonist__cached_label"),
SearchVectorConfig("official_report_number"),
SearchVectorConfig("old_code"),
SearchVectorConfig("operation_type__label"),
@@ -1048,21 +1048,24 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
seizure_name = models.TextField(_("Seizure name"), blank=True, null=True)
official_report_number = models.TextField(_("Official report number"),
blank=True, null=True)
- name_of_the_protagonist = models.TextField(_("Name of the protagonist"),
- blank=True, null=True)
- applicant_authority = models.TextField(_("Applicant authority"),
- blank=True, null=True)
- minutes_writer = models.TextField(_("Writer of the minutes"),
- blank=True, null=True)
+ protagonist = models.ForeignKey(
+ Person, verbose_name=_("Name of the protagonist"),
+ blank=True, null=True, related_name="operation_protagonist")
+ applicant_authority = models.ForeignKey(
+ Organization, verbose_name=_("Applicant authority"),
+ blank=True, null=True, related_name="operation_applicant_authority")
+ minutes_writer = models.ForeignKey(
+ Person, verbose_name=_("Writer of the minutes"),
+ blank=True, null=True, related_name="minutes_writer")
cached_towns_label = models.TextField(
_("Cached town label"), blank=True, null=True,
help_text=_("Generated automatically - do not edit")
)
- cached_periods = models.TextField(
+ cached_periods = models.TextField(
_("Cached periods label"), blank=True, null=True,
help_text=_("Generated automatically - do not edit")
)
- cached_remains = models.TextField(
+ cached_remains = models.TextField(
_("Cached remains label"), blank=True, null=True,
help_text=_("Generated automatically - do not edit")
)
diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html
index e12742aa9..afd8be3ca 100644
--- a/archaeological_operations/templates/ishtar/sheet_operation.html
+++ b/archaeological_operations/templates/ishtar/sheet_operation.html
@@ -244,9 +244,9 @@
<div class="row">
{% field_flex "Seizure name" item.seizure_name %}
{% field_flex "Official report number" item.official_report_number %}
- {% field_flex "Name of the protagonist" item.name_of_the_protagonist %}
- {% field_flex "Applicant authority" item.applicant_authority %}
- {% field_flex "Writer of the minutes" item.minutes_writer %}
+ {% field_flex_detail "Protagonist" item.protagonist %}
+ {% field_flex_detail "Applicant authority" item.applicant_authority %}
+ {% field_flex_detail "Writer of the minutes" item.minutes_writer %}
</div>
{% endif %}