From ca92ada04a5440c7bcfb9ec6f1bae3fc9f3902ab Mon Sep 17 00:00:00 2001
From: Étienne Loks
Date: Thu, 21 Apr 2011 23:20:25 +0200
Subject: First version of context record window (refs #376)
---
ishtar/furnitures/models.py | 79 ++++++++++---
ishtar/templates/sheet_context_proto.html | 115 -------------------
ishtar/templates/sheet_contextrecord.html | 136 +++++++++++++++++++++++
ishtar/templates/sheet_contextrecord_window.html | 3 +
4 files changed, 202 insertions(+), 131 deletions(-)
delete mode 100644 ishtar/templates/sheet_context_proto.html
create mode 100644 ishtar/templates/sheet_contextrecord.html
create mode 100644 ishtar/templates/sheet_contextrecord_window.html
diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py
index 9d1873770..f9e9080df 100644
--- a/ishtar/furnitures/models.py
+++ b/ishtar/furnitures/models.py
@@ -37,6 +37,8 @@ from simple_history.models import HistoricalRecords as BaseHistoricalRecords
from ishtar import settings
+JOINT = u" - "
+
# HistoricalRecords enhancement: don't save identical versions
class HistoricalRecords(BaseHistoricalRecords):
def create_historical_record(self, instance, type):
@@ -289,7 +291,7 @@ class Departement(models.Model):
ordering = ['number']
def __unicode__(self):
- return unicode(self.number) + u" - " + self.label
+ return unicode(self.number) + JOINT + self.label
class Address(BaseHistorizedItem):
address = models.TextField(_(u"Address"), null=True, blank=True)
@@ -366,7 +368,8 @@ class Person(Address, OwnPerms) :
)
def __unicode__(self):
- lbl = u"%s %s - " % (self.name, self.surname)
+ lbl = u"%s %s" % (self.name, self.surname)
+ lbl += JOINT
if self.attached_to:
lbl += unicode(self.attached_to)
elif self.email:
@@ -474,7 +477,7 @@ class File(BaseHistorizedItem, OwnPerms):
unicode(self.numeric_reference))))
items += [unicode(getattr(self, k))[:36]
for k in ['internal_reference',] if getattr(self, k)]
- return u" - ".join(items)
+ return JOINT.join(items)
@classmethod
def get_query_owns(cls, user):
@@ -577,7 +580,7 @@ class Operation(BaseHistorizedItem, OwnPerms):
items[0] = unicode(self.towns.all()[0])
items.append("-".join((unicode(self.year),
unicode(self.operation_code))))
- return u" - ".join(items)
+ return JOINT.join(items)
def is_own(self, person):
return False
@@ -614,12 +617,11 @@ class Parcel(LightHistorizedItem):
verbose_name_plural = _(u"Parcels")
def short_label(self):
- return u" - ".join([unicode(item) for item in \
- [self.town, self.section, self.parcel_number]
- if item])
+ return JOINT.join([unicode(item) for item in [self.section,
+ self.parcel_number] if item])
def __unicode__(self):
- return u" - ".join([unicode(item) for item in \
+ return JOINT.join([unicode(item) for item in \
[self.associated_file, self.operation, self.section, self.parcel_number]
if item])
@@ -727,7 +729,25 @@ class ContextRecord(BaseHistorizedItem, OwnPerms):
)
def __unicode__(self):
- return u"%s - %s" % (self.parcel, self.label)
+ return JOINT.join((unicode(self.parcel), self.label))
+
+ def full_label(self):
+ if not self.parcel.operation:
+ return unicode(self)
+ return self._real_label() or self._temp_label()
+
+ def _real_label(self):
+ if not self.parcel.operation.code_patriarche:
+ return
+ return JOINT.join((self.parcel.operation.code_patriarche,
+ self.label))
+
+ def _temp_label(self):
+ if self.parcel.operation.code_patriarche:
+ return
+ return JOINT.join([unicode(lbl) for lbl in [self.parcel.operation.year,
+ self.parcel.operation.operation_code,
+ self.label] if lbl])
class SourceType(GeneralType):
class Meta:
@@ -758,7 +778,7 @@ class BaseItem(BaseHistorizedItem, OwnPerms):
label = models.CharField(_(u"Label"), max_length=60)
description = models.TextField(_(u"Description"))
context_record = models.ForeignKey(ContextRecord,
- verbose_name=_(u"Context Record"))
+ related_name='base_items', verbose_name=_(u"Context Record"))
is_isolated = models.NullBooleanField(_(u"Is isolated?"), blank=True,
null=True)
documentations = models.ManyToManyField(Source)
@@ -777,6 +797,28 @@ class BaseItem(BaseHistorizedItem, OwnPerms):
def __unicode__(self):
return self.label
+ def get_last_item(self):
+ #TODO: manage virtuals - property(last_item) ?
+ return self.item.filter().order_by("-order").all()[0]
+
+ def full_label(self):
+ return self._real_label() or self._temp_label()
+
+ def _real_label(self):
+ if not self.context_record.parcel.operation.code_patriarche:
+ return
+ return JOINT.join((self.context_record.parcel.operation.code_patriarche,
+ self.context_record.label,
+ self.label))
+
+ def _temp_label(self):
+ if self.context_record.parcel.operation.code_patriarche:
+ return
+ return JOINT.join((self.context_record.parcel.year,
+ #TODO:self.index
+ self.context_record.label,
+ self.label))
+
class Item(BaseHistorizedItem, OwnPerms):
TABLE_COLS = ['base_items.context_record.parcel.town',
'base_items.context_record.parcel.operation.year',
@@ -816,6 +858,11 @@ class Item(BaseHistorizedItem, OwnPerms):
def __unicode__(self):
return self.label
+ def material_type_label(self):
+ #TODO to complete cf. #372 and sheet_contextrecord template
+ return unicode(self.material_type)
+
+
class ParcelOwner(LightHistorizedItem):
owner = models.ForeignKey(Person, verbose_name=_(u"Owner"))
parcel = models.ForeignKey(Parcel, verbose_name=_(u"Parcel"))
@@ -827,7 +874,7 @@ class ParcelOwner(LightHistorizedItem):
verbose_name_plural = _(u"Parcel owners")
def __unicode__(self):
- return self.owner + u" - " + self.parcel
+ return self.owner + JOINT + self.parcel
class WarehouseType(GeneralType):
class Meta:
@@ -900,7 +947,7 @@ related_name='+', verbose_name=_(u"Person in charge of the scientific part"))
)
def __unicode__(self):
- return u" - ".join([unicode(item)
+ return JOINT.join([unicode(item)
for item in [self.operation, self.associated_file, self.act_object]
if item])
@@ -932,14 +979,14 @@ if settings.COUNTRY == 'fr':
department = models.ForeignKey(Departement, verbose_name=u"Département")
def __unicode__(self):
- return u"%s - %s" % (self.name, unicode(self.department))
+ return JOINT.join((self.name, unicode(self.department)))
class Canton(models.Model):
name = models.CharField(u"Nom", max_length=30)
arrondissement = models.ForeignKey(Arrondissement,
verbose_name=u"Arrondissement")
def __unicode__(self):
- return u"%s - %s" % (self.name, unicode(self.arrondissement))
+ return JOINT.join((self.name, unicode(self.arrondissement)))
class Town(models.Model):
name = models.CharField(_(u"Name"), max_length=100)
@@ -1011,7 +1058,7 @@ class Author(models.Model):
verbose_name_plural = _(u"Authors")
def __unicode__(self):
- return self.person + u" - " + self.source
+ return self.person + JOINT + self.source
class Property(LightHistorizedItem):
item = models.ForeignKey(Item, verbose_name=_(u"Item"))
@@ -1026,5 +1073,5 @@ class Property(LightHistorizedItem):
verbose_name_plural = _(u"Properties")
def __unicode__(self):
- return self.person + u" - " + self.item
+ return self.person + JOINT + self.item
diff --git a/ishtar/templates/sheet_context_proto.html b/ishtar/templates/sheet_context_proto.html
deleted file mode 100644
index 365a766b5..000000000
--- a/ishtar/templates/sheet_context_proto.html
+++ /dev/null
@@ -1,115 +0,0 @@
-{% extends "sheet.html" %}
-{% load i18n %}
-{% block content %}
-
-
-{% trans "Context Unit"%}
-
-{% if item.operation.patriarche_code %}{%trans "Complete_label:"%} {{ item.operation.complete_label }}
{%endif%}
-{% if item.operation.patriarche_code_not_recorded %}{%trans "Patriarche OA code not yet recorded !"%}
-{%trans "Temporary_label:"%} {{ item.operation.temporary_label }}
-{%endif%}
-{% trans "Type:" %} {{ item.unit_type }}
-{% trans "Chronology:" %} {{ item.period.all|join:", " }}
-{% trans "Place:" %} {{ item.place }}
-{% trans "Parcel:" %} {{ item.section_and_parcel }}
-
-{% trans "Description"%}
-
-{% trans "Description:" %} {{ item.description }}
-{% if item.lenght %}{% trans "Length (cm):" %} {{ item.length }}
{%endif%}
-{% if item.width %}{% trans "Width (cm):" %} {{ item.width }}
{%endif%}
-{% if item.depth %}{% trans "Depth (cm):" %} {{ item.depth }}
{%endif%}
-
-{% trans "Interpretation"%}
-
-{% if item.activity %}{% trans "Activity:" %} {{ item.activity }}
{%endif%}
-{% if item.identification %}{% trans "Identification:" %} {{ item.identification }}
{%endif%}
-{% if item.interpretation %}{% trans "Interpretation:" %} {{ item.interpretation }}
{%endif%}
-
-{% if item.TAQ or item.TAQ_estimated or item.TPQ or item.TPQ_estimated %}
-{% trans "Datations"%}
-{% if item.TAQ %}{% trans "TAQ:" %} {{ item.TAQ }}
{%endif%}
-{% if item.TAQ_estimated %}{% trans "TAQ estimated:" %} {{ item.TAQ_estimated }}
{%endif%}
-{% if item.TPQ %}{% trans "TPQ:" %} {{ item.TPQ }}
{%endif%}
-{% if item.TPQ_estimated %}{% trans "TPQ estimated:" %} {{ item.TPQ_estimated }}
{%endif%}
-{%endif%}
-
-{% if item.related_operation %}
-{% trans "Operation resume"%}
-{%trans "Year:"%} {{ item.operation.year }}
-{%trans "Numerical reference:"%} {{ item.operation.numeric_reference }}
-{% if item.operation.patriarche_code %}{%trans "Patriarche OA code:"%} {{ item.operation.patriarche_code }}
{%endif%}
-{% if item.operation.patriarche_code_not_recorded %}{%trans "Patriarche OA code not yet recorded !"%}
{%endif%}
-{%trans "Operation's name:"%} {{ item.operation.internal_reference }}
-{%trans "Head scientist:"%} {{ item.operation.head_scientist.full_label }}
-{%trans "State:"%} {% if item.operation.is_active %}{%trans "Active file"%}
-{% else %}{%trans "Closed operation"%}
-{%trans "Closing date:"%} {{ item.operation.closing.date }} {%trans "by" %} {{ item.operation.closing.user }}
-{% endif %}
-{%trans "Type:"%} {{ item.operation.operation_type }}
-{%trans "Remains:"%} {{ item.operation.remains.all|join:", " }}
-{%trans "Periods:"%} {{ item.operation.periods.all|join:", " }}
-{% if item.operation.comment %}{%trans "Comment:"%} {{ item.operation.comment }}
{%endif%}
-{% trans "Localisation"%}
-{%trans "Towns:"%} {{ item.operation.towns.all|join:", " }}
-{%trans "Related operation:"%} {{ item.related_operation }}
-{% else %}{%trans "No operation linked to this context unit !"%}
-{% endif %}
-
-{% trans "Documentation"%}
-
- {%trans "Documents"%}
-
- {% trans "Title" %}
- {% trans "Type" %}
- {% trans "Authors" %}
- {% trans "Localisation" %}
-
- {% for doc in item.operation.doc.all %}
-
- {{ doc.title }}
- {{doc.type}}
- {{ doc.author.all|join:", " }}
- {{ doc.localisation }}
-
- {% empty %}
- {% trans "No document associated to this context unit" %}
- {% endfor %}
-
-
-{% trans "Finds"%}
-
- {%trans "Finds"%}
-
- {% trans "Find_complete_Label" %}
- {% trans "Find_complete_material_type_Label" %}
- {% trans "Context_record" %}
- {% trans "Periods" %}
- {% trans "Description" %}
- {% trans "Weight" %}
- {% trans "Numbers" %}
- {% trans "Parcel" %}
-
-
- {% for find in item.find.all %}
-
- {% if item.operation.patriarche_code %}{% trans "item.find.complete_label" %} {%endif%}
- {% if item.operation.patriarche_code_not_recorded %}{% trans "item.find.not_patriarche_complete_label" %} {%endif%}
- {% if item.operation.patriarche_code %}{% trans "item.find.material_type_complete_label" %} {%endif%}
- {% if item.operation.patriarche_code_not_recorded %}{% trans "item.find.material_type_not_patriarche_complete_label" %} {%endif%}
-
- {{item.find.context_record}}
- {{ item.find.period.all|join:", " }}
- {{ item.find.description }}
- {{ item.find.weight }}
- {{ item.find.numbers }}
- {{ item.find.record_unit.section_and_parcel }}
- {% trans "Details" %}
-
- {% empty %}
- {% trans "No find associated to this operation" %}
- {% endfor %}
-
-
-{% endblock %}
diff --git a/ishtar/templates/sheet_contextrecord.html b/ishtar/templates/sheet_contextrecord.html
new file mode 100644
index 000000000..0f7259f3a
--- /dev/null
+++ b/ishtar/templates/sheet_contextrecord.html
@@ -0,0 +1,136 @@
+{% extends "sheet.html" %}
+{% load i18n %}
+{% block content %}
+
+
+{% trans "Context Record"%}
+
+{% if item.parcel.operation.code_patriarche %}
+{%trans "Complete label:"%}
+{% else %}
+
{%trans "Patriarche OA code not yet recorded!"%}
+{%trans "Temporary label:"%}
+{%endif%}
+{{item.full_label}}
+{%if item.unit %}
+{% trans "Type:" %} {{ item.unit }}
+{%endif%}
+{% trans "Chronology:" %} {{ item.datings.all|join:", " }}
+{% trans "Place:" %} {{ item.parcel.town }}
+{% trans "Parcel:" %} {{ item.parcel.short_label }}
+
+{% if item.description or item.lenght or item.width or item.depth %}
+{% trans "Description"%}
+
+{% trans "Description:" %} {{ item.description }}
+{% if item.lenght %}{% trans "Length (cm):" %} {{ item.length }}
{%endif%}
+{% if item.width %}{% trans "Width (cm):" %} {{ item.width }}
{%endif%}
+{% if item.depth %}{% trans "Depth (cm):" %} {{ item.depth }}
{%endif%}
+{% endif %}
+
+{% if item.activity or item.identification or item.interpretation %}
+{% trans "Interpretation"%}
+
+{% if item.activity %}{% trans "Activity:" %} {{ item.activity }}
{%endif%}
+{% if item.identification %}{% trans "Identification:" %} {{ item.identification }}
{%endif%}
+{% if item.interpretation %}{% trans "Interpretation:" %} {{ item.interpretation }}
{%endif%}
+{% endif %}
+
+{% if item.taq or item.taq_estimated or item.tpq or item.tpq_estimated %}
+{% trans "Datations"%}
+{% if item.taq %}{% trans "TAQ:" %} {{ item.taq }}
{%endif%}
+{% if item.taq_estimated %}{% trans "TAQ estimated:" %} {{ item.taq_estimated }}
{%endif%}
+{% if item.tpq %}{% trans "TPQ:" %} {{ item.tpq }}
{%endif%}
+{% if item.tpq_estimated %}{% trans "TPQ estimated:" %} {{ item.tpq_estimated }}
{%endif%}
+{%endif%}
+
+{% if item.parcel.operation %}
+{% trans "Operation resume"%}
+{%trans "Year:"%} {{ item.parcel.operation.year }}
+{%trans "Numerical reference:"%} {{ item.parcel.operation.numeric_reference }}
+{% if item.parcel.operation.code_patriarche %}
+{%trans "Patriarche OA code:"%}
+{{ item.parcel.operation.code_patriarche }}
+{% else %}{%trans "Patriarche OA code not yet recorded!"%}
+{%endif%}
+{%trans "Operation's name:"%}
+{{ item.parcel.operation.internal_reference }}
+{%trans "Head scientist:"%}
+{{ item.parcel.operation.in_charge.full_label }}
+{%trans "State:"%}
+{% if item.parcel.operation.is_active %}
+{%trans "Active file"%}
+{% else %}
+{%trans "Closed operation"%}
+{%trans "Closing date:"%} {{ item.parcel.operation.closing.date }}
+{%trans "by" %} {{ item.parcel.operation.closing.user }}
+{% endif %}
+{%trans "Type:"%} {{ item.parcel.operation.operation_type }}
+{%trans "Remains:"%} {{ item.parcel.operation.remains.all|join:", " }}
+{%trans "Periods:"%} {{ item.parcel.operation.periods.all|join:", " }}
+{% if item.parcel.operation.comment %}{%trans "Comment:"%} {{ item.parcel.operation.comment }}
{%endif%}
+{% trans "Localisation"%}
+{%trans "Towns:"%} {{ item.parcel.operation.towns.all|join:", " }}
+{%trans "Related operation:"%}
+{{ item.parcel.operation }}
+{# TODO: Displayed as Year/index/Commune/Common_name This should be a link to the file sheet of the related operation #}
+{% else %}{%trans "No operation linked to this context unit!"%}
+{% endif %}
+
+
+ {%trans "Documents"%}
+
+ {% trans "Title" %}
+ {% trans "Type" %}
+ {% trans "Authors" %}
+ {% trans "Localisation" %}
+
+ {% for doc in item.parcel.operation.documents.all %}
+
+ {{ doc.title }}
+ {{doc.type}}
+ {{ doc.author.all|join:", " }}
+ {{ doc.localisation }}
+
+ {% empty %}
+ {% trans "No document associated to this context record" %}
+ {% endfor %}
+
+
+
+ {%trans "Finds"%}
+
+ {% trans "Find" %}
+ {% trans "Material type" %}
+ {% trans "Context record" %}
+ {% trans "Periods" %}
+ {% trans "Description" %}
+ {% trans "Weight" %}
+ {% trans "Numbers" %}
+ {% trans "Parcel" %}
+
+
+ {% for find in item.base_items.all %}
+
+ {{ find.full_label }}
+{# Displayed as (Patriarche operation code)-(Record unit label)-(Finds label). #}
+{# or displayed as (Year)-(index)-(Record unit label)-(Finds label). #}
+ {{ find.get_last_item.material_type_label }}
+{# Displayed as (Patriarche operation code)-(Record unit label)-(material code)-(Finds label indexed by material type). #}
+{# or displayed as (Year)-(index)-(Record unit label)-(material code)-(Finds label indexed by material type) #}
+
+ {{find.context_record.short_label}}
+ {{ find.get_last_item.dating}} {# TODO .all|join:", " ? #}
+ {{ find.get_last_item.description }}
+ {{ find.get_last_item.weight }}
+ {{ find.get_last_item.item_number }}
+ {{ item.context_record.parcel.short_label }}
+ {% trans "Details" %}
+ {#{%trans "Details"%} #}
+
+ {% empty %}
+ {% trans "No find associated to this operation" %}
+ {% endfor %}
+
+
+{% endblock %}
diff --git a/ishtar/templates/sheet_contextrecord_window.html b/ishtar/templates/sheet_contextrecord_window.html
new file mode 100644
index 000000000..7ff65d1e7
--- /dev/null
+++ b/ishtar/templates/sheet_contextrecord_window.html
@@ -0,0 +1,3 @@
+{% extends "sheet_contextrecord.html" %}
+{% block main_head %}{%endblock%}
+{% block main_foot %}{%endblock%}
--
cgit v1.2.3