diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-12-14 23:52:13 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-12-14 23:52:13 +0100 |
commit | dd005db8c38c1139c33a5f3b8b9e3e1556b28b38 (patch) | |
tree | e702a5e335c4366a1e27499a4db51e31b7f5c7b7 /archaeological_files | |
parent | c6f301b76291d2f416f6a641fe92b03cd10076a7 (diff) | |
parent | b3c5ce577b925da4022f21ccdf8d138486557450 (diff) | |
download | Ishtar-dd005db8c38c1139c33a5f3b8b9e3e1556b28b38.tar.bz2 Ishtar-dd005db8c38c1139c33a5f3b8b9e3e1556b28b38.zip |
Merge branch 'master' of lysithea.proxience.net:/home/proxience/git/ishtar
Diffstat (limited to 'archaeological_files')
-rw-r--r-- | archaeological_files/forms.py | 22 | ||||
-rw-r--r-- | archaeological_files/locale/fr/LC_MESSAGES/django.po | 56 | ||||
-rw-r--r-- | archaeological_files/templates/ishtar/administrativeact_document.html | 4 | ||||
-rw-r--r-- | archaeological_files/views.py | 25 |
4 files changed, 43 insertions, 64 deletions
diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py index ec9409ef6..a4a20938b 100644 --- a/archaeological_files/forms.py +++ b/archaeological_files/forms.py @@ -194,28 +194,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/locale/fr/LC_MESSAGES/django.po b/archaeological_files/locale/fr/LC_MESSAGES/django.po index 0dda70bec..46c24adbb 100644 --- a/archaeological_files/locale/fr/LC_MESSAGES/django.po +++ b/archaeological_files/locale/fr/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: alpha\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-10-28 20:04+0100\n" +"POT-Creation-Date: 2013-12-02 20:32+0100\n" "PO-Revision-Date: 2010-12-09\n" "Last-Translator: Étienne Loks <etienne.loks at peacefrogs net>\n" "Language-Team: \n" @@ -133,15 +133,19 @@ msgstr "Surface totale aménagée (m²)" msgid "Reception date" msgstr "Date de réception" -#: forms.py:191 +#: forms.py:190 msgid "Would you like to close this archaeological file?" msgstr "Voulez vous clore ce dossier archéologique ?" -#: forms.py:196 +#: forms.py:194 msgid "Would you like to delete this archaelogical file ?" msgstr "Voulez vous supprimer ce dossier archéologique ?" -#: forms.py:200 forms.py:217 +#: forms.py:198 +msgid "Template" +msgstr "Patron" + +#: forms.py:220 forms.py:237 msgid "Act type" msgstr "Type d'acte" @@ -177,15 +181,19 @@ msgstr "Acte administratif" msgid "Add" msgstr "Ajout" -#: ishtar_menu.py:66 +#: ishtar_menu.py:64 +msgid "Documents" +msgstr "Documents" + +#: ishtar_menu.py:70 msgid "Dashboard" msgstr "Tableau de bord" -#: ishtar_menu.py:68 +#: ishtar_menu.py:72 msgid "General informations" msgstr "Informations générales" -#: ishtar_menu.py:71 models.py:115 +#: ishtar_menu.py:75 models.py:115 #: templates/ishtar/dashboards/dashboard_file.html:8 msgid "Archaeological files" msgstr "Dossiers archéologiques" @@ -246,47 +254,47 @@ msgstr "Peut supprimer son propre Dossier archéologique" msgid "FILE" msgstr "DOSSIER" -#: models.py:168 +#: models.py:176 msgid "Intercommunal" msgstr "Intercommunal" -#: models.py:224 +#: models.py:232 msgid "File" msgstr "Dossier" -#: models.py:225 +#: models.py:233 msgid "Department" msgstr "Département" -#: views.py:87 +#: views.py:89 msgid "File search" msgstr "Recherche de dossier archéologique" -#: views.py:96 +#: views.py:98 msgid "New file" msgstr "Nouveau dossier archéologique" -#: views.py:111 +#: views.py:113 msgid "File modification" msgstr "Modification de dossier archéologique" -#: views.py:122 +#: views.py:124 msgid "File closing" msgstr "Clotûre de dossier" -#: views.py:129 +#: views.py:131 msgid "File deletion" msgstr "Suppression de dossier archéologique" -#: views.py:137 +#: views.py:139 msgid "File: new administrative act" msgstr "Dossier archéologique : nouvel acte administratif" -#: views.py:147 +#: views.py:149 msgid "File: administrative act modification" msgstr "Dossier archéologique : modification d'acte administratif" -#: views.py:156 +#: views.py:158 msgid "File: administrative act deletion" msgstr "Dossier archéologique : suppression acte administratif" @@ -294,6 +302,18 @@ msgstr "Dossier archéologique : suppression acte administratif" msgid "Associated operations" msgstr "Opérations associées" +#: templates/ishtar/administrativeact_document.html:9 +msgid "Document generation" +msgstr "Génération de document" + +#: templates/ishtar/administrativeact_document.html:15 +msgid "Choose the type of document" +msgstr "Choisir le type de document" + +#: templates/ishtar/administrativeact_document.html:19 +msgid "Generate" +msgstr "Générer" + #: templates/ishtar/sheet_file.html:13 msgid "Previous version" msgstr "Version précédente" diff --git a/archaeological_files/templates/ishtar/administrativeact_document.html b/archaeological_files/templates/ishtar/administrativeact_document.html index cdb2b45be..8c08519de 100644 --- a/archaeological_files/templates/ishtar/administrativeact_document.html +++ b/archaeological_files/templates/ishtar/administrativeact_document.html @@ -12,10 +12,6 @@ <table> {{ search_form.as_table }} </table> -<h4>{% trans "Choose the type of document" %}</h4> -<table> -{{ template_form }} -</table> <input type="submit" id="submit_form" name='validate' value="{% trans "Generate" %}"/> </div> </form> diff --git a/archaeological_files/views.py b/archaeological_files/views.py index e55368e62..699335a56 100644 --- a/archaeological_files/views.py +++ b/archaeological_files/views.py @@ -18,12 +18,10 @@ # See the file COPYING for details. import json -import os from django.db.models import Q from django.http import HttpResponse from django.shortcuts import render_to_response -from django.template.defaultfilters import slugify from django.utils.translation import ugettext_lazy as _ from ishtar_common.views import get_item, show_item, revert_item @@ -36,6 +34,8 @@ from ishtar_common.forms_common import TownFormset from archaeological_operations.forms import ParcelFormSet from forms import * +from archaeological_operations.views import generatedoc_administrativeactop + def autocomplete_file(request): if not request.user.has_perm('ishtar_common.view_file', models.File) and \ not request.user.has_perm('ishtar_common.view_own_file', models.File) \ @@ -162,25 +162,10 @@ def file_administrativeactfile_document(request): dct = {} if request.POST: dct['search_form'] = AdministrativeActFileFormSelection(request.POST) - dct['template_form'] = DocumentGenerationAdminActForm(request.POST) - if dct['search_form'].is_valid() and dct['template_form'].is_valid(): - doc = dct['template_form'].save( - dct['search_form'].cleaned_data.get('pk')) - if doc: - MIMES = {'odt':'application/vnd.oasis.opendocument.text', - 'ods':'application/vnd.oasis.opendocument.spreadsheet'} - ext = doc.split('.')[-1] - doc_name = slugify(doc.split(os.path.sep)[-1][:-len(ext)])+ "."\ - + ext - mimetype = 'text/csv' - if ext in MIMES: - mimetype = MIMES[ext] - response = HttpResponse(open(doc), mimetype=mimetype) - response['Content-Disposition'] = 'attachment; filename=%s' % \ - doc_name - return response + if dct['search_form'].is_valid(): + return generatedoc_administrativeactop(request, + dct['search_form'].cleaned_data.get('pk')) else: dct['search_form'] = AdministrativeActFileFormSelection() - dct['template_form'] = DocumentGenerationAdminActForm() return render_to_response('ishtar/administrativeact_document.html', dct, context_instance=RequestContext(request)) |