summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_finds/forms_treatments.py50
-rw-r--r--archaeological_finds/migrations/0075_auto_20190916_1822.py57
-rw-r--r--archaeological_finds/migrations/0076_treatmentfile_change_txt_idx.py18
-rw-r--r--archaeological_finds/models_treatments.py39
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatment.html1
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatmentfile.html9
6 files changed, 168 insertions, 6 deletions
diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py
index 4f906f1b9..dbd523450 100644
--- a/archaeological_finds/forms_treatments.py
+++ b/archaeological_finds/forms_treatments.py
@@ -57,6 +57,11 @@ class TreatmentSelect(HistorySelect):
other_reference = forms.CharField(label=_(u"Other ref."))
year = forms.IntegerField(label=_(u"Year"))
index = forms.IntegerField(label=_(u"Index"))
+ scientific_monitoring_manager = forms.IntegerField(
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-person-permissive'),
+ associated_model=Person),
+ label=_(u"Scientific monitoring manager"))
treatment_types = forms.ChoiceField(label=_(u"Treatment type"), choices=[])
documents__image__isnull = forms.NullBooleanField(label=_(u"Has an image?"))
@@ -109,7 +114,7 @@ class TreatmentStateSelect(forms.Select):
};
$("#id_%(name)s").change(%(id)s_check);
- %(id)s_check();
+ setTimeout(function(){ %(id)s_check(); }, 500);
</script>""" % {"name": name, "id": name.replace("-", "_"),
"exec_list": "','".join(executed_id),
"message": message}
@@ -126,6 +131,7 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
extra_form_modals = ["container", "warehouse", "organization", "person"]
associated_models = {'treatment_type': models.TreatmentType,
'person': Person,
+ 'scientific_monitoring_manager': Person,
'location': Warehouse,
'organization': Organization,
'container': Container,
@@ -149,6 +155,12 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
reverse_lazy('autocomplete-warehouse'), associated_model=Warehouse,
new=True),
validators=[valid_id(Warehouse)])
+ scientific_monitoring_manager = forms.IntegerField(
+ label=_("Scientific monitoring manager"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-person'), associated_model=Person,
+ new=True),
+ validators=[valid_id(Person)], required=False)
person = forms.IntegerField(
label=_(u"Responsible"),
widget=widgets.JQueryAutoComplete(
@@ -222,9 +234,7 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
q = Person.objects.filter(ishtaruser__pk=user.pk)
if q.count():
person = q.all()[0]
- self.fields['person'].initial = person.pk
- if person.attached_to:
- self.fields['organization'].initial = person.attached_to.pk
+ self.fields['scientific_monitoring_manager'].initial = person.pk
# self.fields['target_is_basket'].widget.choices = \
# ((False, _(u"Single find")), (True, _(u"Basket")))
# TODO
@@ -686,6 +696,21 @@ class TreatmentFileSelect(HistorySelect):
associated_model=Organization),
validators=[valid_id(Organization)])
+ end_date = forms.DateField(label=_(u"Closing date"), required=False,
+ widget=DatePicker)
+ exhibition_start_before = forms.DateField(
+ label=_(u"Exhibition started before"), widget=DatePicker
+ )
+ exhibition_start_after = forms.DateField(
+ label=_(u"Exhibition started after"), widget=DatePicker
+ )
+ exhibition_end_before = forms.DateField(
+ label=_(u"Exhibition ended before"), widget=DatePicker
+ )
+ exhibition_end_after = forms.DateField(
+ label=_(u"Exhibition ended after"), widget=DatePicker
+ )
+
def __init__(self, *args, **kwargs):
super(TreatmentFileSelect, self).__init__(*args, **kwargs)
self.fields['type'].choices = models.TreatmentFileType.get_types()
@@ -718,7 +743,7 @@ class TreatmentFileFormSelectionMultiple(MultiSearchForm):
validators=[valid_ids(models.TreatmentFile)])
-class TreatmentFileForm(ManageOldType):
+class TreatmentFileForm(CustomForm, ManageOldType):
form_label = _(u"Treatment request")
base_models = ['treatment_type_type']
associated_models = {
@@ -764,6 +789,12 @@ class TreatmentFileForm(ManageOldType):
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-findbasket'),
associated_model=models.FindBasket), required=False)
+ exhibition_name = forms.CharField(label=_("Exhibition name"),
+ max_length=200, required=False)
+ exhibition_start_date = forms.DateField(
+ label=_("Exhibition start date"), required=False, widget=DatePicker)
+ exhibition_end_date = forms.DateField(
+ label=_("Exhibition end date"), required=False, widget=DatePicker)
comment = forms.CharField(label=_(u"Comment"),
widget=forms.Textarea, required=False)
creation_date = forms.DateField(label=_(u"Start date"), required=False,
@@ -775,6 +806,15 @@ class TreatmentFileForm(ManageOldType):
end_date = forms.DateField(label=_(u"Closing date"), required=False,
widget=DatePicker)
+ TYPES = [
+ FieldType('type', models.TreatmentFileType),
+ ]
+
+ CONDITIONAL_FIELDS = (
+ (("type", "txt_idx", "loan-for-exhibition"),
+ ("exhibition_name", "exhibition_start_date", "exhibition_end_date")),
+ )
+
def __init__(self, *args, **kwargs):
user = kwargs.pop('user')
super(TreatmentFileForm, self).__init__(*args, **kwargs)
diff --git a/archaeological_finds/migrations/0075_auto_20190916_1822.py b/archaeological_finds/migrations/0075_auto_20190916_1822.py
new file mode 100644
index 000000000..3aa52d119
--- /dev/null
+++ b/archaeological_finds/migrations/0075_auto_20190916_1822.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.18 on 2019-09-16 18:22
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0111_ishtarsiteprofile_account_naming_style'),
+ ('archaeological_finds', '0074_auto_20190910_1324'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='historicaltreatment',
+ name='scientific_monitoring_manager',
+ 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='historicaltreatmentfile',
+ name='exhibition_end_date',
+ field=models.DateField(blank=True, null=True, verbose_name='Exhibition end date'),
+ ),
+ migrations.AddField(
+ model_name='historicaltreatmentfile',
+ name='exhibition_name',
+ field=models.TextField(blank=True, null=True, verbose_name='Exhibition name'),
+ ),
+ migrations.AddField(
+ model_name='historicaltreatmentfile',
+ name='exhibition_start_date',
+ field=models.DateField(blank=True, null=True, verbose_name='Exhibition start date'),
+ ),
+ migrations.AddField(
+ model_name='treatment',
+ name='scientific_monitoring_manager',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='manage_treatments', to='ishtar_common.Person', verbose_name='Scientific monitoring manager'),
+ ),
+ migrations.AddField(
+ model_name='treatmentfile',
+ name='exhibition_end_date',
+ field=models.DateField(blank=True, null=True, verbose_name='Exhibition end date'),
+ ),
+ migrations.AddField(
+ model_name='treatmentfile',
+ name='exhibition_name',
+ field=models.TextField(blank=True, null=True, verbose_name='Exhibition name'),
+ ),
+ migrations.AddField(
+ model_name='treatmentfile',
+ name='exhibition_start_date',
+ field=models.DateField(blank=True, null=True, verbose_name='Exhibition start date'),
+ ),
+ ]
diff --git a/archaeological_finds/migrations/0076_treatmentfile_change_txt_idx.py b/archaeological_finds/migrations/0076_treatmentfile_change_txt_idx.py
new file mode 100644
index 000000000..0cc48d047
--- /dev/null
+++ b/archaeological_finds/migrations/0076_treatmentfile_change_txt_idx.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.18 on 2019-09-16 18:47
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_finds', '0075_auto_20190916_1822'),
+ ]
+
+ operations = [
+ migrations.RunSQL("""UPDATE archaeological_finds_treatmentfiletype
+ SET txt_idx='loan-for-exhibition' WHERE txt_idx='loan_demand_exposure'
+ """)
+ ]
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index 52db8cabe..2a19957c8 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -70,7 +70,8 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,
SHOW_URL = 'show-treatment'
TABLE_COLS = ('year', 'index', 'treatment_types__label',
'treatment_state__label',
- 'label', 'person__cached_label',
+ 'label', 'scientific_monitoring_manager__cached_label',
+ 'person__cached_label',
'start_date', 'downstream_cached_label',
'upstream_cached_label')
REVERSED_BOOL_FIELDS = ['documents__image__isnull']
@@ -78,6 +79,8 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,
"downstream_cached_label": "downstream__cached_label",
"upstream_cached_label": "upstream__cached_label",
'person__cached_label': 'person__cached_label',
+ 'scientific_monitoring_manager__cached_label':
+ 'scientific_monitoring_manager__cached_label',
"person__pk": "person__pk", # used by dynamic_table_documents
}
COL_LABELS = {
@@ -86,6 +89,8 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,
"treatment_types__label": _(u"Type"),
"treatment_state__label": _(u"State"),
"person__cached_label": _(u"Responsible"),
+ "scientific_monitoring_manager__cached_label": _(
+ "Scientific monitoring manager"),
}
# extra keys than can be passed to save method
EXTRA_SAVED_KEYS = ('items', 'user', 'resulting_find', 'upstream_items',
@@ -118,6 +123,10 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,
pgettext_lazy("key for text search", "type"),
'treatment_types__label__iexact'
),
+ 'scientific_monitoring_manager': SearchAltName(
+ pgettext_lazy("key for text search", "scientific-manager"),
+ 'scientific_monitoring_manager__cached_label__iexact'
+ ),
}
ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES)
HISTORICAL_M2M = [
@@ -172,6 +181,10 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,
person = models.ForeignKey(
Person, verbose_name=_(u"Responsible"), blank=True, null=True,
on_delete=models.SET_NULL, related_name='treatments')
+ scientific_monitoring_manager = models.ForeignKey(
+ Person, verbose_name=_('Scientific monitoring manager'), blank=True,
+ null=True, on_delete=models.SET_NULL,
+ related_name='manage_treatments')
organization = models.ForeignKey(
Organization, verbose_name=_(u"Organization"), blank=True, null=True,
on_delete=models.SET_NULL, related_name='treatments')
@@ -925,6 +938,22 @@ class TreatmentFile(DashboardFormItem, ClosedItem, DocumentItem,
pgettext_lazy("key for text search", "applicant-organisation"),
'applicant_organisation__cached_label__iexact'
),
+ 'exhibition_start_before': SearchAltName(
+ pgettext_lazy("key for text search", "exhibition-start-before"),
+ 'exhibition_start_date__lte'
+ ),
+ 'exhibition_start_after': SearchAltName(
+ pgettext_lazy("key for text search", "exhibition-start-after"),
+ 'exhibition_start_date__gte'
+ ),
+ 'exhibition_end_before': SearchAltName(
+ pgettext_lazy("key for text search", "exhibition-end-before"),
+ 'exhibition_end_date__lte'
+ ),
+ 'exhibition_end_after': SearchAltName(
+ pgettext_lazy("key for text search", "exhibition-end-after"),
+ 'exhibition_end_date__gte'
+ ),
}
ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES)
@@ -956,6 +985,14 @@ class TreatmentFile(DashboardFormItem, ClosedItem, DocumentItem,
null=True)
reception_date = models.DateField(_(u'Reception date'), blank=True,
null=True)
+ # exhibition
+ exhibition_name = models.TextField(_("Exhibition name"),
+ blank=True, null=True)
+ exhibition_start_date = models.DateField(_("Exhibition start date"),
+ blank=True, null=True)
+ exhibition_end_date = models.DateField(_("Exhibition end date"),
+ blank=True, null=True)
+
comment = models.TextField(_(u"Comment"), null=True, blank=True)
documents = models.ManyToManyField(
Document, related_name='treatment_files', verbose_name=_(u"Documents"),
diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html
index 029257f63..e6bd83aab 100644
--- a/archaeological_finds/templates/ishtar/sheet_treatment.html
+++ b/archaeological_finds/templates/ishtar/sheet_treatment.html
@@ -76,6 +76,7 @@
{% field_flex_detail "Associated request" item.file %}
{% field_flex "Location" item.location %}
{% field_flex "Container" item.container %}
+ {% field_flex "Scientific monitoring manager" item.scientific_monitoring_manager %}
{% field_flex "Responsible" item.person %}
{% field_flex "Organization" item.organization %}
{% field_flex "Start date" item.start_date %}
diff --git a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html
index 072285262..6519e4f47 100644
--- a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html
+++ b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html
@@ -42,6 +42,15 @@
{% include "ishtar/blocks/sheet_json.html" %}
</div>
+{% if item.exhibition_name or item.exhibition_start_date or item.exhibition_end_date %}
+<h3>{% trans "Exhibition" %}</h3>
+<div class="row">
+ {% field_flex "Name" item.exhibition_name %}
+ {% field_flex "Start date" item.exhibition_start_date %}
+ {% field_flex "End date" item.exhibition_end_date %}
+</div>
+{% endif %}
+
{% if item.applicant %}
<h3>{% trans "Applicant" %}</h3>
<div class="row">