summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-11-30 17:49:39 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-11-30 17:49:39 +0100
commit3232a862a9f68751ba17d7f850ce05f5f6a065c5 (patch)
tree13469ff4be4d6d84ae1272633b3f77ff25304246
parent227885e4a6b2df9e4df1507d93c31dd30c5b458a (diff)
downloadIshtar-3232a862a9f68751ba17d7f850ce05f5f6a065c5.tar.bz2
Ishtar-3232a862a9f68751ba17d7f850ce05f5f6a065c5.zip
Treatment searches and sheet
-rw-r--r--archaeological_finds/models.py4
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatment.html34
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatment_pdf.html18
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatment_window.html3
-rw-r--r--archaeological_finds/urls.py4
-rw-r--r--archaeological_finds/views.py4
-rw-r--r--ishtar_common/templatetags/window_tables.py2
-rw-r--r--ishtar_common/views.py22
8 files changed, 81 insertions, 10 deletions
diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py
index a886485b5..2957c656d 100644
--- a/archaeological_finds/models.py
+++ b/archaeological_finds/models.py
@@ -807,8 +807,8 @@ class Treatment(BaseHistorizedItem, OwnPerms):
help_text=_(
u"Location where the treatment is done. Target warehouse for "
u"a move."))
- other_location = models.CharField(_(u"Other location"), max_length=200,
- blank=True, null=True)
+ other_location = models.CharField(_(u"Location (not referenced)"),
+ max_length=200, blank=True, null=True)
person = models.ForeignKey(
Person, verbose_name=_(u"Doer"), blank=True, null=True,
on_delete=models.SET_NULL, related_name='treatments')
diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html
new file mode 100644
index 000000000..20ea9e3c4
--- /dev/null
+++ b/archaeological_finds/templates/ishtar/sheet_treatment.html
@@ -0,0 +1,34 @@
+{% extends "ishtar/sheet.html" %}
+{% load i18n window_field from_dict link_to_window window_tables window_header humanize %}
+{% load url from future %}
+
+{% block head_title %}{% trans "Treatment" %}{% endblock %}
+{% block content %}
+{% window_nav item window_id 'show-treatment' %}
+
+<ul class='form-flex'>
+ {% field_li "Treatment type" item.treatment_type %}
+ {% field_li "Container" item.container %}
+ {% field_li "Location" item.location %}
+ {% field_li "Location (not referenced)" item.other_location %}
+ {% field_li "Doer" item.person %}
+ {% field_li "Start date" item.start_date %}
+ {% field_li "End date" item.end_date %}
+</ul>
+{% if item.description or item.comment %}
+{% field "Description" item.description "<pre>" "</pre>" %}
+{% field "Comment" item.comment "<pre>" "</pre>" %}
+{% endif %}
+
+{% trans "Upstream finds" as finds %}
+{% if item.upstream.count %}
+{% dynamic_table_document finds 'finds_for_treatment' 'downstream_treatment' item.pk 'TABLE_COLS_FOR_OPE' output %}
+{% endif %}
+
+{% trans "Downstream finds" as finds %}
+{% if item.downstream.count %}
+{% dynamic_table_document finds 'finds_for_treatment' 'upstream_treatment' item.pk 'TABLE_COLS_FOR_OPE' output %}
+{% endif %}
+
+
+{% endblock %}
diff --git a/archaeological_finds/templates/ishtar/sheet_treatment_pdf.html b/archaeological_finds/templates/ishtar/sheet_treatment_pdf.html
new file mode 100644
index 000000000..08df52e97
--- /dev/null
+++ b/archaeological_finds/templates/ishtar/sheet_treatment_pdf.html
@@ -0,0 +1,18 @@
+{% extends "ishtar/sheet_treatment.html" %}
+{% block header %}
+<link rel="stylesheet" href="{{STATIC_URL}}/media/style_basic.css?ver={{VERSION}}" />
+{% endblock %}
+{% block main_head %}
+{{ block.super }}
+<div id="pdfheader">
+ Ishtar &ndash; {{APP_NAME}} &ndash; {{item}}
+</div>
+{% endblock %}
+{%block head_sheet%}{%endblock%}
+{%block main_foot%}
+<div id="pdffooter">
+ &ndash; <pdf:pagenumber/> &ndash;
+</div>
+</body>
+</html>
+{%endblock%}
diff --git a/archaeological_finds/templates/ishtar/sheet_treatment_window.html b/archaeological_finds/templates/ishtar/sheet_treatment_window.html
new file mode 100644
index 000000000..fb0757d10
--- /dev/null
+++ b/archaeological_finds/templates/ishtar/sheet_treatment_window.html
@@ -0,0 +1,3 @@
+{% extends "ishtar/sheet_treatment.html" %}
+{% block main_head %}{%endblock%}
+{% block main_foot %}{%endblock%}
diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py
index bbb123d09..220087d33 100644
--- a/archaeological_finds/urls.py
+++ b/archaeological_finds/urls.py
@@ -119,6 +119,10 @@ urlpatterns += patterns(
name='get-own-find-for-ope', kwargs={'force_own': True}),
url(r'get-find-for-ope/(?P<type>.+)?$', 'get_find_for_ope',
name='get-find-for-ope'),
+ url(r'get-find-for-treatment/own/(?P<type>.+)?$', 'get_find_for_treatment',
+ name='get-own-find-for-treatment', kwargs={'force_own': True}),
+ url(r'get-find-for-treatment/(?P<type>.+)?$', 'get_find_for_treatment',
+ name='get-find-for-treatment'),
url(r'get-find-full/own/(?P<type>.+)?$', 'get_find',
name='get-own-find-full', kwargs={'full': True, 'force_own': True}),
url(r'get-find-full/(?P<type>.+)?$', 'get_find',
diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py
index f0c67c231..1f3213504 100644
--- a/archaeological_finds/views.py
+++ b/archaeological_finds/views.py
@@ -45,6 +45,10 @@ get_find = get_item(models.Find, 'get_find', 'find')
get_find_for_ope = get_item(models.Find, 'get_find', 'find',
own_table_cols=models.Find.TABLE_COLS_FOR_OPE)
+get_find_for_treatment = get_item(
+ models.Find, 'get_find', 'find',
+ own_table_cols=models.Find.TABLE_COLS_FOR_OPE, base_request={})
+
show_treatment = show_item(models.Treatment, 'treatment')
get_treatment = get_item(models.Treatment, 'get_treatement', 'treatment')
diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py
index acb3d4a0a..566d1dfbc 100644
--- a/ishtar_common/templatetags/window_tables.py
+++ b/ishtar_common/templatetags/window_tables.py
@@ -45,6 +45,8 @@ ASSOCIATED_MODELS['context_records_relations'] = (
ASSOCIATED_MODELS['finds'] = (Find, 'get-find', 'get-find-full')
ASSOCIATED_MODELS['finds_for_ope'] = (
Find, 'get-find-for-ope', 'get-find-full')
+ASSOCIATED_MODELS['finds_for_treatment'] = (
+ Find, 'get-find-for-treatment', 'get-find-full')
ASSOCIATED_MODELS['finds_docs'] = (
FindSource, 'get-findsource', 'get-findsource-full')
ASSOCIATED_MODELS['finds_upstreamtreatments'] = (
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index cb6afe8c4..4a7c7e2e8 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -528,7 +528,7 @@ HIERARCHIC_FIELDS = ['periods', 'period', 'unit', 'material_types',
def get_item(model, func_name, default_name, extra_request_keys=[],
- base_request={}, bool_fields=[], reversed_bool_fields=[],
+ base_request=None, bool_fields=[], reversed_bool_fields=[],
dated_fields=[], associated_models=[], relative_session_names=[],
specific_perms=[], own_table_cols=None, relation_types_prefix={}):
"""
@@ -577,10 +577,12 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
my_extra_request_keys = copy(model.EXTRA_REQUEST_KEYS)
else:
my_extra_request_keys = copy(extra_request_keys)
- if not base_request and hasattr(model, 'BASE_REQUEST'):
+ if base_request is None and hasattr(model, 'BASE_REQUEST'):
my_base_request = copy(model.BASE_REQUEST)
- else:
+ elif base_request is not None:
my_base_request = copy(base_request)
+ else:
+ my_base_request = {}
if not bool_fields and hasattr(model, 'BOOL_FIELDS'):
my_bool_fields = model.BOOL_FIELDS[:]
else:
@@ -677,7 +679,7 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
request.session[default_name].split('-')[-1]}
else:
dct = {"pk": request.session[default_name]}
- elif dct == base_request:
+ elif dct == (base_request or {}):
# a parent item may be selected in the default menu
for name, key in my_relative_session_names:
if name in request.session and request.session[name]:
@@ -931,10 +933,14 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
v = v()
new_vals.append(v)
elif val:
- val = getattr(val, ky)
- if callable(val):
- val = val()
- new_vals.append(val)
+ try:
+ val = getattr(val, ky)
+ if callable(val):
+ val = val()
+ new_vals.append(val)
+ except AttributeError:
+ # must be a query key such as "contains"
+ pass
vals = new_vals
# manage last related objects
if vals and hasattr(vals[0], 'all'):