summaryrefslogtreecommitdiff
path: root/archaeological_operations
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/management/commands/regenerate_cached_label_ope.py38
-rw-r--r--archaeological_operations/models.py35
2 files changed, 25 insertions, 48 deletions
diff --git a/archaeological_operations/management/commands/regenerate_cached_label_ope.py b/archaeological_operations/management/commands/regenerate_cached_label_ope.py
deleted file mode 100644
index 4eee0b623..000000000
--- a/archaeological_operations/management/commands/regenerate_cached_label_ope.py
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# Copyright (C) 2014 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# See the file COPYING for details.
-
-import sys
-
-from django.db import models
-from django.core.management.base import BaseCommand, CommandError
-from django.core.exceptions import ValidationError
-
-from archaeological_operations import models
-
-class Command(BaseCommand):
- args = ''
- help = 'Regenerate cached label'
-
- def handle(self, *args, **options):
- q = models.Operation.objects
- ln = q.count()
- sys.stdout.write("\n* regeneration\n")
- for idx, operation in enumerate(q.all()):
- operation.save()
- sys.stdout.write("\r* %d/%d" % (idx, ln))
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"]