summaryrefslogtreecommitdiff
path: root/archaeological_operations/views.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2014-12-12 23:21:45 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2014-12-12 23:21:45 +0100
commit00b2c7e6d225fa97567bab088b9c8deef76dda62 (patch)
tree9203d4e291c65caae20c72870e5eb0e5f9702c40 /archaeological_operations/views.py
parent982bface0b1d11c614f457a40bffb7c84d987cc7 (diff)
downloadIshtar-00b2c7e6d225fa97567bab088b9c8deef76dda62.tar.bz2
Ishtar-00b2c7e6d225fa97567bab088b9c8deef76dda62.zip
Better management of document generation form (refs #2132)
* check if the document template is compatible with the selected object * remove dead code (old document generation form)
Diffstat (limited to 'archaeological_operations/views.py')
-rw-r--r--archaeological_operations/views.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index 182ae115e..ba66a724a 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -357,10 +357,22 @@ def administrativeactfile_document(request, operation=True):
dct = {}
if request.POST:
dct['search_form'] = search_form(request.POST)
- dct['template_form'] = DocumentGenerationAdminActForm(request.POST,
- operation=operation)
- if dct['search_form'].is_valid() and dct['template_form'].is_valid():
- return generatedoc_administrativeactop(request,
+ dct['template_form'] = DocumentGenerationAdminActForm(
+ operation=operation)
+ c_object = None
+ try:
+ if dct['search_form'].is_valid():
+ c_object = \
+ DocumentGenerationAdminActForm._associated_model.objects.get(
+ pk=dct['search_form'].cleaned_data.get('pk'))
+ except DocumentGenerationAdminActForm._associated_model.DoesNotExist:
+ pass
+ if c_object:
+ dct['template_form'] = DocumentGenerationAdminActForm(request.POST,
+ operation=operation,
+ obj=c_object)
+ if dct['template_form'].is_valid():
+ return generatedoc_administrativeactop(request,
dct['search_form'].cleaned_data.get('pk'),
dct['template_form'].cleaned_data.get('document_template'))
else: