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
commitbc3a5dc47d6a0da3ffcc6d36b2041854b143ee59 (patch)
tree9203d4e291c65caae20c72870e5eb0e5f9702c40 /archaeological_operations/views.py
parentd0eaa4529f02cea7aa7939ea397f903b3f7d0a5e (diff)
downloadIshtar-bc3a5dc47d6a0da3ffcc6d36b2041854b143ee59.tar.bz2
Ishtar-bc3a5dc47d6a0da3ffcc6d36b2041854b143ee59.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: