time exceptions: paginated list of exceptions (#19033)
This commit is contained in:
parent
b5ef493d77
commit
c6f418dd8e
|
@ -3,7 +3,11 @@
|
|||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
{% if desk %}
|
||||
<a href="{% url 'chrono-manager-agenda-settings' desk.agenda_id %}">{% trans "Settings" %}</a>
|
||||
{% else %}
|
||||
<a href=".">{% trans "Settings" %}</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar %}
|
||||
|
@ -144,7 +148,7 @@
|
|||
{% if user_can_manage %}<a rel="popup" class="delete" href="{% url 'chrono-manager-time-period-exception-delete' pk=exception.id %}">{% trans "remove" %}</a>{% endif %}
|
||||
{% endfor %}
|
||||
{% if not desk.are_all_exceptions_displayed %}
|
||||
<li><a class="timeperiod-exception-all" rel="popup" data-selector="div.timeperiod" href="{% url 'chrono-manager-time-period-exception-list' pk=desk.id %}">({% trans 'see all exceptions' %})</a></li>
|
||||
<li><a class="timeperiod-exception-all" rel="popup" data-selector="div.timeperiod" href="{% url 'chrono-manager-time-period-exception-extract-list' pk=desk.id %}">({% trans 'see all exceptions' %})</a></li>
|
||||
{% endif %}
|
||||
<li><a class="add" rel="popup" href="{{add_time_period_exception_url}}">{% trans 'Add a time period exception' %}</a></li>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "chrono/manager_desk_form.html" %}
|
||||
{% extends "chrono/manager_agenda_settings.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block extrascripts %}
|
||||
|
@ -8,9 +8,7 @@
|
|||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
{% if desk %}
|
||||
<a href="{% url 'chrono-manager-agenda-view' pk=desk.agenda.id %}">{{desk.label}}</a>
|
||||
{% endif %}
|
||||
<a href=".">{% trans "All exceptions" %}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar %}
|
||||
|
@ -26,5 +24,11 @@
|
|||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% if not page_obj %}
|
||||
<p><a href="{% url 'chrono-manager-time-period-exception-list' desk.pk %}">{% trans "Show more..." %}</a></p>
|
||||
{% endif %}
|
||||
|
||||
{% include "gadjo/pagination.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -76,6 +76,8 @@ urlpatterns = [
|
|||
name='chrono-manager-time-period-exception-edit'),
|
||||
url(r'^time-period-exceptions/(?P<pk>\d+)/delete$', views.time_period_exception_delete,
|
||||
name='chrono-manager-time-period-exception-delete'),
|
||||
url(r'^time-period-exceptions/(?P<pk>\d+)/exception-extract-list$', views.time_period_exception_extract_list,
|
||||
name='chrono-manager-time-period-exception-extract-list'),
|
||||
url(r'^time-period-exceptions/(?P<pk>\d+)/exception-list$', views.time_period_exception_list,
|
||||
name='chrono-manager-time-period-exception-list'),
|
||||
|
||||
|
|
|
@ -747,6 +747,7 @@ time_period_exception_edit = TimePeriodExceptionEditView.as_view()
|
|||
class TimePeriodExceptionListView(ManagedDeskMixin, ListView):
|
||||
template_name = 'chrono/manager_time_period_exception_list.html'
|
||||
model = TimePeriodException
|
||||
paginate_by = 20
|
||||
|
||||
def get_queryset(self):
|
||||
return self.model.objects.filter(desk=self.desk, end_datetime__gte=now())
|
||||
|
@ -760,6 +761,17 @@ class TimePeriodExceptionListView(ManagedDeskMixin, ListView):
|
|||
time_period_exception_list = TimePeriodExceptionListView.as_view()
|
||||
|
||||
|
||||
class TimePeriodExceptionExtractListView(TimePeriodExceptionListView):
|
||||
paginate_by = None # no pagination
|
||||
|
||||
def get_queryset(self):
|
||||
# but limit queryset
|
||||
return super(TimePeriodExceptionExtractListView, self).get_queryset()[:10]
|
||||
|
||||
|
||||
time_period_exception_extract_list = TimePeriodExceptionExtractListView.as_view()
|
||||
|
||||
|
||||
class TimePeriodExceptionDeleteView(ManagedDeskSubobjectMixin, DeleteView):
|
||||
template_name = 'chrono/manager_confirm_delete.html'
|
||||
model = TimePeriodException
|
||||
|
|
|
@ -926,7 +926,7 @@ def test_meetings_agenda_add_time_period_exception(app, admin_user):
|
|||
assert TimePeriodException.objects.count() == 2
|
||||
assert 'Exception 1' in resp.text
|
||||
assert 'Exception 2' not in resp.text
|
||||
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-list" % agenda.desk_set.first().pk)
|
||||
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-extract-list" % agenda.desk_set.first().pk)
|
||||
assert 'Exception 1' in resp.text
|
||||
assert 'Exception 2' in resp.text
|
||||
|
||||
|
@ -1057,6 +1057,11 @@ def test_exception_list(app, admin_user):
|
|||
assert '/manage/time-period-exceptions/%d/edit' % current_exception.pk in resp.text
|
||||
assert '/manage/time-period-exceptions/%d/edit' % future_exception.pk in resp.text
|
||||
|
||||
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-extract-list" % desk.pk)
|
||||
assert '/manage/time-period-exceptions/%d/edit' % past_exception.pk not in resp.text
|
||||
assert '/manage/time-period-exceptions/%d/edit' % current_exception.pk in resp.text
|
||||
assert '/manage/time-period-exceptions/%d/edit' % future_exception.pk in resp.text
|
||||
|
||||
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-list" % desk.pk)
|
||||
assert '/manage/time-period-exceptions/%d/edit' % past_exception.pk not in resp.text
|
||||
assert '/manage/time-period-exceptions/%d/edit' % current_exception.pk in resp.text
|
||||
|
|
Loading…
Reference in New Issue