summaryrefslogtreecommitdiff
path: root/archaeological_files/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2013-12-17 02:13:22 +0100
committerÉtienne Loks <etienne.loks@peacefrogs.net>2013-12-17 02:13:22 +0100
commitbdcb80ff43bbe7bda74785a4d97572631959c05c (patch)
tree7daed5ea896db340d80d1f20fcd990c4bb27526a /archaeological_files/forms.py
parent758ee42b4970372d38d620f80c51854abc64a69f (diff)
downloadIshtar-bdcb80ff43bbe7bda74785a4d97572631959c05c.tar.bz2
Ishtar-bdcb80ff43bbe7bda74785a4d97572631959c05c.zip
Administrativ act - document generation: Allow to generate many documents
Diffstat (limited to 'archaeological_files/forms.py')
-rw-r--r--archaeological_files/forms.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py
index 4e0273e77..fcc62b39d 100644
--- a/archaeological_files/forms.py
+++ b/archaeological_files/forms.py
@@ -195,6 +195,28 @@ class FinalFileDeleteForm(FinalForm):
confirm_msg = " "
confirm_end_msg = _(u"Would you like to delete this archaelogical file ?")
+class DocumentGenerationAdminActForm(forms.Form):
+ _associated_model = AdministrativeAct
+ document_template = forms.ChoiceField(label=_("Template"), choices=[])
+
+ def __init__(self, *args, **kwargs):
+ super(DocumentGenerationAdminActForm, self).__init__(*args, **kwargs)
+ self.fields['document_template'].choices = DocumentTemplate.get_tuples(
+ dct={'associated_object_name':
+ 'archaeological_operations.models.AdministrativeAct'})
+
+ def save(self, object_pk):
+ try:
+ c_object = self._associated_model.objects.get(pk=object_pk)
+ except self._associated_model.DoesNotExist:
+ return
+ try:
+ template = DocumentTemplate.objects.get(
+ pk=self.cleaned_data.get('document_template'))
+ except DocumentTemplate.DoesNotExist:
+ return
+ return template.publish(c_object)
+
class AdministrativeActFileSelect(TableSelect):
associated_file__towns = get_town_field()
act_type = forms.ChoiceField(label=_("Act type"), choices=[])