Projet

Général

Profil

0001-workflows-add-bottom-of-page-position-choice-for-ale.patch

au cas où. - Frédéric Péters, 21 février 2018 13:37

Télécharger (4,57 ko)

Voir les différences:

Subject: [PATCH] workflows: add "bottom of page" position choice for alerts
 (#22034)

 tests/test_backoffice_pages.py         | 6 ++++++
 tests/test_form_pages.py               | 9 +++++++++
 wcs/forms/common.py                    | 5 +++++
 wcs/templates/wcs/formdata_status.html | 1 +
 wcs/workflows.py                       | 8 ++++++--
 5 files changed, 27 insertions(+), 2 deletions(-)
tests/test_backoffice_pages.py
3940 3940
    assert 'message-to-submitter' not in resp.body
3941 3941
    assert 'message-to-receiver' in resp.body
3942 3942

  
3943
    # display first message at the bottom of the page
3944
    display1.position = 'bottom'
3945
    workflow.store()
3946
    resp = app.get(formdata.get_url(backoffice=True))
3947
    assert resp.body.index('message-to-all') > resp.body.index('message-to-receiver')
3948

  
3943 3949
    # display first message on top of actions
3944 3950
    display1.position = 'actions'
3945 3951
    workflow.store()
tests/test_form_pages.py
3562 3562
    assert 'message-to-submitter' not in page.body
3563 3563
    assert 'message-to-xxx-and-submitter' in page.body
3564 3564

  
3565
    # change to always display at the bottom
3566
    display2.position = 'bottom'
3567
    workflow.store()
3568
    page = app.get(formdata.get_url())
3569
    assert 'message-to-all' in page.body
3570
    assert 'message-to-submitter' in page.body
3571
    assert 'message-to-xxx-and-submitter' in page.body
3572
    assert page.body.index('message-to-submitter') > page.body.index('message-to-xxx-and-submitter')
3573

  
3565 3574
def test_session_cookie_flags(pub):
3566 3575
    formdef = create_formdef()
3567 3576
    app = get_app(pub)
wcs/forms/common.py
187 187
    def actions_workflow_messages(self):
188 188
        return self.workflow_messages(position='actions')
189 189

  
190
    def bottom_workflow_messages(self):
191
        return self.workflow_messages(position='bottom')
192

  
190 193
    def recorded_message(self):
191 194
        r = TemplateIO(html=True)
192 195
        # behaviour if workflow doesn't display any message
......
467 470

  
468 471
        r += self.history()
469 472

  
473
        r += htmltext(self.bottom_workflow_messages())
474

  
470 475
        locked = False
471 476
        if form:
472 477
            all_visitors = get_publisher().get_object_visitors(object_key)
wcs/templates/wcs/formdata_status.html
21 21

  
22 22
{{ view.receipt|safe }}
23 23
{{ view.history|safe }}
24
{{ view.bottom_workflow_messages|safe }}
24 25
{% if workflow_form %}
25 26
  {{ view.actions_workflow_messages|safe }}
26 27
  {{ workflow_form.render|safe }}
wcs/workflows.py
2404 2404
        parts = []
2405 2405
        if self.position == 'top':
2406 2406
            parts.append(_('top of page'))
2407
        elif self.position == 'bottom':
2408
            parts.append(_('bottom of page'))
2407 2409
        elif self.position == 'actions':
2408
            parts.append(_('top of actions'))
2410
            parts.append(_('with actions'))
2409 2411
        if self.to:
2410 2412
            parts.append(_('for %s') % self.render_list_of_roles(self.to))
2411 2413
        return ', '.join(parts)
......
2448 2450
        if 'position' in parameters:
2449 2451
            form.add(SingleSelectWidget, '%sposition' % prefix, title=_('Position'),
2450 2452
                value=self.position,
2451
                options=[('top', _('Top of page')), ('actions', _('Top of actions'))])
2453
                options=[('top', _('Top of page')),
2454
                         ('bottom', _('Bottom of page')),
2455
                         ('actions', _('With actions'))])
2452 2456
        if 'to' in parameters:
2453 2457
            form.add(WidgetList, '%sto' % prefix, title=_('To'),
2454 2458
                     element_type=SingleSelectWidget,
2455
-