summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-01-19 17:59:04 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-01-19 17:59:04 +0100
commit819ff20e535d670bf4d7946284049d92cc261ede (patch)
treee8a1dd8ba41805eee55711d5e09d0c3ac3139815
parent642a104a9497bc6a0171ef1c6c8d96b68492c78c (diff)
downloadIshtar-819ff20e535d670bf4d7946284049d92cc261ede.tar.bz2
Ishtar-819ff20e535d670bf4d7946284049d92cc261ede.zip
Adapt context record forms
-rw-r--r--archaeological_context_records/forms.py1
-rw-r--r--archaeological_context_records/models.py17
-rw-r--r--ishtar_common/templates/base.html5
-rw-r--r--ishtar_common/views.py5
4 files changed, 25 insertions, 3 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index ea47be311..b2bf9f39b 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -115,6 +115,7 @@ class RecordSelect(TableSelect):
class RecordFormSelection(forms.Form):
form_label = _("Context record search")
+ SEARCH_AND_SELECT = True
associated_models = {'pk': models.ContextRecord}
currents = {'pk': models.ContextRecord}
pk = forms.IntegerField(
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 71e8330b7..5e9d63652 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -42,6 +42,8 @@ class DatingType(GeneralType):
verbose_name = _(u"Dating type")
verbose_name_plural = _(u"Dating types")
ordering = ('label',)
+
+
post_save.connect(post_save_cache, sender=DatingType)
post_delete.connect(post_save_cache, sender=DatingType)
@@ -51,6 +53,8 @@ class DatingQuality(GeneralType):
verbose_name = _(u"Dating quality type")
verbose_name_plural = _(u"Dating quality types")
ordering = ('label',)
+
+
post_save.connect(post_save_cache, sender=DatingQuality)
post_delete.connect(post_save_cache, sender=DatingQuality)
@@ -119,6 +123,8 @@ class Unit(GeneralType):
def __unicode__(self):
return self.label
+
+
post_save.connect(post_save_cache, sender=Unit)
post_delete.connect(post_save_cache, sender=Unit)
@@ -133,6 +139,8 @@ class ActivityType(GeneralType):
def __unicode__(self):
return self.label
+
+
post_save.connect(post_save_cache, sender=ActivityType)
post_delete.connect(post_save_cache, sender=ActivityType)
@@ -147,6 +155,8 @@ class IdentificationType(GeneralType):
def __unicode__(self):
return self.label
+
+
post_save.connect(post_save_cache, sender=IdentificationType)
post_delete.connect(post_save_cache, sender=IdentificationType)
@@ -156,6 +166,8 @@ class ExcavationTechnicType(GeneralType):
verbose_name = _(u"Excavation technique type")
verbose_name_plural = _(u"Excavation technique types")
ordering = ('label',)
+
+
post_save.connect(post_save_cache, sender=ExcavationTechnicType)
post_delete.connect(post_save_cache, sender=ExcavationTechnicType)
@@ -165,6 +177,8 @@ class DocumentationType(GeneralType):
verbose_name = _(u"Documentation type")
verbose_name_plural = _(u"Documentation types")
ordering = ('label',)
+
+
post_save.connect(post_save_cache, sender=DocumentationType)
post_delete.connect(post_save_cache, sender=DocumentationType)
@@ -196,7 +210,7 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
EXTERNAL_ID_KEY = 'context_record_external_id'
EXTERNAL_ID_DEPENDENCIES = ['base_finds']
TABLE_COLS = ['label', 'operation__common_name', 'parcel__town__name',
- 'parcel__label', 'unit']
+ 'parcel__short_label', 'unit']
if settings.COUNTRY == 'fr':
TABLE_COLS.insert(1, 'operation__code_patriarche')
TABLE_COLS_FOR_OPE = ['label', 'parcel', 'unit',
@@ -222,6 +236,7 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
# search parameters
EXTRA_REQUEST_KEYS = {
'parcel__town': 'parcel__town__pk',
+ 'parcel__short_label': 'parcel__short_label',
'operation__year': 'operation__year__contains',
'year': 'operation__year__contains',
'operation__code_patriarche': 'operation__code_patriarche',
diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html
index ee318fa7c..fa62acdd2 100644
--- a/ishtar_common/templates/base.html
+++ b/ishtar_common/templates/base.html
@@ -54,11 +54,12 @@
<body{% if current_theme%} id='{{current_theme}}'{%endif%}>
{% include "navbar.html" %}
{% if not reminders %}<div id="context-menu" class="navbar navbar-expand-lg"></div>
- {% else %}<fieldset id='reminder'><legend>{% trans "Current items" %}</legend>
+ {% else %}
+<div id="reminder"><h5>{% trans "Current items" %}</h5>
{% for lbl, value in reminders %}
<p><strong class='lbl'>{{lbl}}{% trans ":"%}</strong> <span class='value'>{{value}}</span></p>
{% endfor %}
-</fieldset>{%endif%}
+</div> {%endif%}
<button class="nav-button btn btn-sm btn-secondary" id="to_bottom_arrow">
<i class="fa fa-arrow-down" aria-hidden="true"></i>
</button>
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index 020544d19..b0365c1cf 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -608,6 +608,8 @@ def _get_values(request, val):
DEFAULT_ROW_NUMBER = 10
+# length is used by ajax DataTable call and can be ambiguous for some models
+EXCLUDED_FIELDS = ['length']
def get_item(model, func_name, default_name, extra_request_keys=[],
@@ -702,6 +704,9 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
request_keys.update(my_extra_request_keys)
request_items = request.method == 'POST' and request.POST \
or request.GET
+ request_items = dict(
+ [(k, request_items[k])
+ for k in request_items if k not in EXCLUDED_FIELDS])
dct = my_base_request
if full == 'shortcut':
dct['cached_label__icontains'] = request.GET.get('term', None)