Projet

Général

Profil

0001-wcs-add-message-for-empty-states-in-drafts-forms-cel.patch

Frédéric Péters, 18 mars 2020 20:04

Télécharger (4,31 ko)

Voir les différences:

Subject: [PATCH] wcs: add message for empty states in drafts/forms cells
 (#13974)

 .../templates/combo/wcs/current_drafts.html   |  1 +
 .../templates/combo/wcs/current_forms.html    |  1 +
 .../templates/combo/wcs/user_all_forms.html   |  1 +
 .../templates/combo/wcs/user_done_forms.html  |  1 +
 tests/test_wcs.py                             | 19 +++++++++++++++++++
 5 files changed, 23 insertions(+)
combo/apps/wcs/templates/combo/wcs/current_drafts.html
17 17
  {% endif %}
18 18
</div>
19 19
{% endfor %}
20
{% if not drafts %}<div class="empty-message"><p>{% trans "There are no current drafts." %}</p></div>{% endif %}
20 21
{% include "combo/pagination.html" %}
21 22
{% endblock %}
combo/apps/wcs/templates/combo/wcs/current_forms.html
6 6
  {% include "combo/wcs/list_of_forms.html" with forms=forms %}
7 7
  </div>
8 8
{% endfor %}
9
{% if not forms %}<div class="empty-message"><p>{% trans "There are no current forms." %}</p></div>{% endif %}
9 10
{% include "combo/pagination.html" %}
10 11
{% endblock %}
combo/apps/wcs/templates/combo/wcs/user_all_forms.html
6 6
  {% include "combo/wcs/list_of_forms.html" with forms=forms %}
7 7
  </div>
8 8
{% endfor %}
9
{% if not forms %}<div class="empty-message"><p>{% trans "There are no forms." %}</p></div>{% endif %}
9 10
{% include "combo/pagination.html" %}
10 11
{% endblock %}
combo/apps/wcs/templates/combo/wcs/user_done_forms.html
6 6
  {% include "combo/wcs/list_of_forms.html" with forms=forms %}
7 7
  </div>
8 8
{% endfor %}
9
{% if not forms %}<div class="empty-message"><p>{% trans "There are no done forms or they have been removed." %}</p></div>{% endif %}
9 10
{% include "combo/pagination.html" %}
10 11
{% endblock %}
tests/test_wcs.py
495 495
        cell.get_cell_extra_context(context)
496 496
    assert requests_get.call_args_list[0][0][0] == '/api/user/forms?limit=100&sort=desc&include-drafts=on'
497 497

  
498
    # check empty messages
499
    cell.categories = {'data': ['default:test-3']}
500
    cell.current_forms = True
501
    cell.done_forms = False
502
    cell.include_drafts = False
503
    result = cell.render(context)
504
    assert 'There are no current forms.' in result
505
    cell.done_forms = True
506
    result = cell.render(context)
507
    assert 'There are no forms.' in result
508
    cell.current_forms = False
509
    result = cell.render(context)
510
    assert 'There are no done forms' in result
511

  
498 512

  
499 513
@wcs_present
500 514
def test_current_forms_cell_validity(context):
......
814 828
    result = cell.render(context)
815 829
    assert not 'http://127.0.0.1:8999/third-form-title' in result # no form
816 830

  
831

  
817 832
@wcs_present
818 833
def test_current_drafts_cell_render_logged_in(context):
819 834
    page = Page(title='xxx', slug='test_current_drafts_cell_render', template_name='standard')
......
844 859
    extra_context = cell.get_cell_extra_context(context)
845 860
    assert len(extra_context['drafts']) == 0
846 861

  
862
    # check empty message
863
    result = cell.render(context)
864
    assert 'There are no current drafts.' in result
865

  
847 866

  
848 867
@wcs_present
849 868
def test_current_drafts_cell_check_validity(context):
850
-