diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-12-14 23:52:13 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-12-14 23:52:13 +0100 |
commit | ccb709bfa5d06737e70c171202ba85aa5410194c (patch) | |
tree | e702a5e335c4366a1e27499a4db51e31b7f5c7b7 /archaeological_operations/models.py | |
parent | 9b3ede3e6d5d2b076975c188454a39c2b45d155d (diff) | |
parent | 1a1040243a10366b01b9bc2c4d3140f2fbd321e4 (diff) | |
download | Ishtar-ccb709bfa5d06737e70c171202ba85aa5410194c.tar.bz2 Ishtar-ccb709bfa5d06737e70c171202ba85aa5410194c.zip |
Merge branch 'master' of lysithea.proxience.net:/home/proxience/git/ishtar
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 26 |
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', |