diff options
Diffstat (limited to 'archaeological_operations')
| -rw-r--r-- | archaeological_operations/views.py | 28 | 
1 files changed, 23 insertions, 5 deletions
| diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index 858043c82..48d7c4a4f 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -18,6 +18,7 @@  # See the file COPYING for details.  import json +from jinja2 import TemplateSyntaxError  from django.conf import settings  from django.core.urlresolvers import reverse @@ -48,7 +49,8 @@ from archaeological_operations.wizards import has_associated_file, \      SiteDeletionWizard, OperationSearch  from ishtar_common.forms import ClosingDateFormSelection, FinalForm, \      FinalDeleteForm -from ishtar_common.models import get_current_profile, IshtarSiteProfile +from ishtar_common.models import get_current_profile, IshtarSiteProfile, \ +    DocumentTemplate  from ishtar_common.utils import put_session_message, check_rights_condition  from ishtar_common.views_item import get_item, show_item, revert_item, new_item  from ishtar_common.wizards import SearchWizard @@ -530,10 +532,26 @@ def administrativeactfile_document(              dct['template_form'] = DocumentGenerationAdminActForm(                  request.POST, document_type=document_type, 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')) +                try: +                    return generatedoc_administrativeactop( +                        request, +                        dct['search_form'].cleaned_data.get('pk'), +                        dct['template_form'].cleaned_data.get( +                            'document_template')) +                except TemplateSyntaxError: +                    dct['search_form'] = search_form() +                    try: +                        template = DocumentTemplate.objects.get(pk=dct[ +                            'template_form'].cleaned_data.get( +                                'document_template')).name +                    except DocumentTemplate.DoesNotExist: +                        template = "" +                    dct['template_form'] = DocumentGenerationAdminActForm( +                        document_type=document_type) +                    dct['template_error'] = unicode(_( +                        u"Syntax error on the source template \"{}\" - " +                        u"contact your administrator and ask him to check " +                        u"the syntax of this document.")).format(template)      else:          dct['search_form'] = search_form()          dct['template_form'] = DocumentGenerationAdminActForm( | 
