diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-12-05 14:21:37 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-12-05 14:21:37 +0100 | 
| commit | 329d91cd38d57d686d24f999c6a57f72662f9844 (patch) | |
| tree | 26c842f547666eb98f2a2e702a662c4e1bd23b57 | |
| parent | d44f0e3856295776a48f38ad3611ce3b0a899343 (diff) | |
| download | Ishtar-329d91cd38d57d686d24f999c6a57f72662f9844.tar.bz2 Ishtar-329d91cd38d57d686d24f999c6a57f72662f9844.zip | |
Document generation: no more specific action -> available on the sheet
| -rw-r--r-- | archaeological_files/ishtar_menu.py | 4 | ||||
| -rw-r--r-- | archaeological_finds/ishtar_menu.py | 8 | ||||
| -rw-r--r-- | archaeological_finds/templates/ishtar/blocks/window_find_nav.html | 6 | ||||
| -rw-r--r-- | archaeological_operations/ishtar_menu.py | 5 | ||||
| -rw-r--r-- | archaeological_operations/models.py | 10 | ||||
| -rw-r--r-- | archaeological_operations/views.py | 6 | ||||
| -rw-r--r-- | docs/fr/source/interface-administrateur.rst | 24 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/blocks/window_nav.html | 32 | ||||
| -rw-r--r-- | ishtar_common/templatetags/window_header.py | 7 | ||||
| -rw-r--r-- | ishtar_common/views.py | 2 | 
10 files changed, 61 insertions, 43 deletions
| diff --git a/archaeological_files/ishtar_menu.py b/archaeological_files/ishtar_menu.py index 21e59a6af..bd41f3782 100644 --- a/archaeological_files/ishtar_menu.py +++ b/archaeological_files/ishtar_menu.py @@ -73,10 +73,6 @@ MENU_SECTIONS = [                                _(u"Deletion"),                                model=AdministrativeAct,                                access_controls=['change_administrativeact']), -                     MenuItem('file_administrativeact_document', -                              _(u"Documents"), -                              model=AdministrativeAct, -                              access_controls=['change_administrativeact']),                   ],)]),),      (100,       SectionItem( diff --git a/archaeological_finds/ishtar_menu.py b/archaeological_finds/ishtar_menu.py index 48e12c79d..21a582a18 100644 --- a/archaeological_finds/ishtar_menu.py +++ b/archaeological_finds/ishtar_menu.py @@ -134,10 +134,6 @@ MENU_SECTIONS = [                                _(u"Deletion"),                                model=AdministrativeAct,                                access_controls=['change_administrativeact']), -                     MenuItem('treatmentfle_administrativeact_document', -                              _(u"Documents"), -                              model=AdministrativeAct, -                              access_controls=['change_administrativeact']),                   ]               ),           ] @@ -197,10 +193,6 @@ MENU_SECTIONS = [                                _(u"Deletion"),                                model=AdministrativeAct,                                access_controls=['change_administrativeact']), -                     MenuItem('treatment_administrativeact_document', -                              _(u"Documents"), -                              model=AdministrativeAct, -                              access_controls=['change_administrativeact']),                   ]),           ]       )), diff --git a/archaeological_finds/templates/ishtar/blocks/window_find_nav.html b/archaeological_finds/templates/ishtar/blocks/window_find_nav.html index 5ecaa35f0..74c6858a1 100644 --- a/archaeological_finds/templates/ishtar/blocks/window_find_nav.html +++ b/archaeological_finds/templates/ishtar/blocks/window_find_nav.html @@ -3,10 +3,12 @@  {% block post_pin %}{% if baskets %}  <div class="dropdown btn-secondary">    <button class="btn btn-sm btn-secondary dropdown-toggle" type="button" -          id="dropdownMenuButton" data-toggle="dropdown"aria-haspopup="true" aria-expanded="false"> +          id="dropdown-post-pin-{{window_id}}" +          data-toggle="dropdown"aria-haspopup="true" +          aria-expanded="false">      <i class="fa fa-shopping-basket"></i> {% trans "Baskets" %}    </button> -  <div class="dropdown-menu" aria-labelledby="dropdownMenuButton"> +  <div class="dropdown-menu" aria-labelledby="dropdown-post-pin-{{window_id}}">      {% for basket_id, lbl in baskets %}        <a class="dropdown-item" href="#"           onclick="load_window('{% url 'show-findbasket' basket_id %}')"> diff --git a/archaeological_operations/ishtar_menu.py b/archaeological_operations/ishtar_menu.py index 4baf14295..bfc027573 100644 --- a/archaeological_operations/ishtar_menu.py +++ b/archaeological_operations/ishtar_menu.py @@ -82,11 +82,6 @@ MENU_SECTIONS = [                          _(u"Deletion"),                          model=models.AdministrativeAct,                          access_controls=['change_administrativeact']), -                    MenuItem( -                        'operation_administrativeact_document', -                        _(u"Documents"), -                        model=models.AdministrativeAct, -                        access_controls=['change_administrativeact']),                  ],),          ]),       ), diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index a0d0ba30b..d1a8b5875 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -1866,6 +1866,16 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):          if self.treatment_file:              return self.treatment_file +    def get_extra_templates(self, request): +        templates = [] +        for template in self.act_type.associated_template.all(): +            urlname = "generatedoc-administrativeactop" +            templates.append( +                (template.name, reverse( +                    urlname, args=[self.pk, template.pk])) +            ) +        return templates +      def get_filename(self):          filename = self.related_item.associated_filename          filename = u"-".join(filename.split('-')[:-1])  # remove date diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index 48d7c4a4f..5ece22073 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -467,10 +467,8 @@ administrativact_register_wizard = SearchWizard.as_view([  def generatedoc_administrativeactop(request, pk, template_pk=None): -    if (not request.user.has_perm( -            'ishtar_common.view_operation', models.Operation) -        and not request.user.has_perm( -            'ishtar_common.view_own_operation', models.Operation)): +    if not request.user.has_perm('view_administrativeact', +                                 models.AdministrativeAct):          return HttpResponse(content_type='text/plain')      try:          act_file = models.AdministrativeAct.objects.get(pk=pk) diff --git a/docs/fr/source/interface-administrateur.rst b/docs/fr/source/interface-administrateur.rst index 73e790441..a77ff605d 100644 --- a/docs/fr/source/interface-administrateur.rst +++ b/docs/fr/source/interface-administrateur.rst @@ -208,6 +208,18 @@ Une fois quelques substitutions faites, on peut l'enregistrer et créer le patro  Notions avancées  **************** +Conditions +++++++++++ + +Des structures conditionnelles peuvent être mise en place. Cela permet notamment de tester si une valeur a été renseignée et de permettre de contextualiser l'affichage en fonction de cela. Exemple : :: + +        Ce traitement sous +        {% if responsable %}la responsabilité de {{responsable}} +        {% else %}une responsabilité à définir +        {% endif %} se tiendra... + +Les structures conditionnelles se structurent autour des mots clés ``if``, ``else`` et ``endif``. On utilise ``{%`` et ``%}`` autour de ces mots clés. La section ``else`` est facultative. +  Attributs  +++++++++ @@ -225,18 +237,6 @@ Certaines clés peuvent parfois renvoyer à des listes d'éléments, chacun ayan  Cela se structure autour des mots clés ``for``, ``in`` et ``endfor``. Au lieu de doubles accolades, ``{%`` et ``%}`` encadrent ces mots clés. -Conditions -++++++++++ - -Des structures conditionnelles peuvent être mise en place. Cela permet notamment de tester si une valeur a été renseignée et de permettre de contextualiser l'affichage en fonction de cela. Exemple : :: - -        Ce traitement sous -        {% if responsable %}la responsabilité de {{responsable}} -        {% else %}une responsabilité à définir -        {% endif %} se tiendra... - -Les structures conditionnelles se structurent autour des mots clés ``if``, ``else`` et ``endif``. On utilise ``{%`` et ``%}`` autour de ces mots clés. La section ``else`` est facultative. -  ..     Images    ++++++ diff --git a/ishtar_common/templates/ishtar/blocks/window_nav.html b/ishtar_common/templates/ishtar/blocks/window_nav.html index 90d58d605..62caff142 100644 --- a/ishtar_common/templates/ishtar/blocks/window_nav.html +++ b/ishtar_common/templates/ishtar/blocks/window_nav.html @@ -57,15 +57,33 @@          </a>          {% endfor %}        </div> +        <div class="btn-group btn-group-sm" role="group"             aria-label="{% trans 'Export' %}"> -          <a class="btn btn-secondary" href='{% url show_url item.pk "odt" %}' -             title='{% trans "Export as OpenOffice.org file"%}'> -              ODT <i class="fa fa-file-word-o" aria-hidden="true"></i> -          <a class="btn btn-secondary" href='{% url show_url item.pk "pdf" %}' -             title='{% trans "Export as PDF file"%}'> -              PDF <i class="fa fa-file-pdf-o" aria-hidden="true"></i> -          </a> +          <div class="dropdown btn-secondary"> +              <button class="btn btn-sm btn-secondary dropdown-toggle" type="button" +                      id="dropdown-sheet-export-{{window_id}}" +                      data-toggle="dropdown"aria-haspopup="true" +                      aria-expanded="false"> +                  <i class="fa fa-file-word-o"></i> {% trans "Export" %} +              </button> +              <div class="dropdown-menu" +                   aria-labelledby="dropdown-sheet-export-{{window_id}}"> +                  <a class="dropdown-item" href='{% url show_url item.pk "odt" %}' +                     title='{% trans "Export as OpenOffice.org file"%}'> +                      ODT <i class="fa fa-file-word-o" aria-hidden="true"></i> +                  </a> +                  <a class="dropdown-item" href='{% url show_url item.pk "pdf" %}' +                     title='{% trans "Export as PDF file"%}'> +                      PDF <i class="fa fa-file-pdf-o" aria-hidden="true"></i> +                  </a>{% for template_name, template_url in extra_templates %} +                  <a class="dropdown-item" href='{{template_url}}'> +                      {{template_name}} <i class="fa fa-file-word-o" aria-hidden="true"></i> +                  </a>{% endfor %} +              </div> +          </div> + +        </div>    </div>  </div> diff --git a/ishtar_common/templatetags/window_header.py b/ishtar_common/templatetags/window_header.py index e6325d3fb..bbd923d41 100644 --- a/ishtar_common/templatetags/window_header.py +++ b/ishtar_common/templatetags/window_header.py @@ -10,6 +10,9 @@ def window_nav(context, item, window_id, show_url, modify_url='', histo_url='',      extra_actions = []      if hasattr(item, 'get_extra_actions'):          extra_actions = item.get_extra_actions(context['request']) +    extra_templates = [] +    if hasattr(item, 'get_extra_templates'): +        extra_templates = item.get_extra_templates(context['request'])      slug = None      if hasattr(item, "LONG_SLUG"): @@ -29,7 +32,9 @@ def window_nav(context, item, window_id, show_url, modify_url='', histo_url='',          'previous': previous,          'next': nxt,          'extra_actions': extra_actions, -        'pin_action': pin_action} +        'pin_action': pin_action, +        'extra_templates': extra_templates, +    }  @register.inclusion_tag('ishtar/blocks/window_find_nav.html', diff --git a/ishtar_common/views.py b/ishtar_common/views.py index bc9c9432a..f23116d21 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -2001,3 +2001,5 @@ class QAItemEditForm(QAItemForm):      def form_save(self, form):          form.save(self.items, self.request.user)          return HttpResponseRedirect(reverse("success")) + + | 
