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.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index c7a8c94ac..ca649d2d0 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -134,6 +134,9 @@ class ArchaeologicalSite(BaseHistorizedItem):
class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem):
TABLE_COLS = ['year_index', 'operation_type', 'remains', 'towns',
+ 'start_date', 'excavation_end_date']
+ if FILES_AVAILABLE:
+ TABLE_COLS = ['year_index', 'operation_type', 'remains', 'towns',
'associated_file_short_label', 'start_date',
'excavation_end_date']
start_date = models.DateField(_(u"Start date"), null=True, blank=True)
@@ -434,7 +437,7 @@ def operation_post_save(sender, **kwargs):
operation.fnap_financing = fnap_percent
operation.save()
cached_label_changed(sender, **kwargs)
- if operation.associated_file:
+ if FILES_AVAILABLE and operation.associated_file:
operation.associated_file.update_short_menu_class()
post_save.connect(operation_post_save, sender=Operation)
@@ -493,6 +496,9 @@ class ActType(GeneralType):
class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
TABLE_COLS = ['full_ref', 'year', 'index', 'act_type', 'signature_date',
+ 'operation']
+ if FILES_AVAILABLE:
+ TABLE_COLS = ['full_ref', 'year', 'index', 'act_type', 'signature_date',
'associated_file', 'operation']
TABLE_COLS_FILE = ['full_ref', 'year', 'index', 'act_type', 'associated_file',
'associated_file.towns',]
@@ -550,9 +556,10 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
)
def __unicode__(self):
- return settings.JOINT.join([unicode(item)
- for item in [self.operation, self.associated_file, self.act_object]
- if item])
+ items = [self.operation, self.act_object]
+ if FILES_AVAILABLE:
+ items = [self.operation, self.associated_file, self.act_object]
+ return settings.JOINT.join([unicode(item) for item in items if item])
full_ref_lbl = _(u"Ref.")
@property
@@ -568,7 +575,7 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
@property
def towns(self):
- if self.associated_file:
+ if FILES_AVAILABLE and self.associated_file:
return self.associated_file.towns.all()
elif self.operation:
return self.operation.towns.all()
@@ -577,7 +584,8 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
@property
def related_item(self):
- return self.operation if self.operation else self.associated_file
+ return self.operation if self.operation \
+ else FILES_AVAILABLE and self.associated_file
def get_filename(self):
filename = self.related_item.associated_filename
@@ -643,7 +651,7 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
self._get_index()
super(AdministrativeAct, self).save(*args, **kwargs)
- if hasattr(self, 'associated_file') and self.associated_file:
+ if FILES_AVAILABLE and self.associated_file:
self.associated_file.update_has_admin_act()
self.associated_file.update_short_menu_class()
@@ -720,7 +728,8 @@ class Parcel(LightHistorizedItem):
return res
def long_label(self):
- items = [unicode(self.operation or self.associated_file)]
+ items = [unicode(self.operation or
+ (FILES_AVAILABLE and self.associated_file))]
items += [unicode(item) for item in [self.section, self.parcel_number]
if item]
return settings.JOINT.join(items)