Projet

Général

Profil

0001-manager-use-dedicated-template-for-exception-deletio.patch

Frédéric Péters, 13 décembre 2019 16:14

Télécharger (5,08 ko)

Voir les différences:

Subject: [PATCH] manager: use dedicated template for exception deletion
 confirm page (#38511)

 .../chrono/manager_confirm_delete.html        |  4 ++--
 .../manager_confirm_exception_delete.html     | 19 +++++++++++++++++++
 chrono/manager/views.py                       |  2 +-
 tests/test_manager.py                         | 10 +++++-----
 4 files changed, 27 insertions(+), 8 deletions(-)
 create mode 100644 chrono/manager/templates/chrono/manager_confirm_exception_delete.html
chrono/manager/templates/chrono/manager_confirm_delete.html
2 2
{% load i18n %}
3 3

  
4 4
{% block appbar %}
5
<h2>{{ object }}</h2>
5
<h2>{{ view.model.get_verbose_name }}</h2>
6 6
{% endblock %}
7 7

  
8 8
{% block content %}
......
13 13
  {% blocktrans %}This cannot be removed as there are bookings for a future date.
14 14
  {% endblocktrans %}
15 15
  {% else %}
16
  {% blocktrans %}Are you sure you want to delete this exception?{% endblocktrans %}
16
  {% blocktrans %}Are you sure you want to delete this?{% endblocktrans %}
17 17
  {% endif %}
18 18
  </p>
19 19
  <div class="buttons">
chrono/manager/templates/chrono/manager_confirm_exception_delete.html
1
{% extends "chrono/manager_home.html" %}
2
{% load i18n %}
3

  
4
{% block appbar %}
5
<h2>{{ object }}</h2>
6
{% endblock %}
7

  
8
{% block content %}
9
<form method="post">
10
  {% csrf_token %}
11
  <p>
12
  {% blocktrans %}Are you sure you want to delete this exception?{% endblocktrans %}
13
  </p>
14
  <div class="buttons">
15
    <button class="delete-button" {% if cannot_delete %}disabled="disabled"{% endif %}>{% trans 'Delete' %}</button>
16
    <a class="cancel" href="{{ object.get_absolute_url }}">{% trans 'Cancel' %}</a>
17
  </div>
18
</form>
19
{% endblock %}
chrono/manager/views.py
782 782

  
783 783

  
784 784
class TimePeriodExceptionDeleteView(ManagedDeskSubobjectMixin, DeleteView):
785
    template_name = 'chrono/manager_confirm_delete.html'
785
    template_name = 'chrono/manager_confirm_exception_delete.html'
786 786
    model = TimePeriodException
787 787

  
788 788
    def get_success_url(self):
tests/test_manager.py
274 274
    resp = app.get('/manage/', status=200)
275 275
    resp = resp.click('Foo bar').follow()
276 276
    resp = resp.click('Delete')
277
    assert 'Are you sure you want to delete this exception?' in resp.text
277
    assert 'Are you sure you want to delete this?' in resp.text
278 278

  
279 279
    booking = Booking(event=event)
280 280
    booking.save()
......
288 288
    resp = app.get('/manage/', status=200)
289 289
    resp = resp.click('Foo bar').follow()
290 290
    resp = resp.click('Delete')
291
    assert 'Are you sure you want to delete this exception?' in resp.text
291
    assert 'Are you sure you want to delete this?' in resp.text
292 292

  
293 293
    # suddenly the booking is no longer cancelled, but the admin clicks on the
294 294
    # delete button.
......
324 324
    resp = resp.click('Settings')
325 325
    desk_page = resp.click('Desk A')
326 326
    desk_delete_page = desk_page.click('Delete')
327
    assert 'Are you sure you want to delete this exception?' in desk_delete_page.text
327
    assert 'Are you sure you want to delete this?' in desk_delete_page.text
328 328
    # make sure the deleting is not disabled
329 329
    assert 'disabled' not in desk_delete_page.text
330 330

  
......
514 514
    resp = app.get('/manage/agendas/%s/settings' % agenda.id, status=200)
515 515
    resp = resp.click(href=r'/manage/events/%s/$' % event.id)
516 516
    resp = resp.click('Delete')
517
    assert 'Are you sure you want to delete this exception?' in resp.text
517
    assert 'Are you sure you want to delete this?' in resp.text
518 518

  
519 519
    booking = Booking(event=event)
520 520
    booking.save()
......
528 528
    resp = app.get('/manage/agendas/%s/settings' % agenda.id, status=200)
529 529
    resp = resp.click(href=r'/manage/events/%s/$' % event.id)
530 530
    resp = resp.click('Delete')
531
    assert 'Are you sure you want to delete this exception?' in resp.text
531
    assert 'Are you sure you want to delete this?' in resp.text
532 532

  
533 533
    # suddenly the booking is no longer cancelled, but the admin clicks on the
534 534
    # delete button.
535
-