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.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index e4e56843f..a3af9a0f7 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,8 @@ class ActType(GeneralType):
)
intented_to = models.CharField(_(u"Intended to"), max_length=1,
choices=TYPE)
+ 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 +411,13 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
for item in [self.operation, self.associated_file, self.act_object]
if item])
+ 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',