summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 004ee8d06..1ff66e195 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -100,7 +100,7 @@ post_delete.connect(post_save_cache, sender=RecordQualityType)
class ArchaeologicalSite(BaseHistorizedItem):
SHOW_URL = 'show-site'
- TABLE_COLS = ['reference', 'name', 'towns', 'periods', 'remains']
+ TABLE_COLS = ['reference', 'name', 'towns_label', 'periods', 'remains']
SLUG = 'site'
BASE_SEARCH_VECTORS = [
@@ -119,7 +119,9 @@ class ArchaeologicalSite(BaseHistorizedItem):
DATED_FIELDS = ['sinking_date']
- EXTRA_REQUEST_KEYS = {}
+ COL_LABELS = {'towns_label': _(u"Towns")}
+
+ EXTRA_REQUEST_KEYS = {'towns_label': 'towns'}
# alternative names of fields for searches
ALT_NAMES = {
@@ -263,6 +265,9 @@ class ArchaeologicalSite(BaseHistorizedItem):
return [u"{} ({})".format(town.name, town.numero_insee) for town in
self.towns.all()]
+ def towns_label(self):
+ return u" - ".join(self.towns_codes())
+
def create_or_update_top_operation(self, create=False):
"""
Create a virtual operation to associate with the site.
@@ -368,7 +373,7 @@ class ClosedItem(object):
class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
ShortMenuItem, DashboardFormItem, RelationItem):
SHOW_URL = 'show-operation'
- TABLE_COLS = ['year', 'towns', 'common_name', 'operation_type',
+ TABLE_COLS = ['year', 'towns_label', 'common_name', 'operation_type',
'start_date', 'excavation_end_date', 'remains']
SLUG = 'operation'
@@ -405,11 +410,12 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
'finds_deadline_before': 'finds_deadline__lte',
'finds_deadline_after': 'finds_deadline__gte',
'related_treatment':
- 'context_record__base_finds__find__upstream_treatment__id'
+ 'context_record__base_finds__find__upstream_treatment__id',
+ 'towns_label': 'towns'
}
COL_LABELS = {
- 'full_code_patriarche': u"Code patriarche",
+ 'code_patriarche': u"Code patriarche",
'associated_file_short_label': _(u"Associated file (label)"),
'operator__name': _(u"Operator name"),
'scientist__raw_name': _(u"Scientist (full name)"),
@@ -428,6 +434,7 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
u"Organisation (nom)",
'archaeological_sites__reference': _(u"Archaeological sites ("
u"reference)"),
+ 'towns_label': _(u"Towns"),
}
BASE_SEARCH_VECTORS = [
"abstract",
@@ -678,7 +685,7 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
if settings.COUNTRY == 'fr':
code_patriarche = models.TextField(u"Code PATRIARCHE", null=True,
blank=True, unique=True)
- TABLE_COLS = ['full_code_patriarche'] + TABLE_COLS
+ TABLE_COLS = ['code_patriarche'] + TABLE_COLS
BASE_SEARCH_VECTORS = ['code_patriarche'] + BASE_SEARCH_VECTORS
# preventive
fnap_financing = models.FloatField(u"Financement FNAP (%)",
@@ -825,6 +832,9 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
return [u"{} ({})".format(town.name, town.numero_insee) for town in
self.towns.all()]
+ def towns_label(self):
+ return u" - ".join(self.towns_codes())
+
def has_finds(self):
from archaeological_finds.models import BaseFind
return BaseFind.objects.filter(context_record__operation=self).count()
@@ -1332,9 +1342,10 @@ post_delete.connect(post_save_cache, sender=ActType)
class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
- TABLE_COLS = ['full_ref', 'year', 'index', 'act_type', 'act_object',
- 'signature_date', 'associated_file', 'operation',
- 'towns_label']
+ TABLE_COLS = ['full_ref', 'signature_date__year', 'index', 'act_type',
+ 'act_object', 'signature_date',
+ 'associated_file__cached_label',
+ 'operation__cached_label', 'towns_label']
TABLE_COLS_FILE = [
'full_ref', 'year', 'index', 'act_type',
'act_object', 'associated_file', 'towns_label',
@@ -1391,7 +1402,11 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
REVERSED_BOOL_FIELDS = ['index__isnull']
RELATIVE_SESSION_NAMES = [('operation', 'operation__pk'),
('file', 'associated_file__pk')]
- COL_LABELS = {'full_ref': _(u"Ref.")}
+ COL_LABELS = {
+ 'full_ref': _(u"Ref."), 'signature_date__year': _(u"Year"),
+ 'associated_file__cached_label': _(u"Archaeological file"),
+ 'operation__cached_label': _(u"Operation"),
+ }
BASE_SEARCH_VECTORS = ['act_type__label', 'act_object',
'towns_label']
INT_SEARCH_VECTORS = ["year", "index"]