diff options
| -rw-r--r-- | archaeological_files/forms.py | 24 | ||||
| -rw-r--r-- | archaeological_files/urls.py | 2 | ||||
| -rw-r--r-- | archaeological_files/views.py | 3 | ||||
| -rw-r--r-- | archaeological_operations/forms.py | 25 | ||||
| -rw-r--r-- | archaeological_operations/ishtar_menu.py | 4 | ||||
| -rw-r--r-- | archaeological_operations/urls.py | 3 | ||||
| -rw-r--r-- | archaeological_operations/views.py | 16 | ||||
| -rw-r--r-- | example_project/local_settings.py.sample | 6 | ||||
| -rw-r--r-- | example_project/settings.py | 11 | 
9 files changed, 63 insertions, 31 deletions
| diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py index b97ca9f15..755c565f2 100644 --- a/archaeological_files/forms.py +++ b/archaeological_files/forms.py @@ -33,7 +33,7 @@ from django.utils.translation import ugettext_lazy as _  from django.utils.safestring import mark_safe  from ishtar_common.models import Person, PersonType, Town, Organization, \ -                         OrganizationType, valid_id, is_unique, DocumentTemplate +                         OrganizationType, valid_id, is_unique  from archaeological_operations.models import ActType, AdministrativeAct  import models  from ishtar_common.forms import FinalForm, FormSet, ClosingDateFormSelection, \ @@ -224,28 +224,6 @@ 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=[]) diff --git a/archaeological_files/urls.py b/archaeological_files/urls.py index 9d1f4f56f..bbac3a052 100644 --- a/archaeological_files/urls.py +++ b/archaeological_files/urls.py @@ -62,5 +62,5 @@ urlpatterns += patterns('archaeological_files.views',       url(r'dashboard_file/$', 'dashboard_file', name='dashboard-file'),       url(r'file_administrativeact_document/$',             'file_administrativeactfile_document', -           name='administrativeact_document'), +           name='file-administrativeact-document'),  ) diff --git a/archaeological_files/views.py b/archaeological_files/views.py index ae4c70f61..6ce194e52 100644 --- a/archaeological_files/views.py +++ b/archaeological_files/views.py @@ -35,7 +35,8 @@ from archaeological_operations.wizards import is_preventive  from wizards import *  from ishtar_common.forms_common import TownFormset -from archaeological_operations.forms import ParcelFormSet +from archaeological_operations.forms import ParcelFormSet, \ +                                            DocumentGenerationAdminActForm  from forms import *  from archaeological_operations.views import generatedoc_administrativeactop diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 52507d748..e52fef927 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -33,7 +33,8 @@ from django.template import RequestContext  from django.utils.translation import ugettext_lazy as _  from django.utils.safestring import mark_safe -from ishtar_common.models import valid_id, PersonType, Person, Town +from ishtar_common.models import valid_id, PersonType, Person, Town, \ +                                 DocumentTemplate  from archaeological_files.models import File  import models @@ -614,6 +615,28 @@ class FinalAdministrativeActDeleteForm(FinalForm):      confirm_msg = " "      confirm_end_msg = _(u"Would you like to delete this administrative act?") +class DocumentGenerationAdminActForm(forms.Form): +    _associated_model = models.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 GenerateDocForm(forms.Form):      form_label = _("Doc generation")      doc_generation = forms.ChoiceField(required=False, choices=[], diff --git a/archaeological_operations/ishtar_menu.py b/archaeological_operations/ishtar_menu.py index cd8ebc2d2..6015ae43a 100644 --- a/archaeological_operations/ishtar_menu.py +++ b/archaeological_operations/ishtar_menu.py @@ -65,6 +65,10 @@ MENU_SECTIONS = [                    model=models.AdministrativeAct,                    access_controls=['operation_deletion',                                     'delete_own_operation']), +                MenuItem('operation_administrativeact_document', +                         _(u"Documents"), +                  model=models.AdministrativeAct, +                  access_controls=['change_operation', 'change_own_operation']),                  ],),              SectionItem('operation_source', _(u"Documentation"),                  childs=[ diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py index 8ae835292..c85c05c88 100644 --- a/archaeological_operations/urls.py +++ b/archaeological_operations/urls.py @@ -80,4 +80,7 @@ urlpatterns += patterns('archaeological_operations.views',           name='dashboard-operation'),       url(r'autocomplete-patriarche/$', 'autocomplete_patriarche',             name='autocomplete-patriarche'), +     url(r'operation_administrativeact_document/$', +           'operation_administrativeactfile_document', +           name='operation-administrativeact-document'),  ) diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index 183c80b83..1ba994a86 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -284,3 +284,19 @@ def generatedoc_administrativeactop(request, pk, template_pk=None):                                                                  doc_name          return response      return HttpResponse(mimetype='text/plain') + +def operation_administrativeactfile_document(request): +    dct = {} +    if request.POST: +        dct['search_form'] = AdministrativeActOperationFormSelection( +                                                              request.POST) +        dct['template_form'] = DocumentGenerationAdminActForm(request.POST) +        if dct['search_form'].is_valid() and 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: +        dct['search_form'] = AdministrativeActOpeFormSelection() +        dct['template_form'] = DocumentGenerationAdminActForm() +    return render_to_response('ishtar/administrativeact_document.html', dct, +                              context_instance=RequestContext(request)) diff --git a/example_project/local_settings.py.sample b/example_project/local_settings.py.sample index 901c7d3a8..f8f0f3e75 100644 --- a/example_project/local_settings.py.sample +++ b/example_project/local_settings.py.sample @@ -23,9 +23,11 @@ DATABASES = {      },  } +BASE_URL = "http://mydomain/" +  ROOT_URLCONF = 'example_project.urls' -STATIC_URL = 'http://mydomain/static/' -MEDIA_URL = 'http://mydomain/media/' +STATIC_URL = BASE_URL + 'static/' +MEDIA_URL = BASE_URL + 'mydomain/media/'  DEBUG = False  DEBUG_TOOLBAR = False diff --git a/example_project/settings.py b/example_project/settings.py index 753c21a07..68ceab74b 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -17,11 +17,10 @@ THUMB_MAX_SIZE = (300, 300)  ROOT_PATH = os.path.abspath(os.path.curdir) + os.path.sep  STATIC_URL = '/static/'  STATIC_ROOT = ROOT_PATH + 'static/' +BASE_URL = ""  URL_PATH = "" -JQUERY_URL = "http://localhost/javascript/jquery/jquery.js" -JQUERY_UI_URL = "http://localhost/javascript/jquery-ui/" -XHTML2ODT_PATH = ROOT_PATH + "../xhtml2odt" +XHTML2ODT_PATH = "/usr/local/lib/"  ODT_TEMPLATE = ROOT_PATH + "../ishtar_common/static/template.odt" @@ -201,6 +200,12 @@ INSTALLED_APPS += EXTRA_APPS  INTERNAL_IPS = ('127.0.0.1',) +if 'JQUERY_URL' not in globals(): +    JQUERY_URL = BASE_URL + "javascript/jquery/jquery.js" +if 'JQUERY_UI_URL' not in globals(): +    JQUERY_UI_URL = BASE_URL + "javascript/jquery-ui/" + +  if DEBUG_TOOLBAR:      global DEBUG_TOOLBAR_PANELS      global DEBUG_TOOLBAR_CONFIG | 
