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.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index e4e56843f..125a5d7d1 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -31,7 +31,8 @@ from ishtar_common.utils import cached_label_changed
from ishtar_common.models import GeneralType, BaseHistorizedItem, \
HistoricalRecords, LightHistorizedItem, OwnPerms, Department, Source,\
- Person, Organization, Town, Dashboard, IshtarUser, ValueGetter
+ Person, Organization, Town, Dashboard, IshtarUser, ValueGetter, \
+ DocumentTemplate
FILES_AVAILABLE = 'archaeological_files' in settings.INSTALLED_APPS
if FILES_AVAILABLE:
from archaeological_files.models import File
@@ -352,6 +353,9 @@ class ActType(GeneralType):
)
intented_to = models.CharField(_(u"Intended to"), max_length=1,
choices=TYPE)
+ code = models.CharField(_(u"Code"), max_length=10, blank=True, null=True)
+ associated_template = models.ManyToManyField(DocumentTemplate, blank=True,
+ null=True, verbose_name=_(u"Associated template"))
class Meta:
verbose_name = _(u"Act type")
verbose_name_plural = _(u"Act types")
@@ -408,6 +412,26 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
for item in [self.operation, self.associated_file, self.act_object]
if item])
+ def get_filename(self, operation=False):
+ filename = ''
+ if operation and self.operation:
+ filename = self.operation.associated_filename
+ elif self.associated_file:
+ filename = self.associated_file.associated_filename
+ filename = u"-".join(filename.split('-')[:-1]) # remove date
+ if self.act_type.code:
+ filename += u"-" + self.act_type.code
+ if self.signature_date:
+ filename += u"-" + self.signature_date.strftime('%Y%m%d')
+ return filename
+
+ def publish(self):
+ if not self.act_type.associated_template.count():
+ return
+ # for administrative_act only one associated_template
+ template = self.act_type.associated_template.all()[0]
+ return template.publish(self)
+
class Parcel(LightHistorizedItem):
if FILES_AVAILABLE:
associated_file = models.ForeignKey(File, related_name='parcels',