0002-time-exceptions-paginated-list-of-exceptions-19033.patch
chrono/manager/templates/chrono/manager_agenda_settings.html | ||
---|---|---|
3 | 3 | |
4 | 4 |
{% block breadcrumb %} |
5 | 5 |
{{ block.super }} |
6 |
{% if desk %} |
|
7 |
<a href="{% url 'chrono-manager-agenda-settings' desk.agenda_id %}">{% trans "Settings" %}</a> |
|
8 |
{% else %} |
|
6 | 9 |
<a href=".">{% trans "Settings" %}</a> |
10 |
{% endif %} |
|
7 | 11 |
{% endblock %} |
8 | 12 | |
9 | 13 |
{% block appbar %} |
... | ... | |
144 | 148 |
{% if user_can_manage %}<a rel="popup" class="delete" href="{% url 'chrono-manager-time-period-exception-delete' pk=exception.id %}">{% trans "remove" %}</a>{% endif %} |
145 | 149 |
{% endfor %} |
146 | 150 |
{% if not desk.are_all_exceptions_displayed %} |
147 |
<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> |
|
151 |
<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>
|
|
148 | 152 |
{% endif %} |
149 | 153 |
<li><a class="add" rel="popup" href="{{add_time_period_exception_url}}">{% trans 'Add a time period exception' %}</a></li> |
150 | 154 |
{% endif %} |
chrono/manager/templates/chrono/manager_time_period_exception_list.html | ||
---|---|---|
1 |
{% extends "chrono/manager_desk_form.html" %}
|
|
1 |
{% extends "chrono/manager_agenda_settings.html" %}
|
|
2 | 2 |
{% load i18n %} |
3 | 3 | |
4 | 4 |
{% block extrascripts %} |
... | ... | |
8 | 8 | |
9 | 9 |
{% block breadcrumb %} |
10 | 10 |
{{ block.super }} |
11 |
{% if desk %} |
|
12 |
<a href="{% url 'chrono-manager-agenda-view' pk=desk.agenda.id %}">{{desk.label}}</a> |
|
13 |
{% endif %} |
|
11 |
<a href=".">{% trans "All exceptions" %}</a> |
|
14 | 12 |
{% endblock %} |
15 | 13 | |
16 | 14 |
{% block appbar %} |
... | ... | |
26 | 24 |
</li> |
27 | 25 |
{% endfor %} |
28 | 26 |
</ul> |
27 | ||
28 |
{% if not page_obj %} |
|
29 |
<p><a href="{% url 'chrono-manager-time-period-exception-list' desk.pk %}">{% trans "Show more..." %}</a></p> |
|
30 |
{% endif %} |
|
31 | ||
32 |
{% include "gadjo/pagination.html" %} |
|
29 | 33 |
</div> |
30 | 34 |
{% endblock %} |
chrono/manager/urls.py | ||
---|---|---|
76 | 76 |
name='chrono-manager-time-period-exception-edit'), |
77 | 77 |
url(r'^time-period-exceptions/(?P<pk>\d+)/delete$', views.time_period_exception_delete, |
78 | 78 |
name='chrono-manager-time-period-exception-delete'), |
79 |
url(r'^time-period-exceptions/(?P<pk>\d+)/exception-extract-list$', views.time_period_exception_extract_list, |
|
80 |
name='chrono-manager-time-period-exception-extract-list'), |
|
79 | 81 |
url(r'^time-period-exceptions/(?P<pk>\d+)/exception-list$', views.time_period_exception_list, |
80 | 82 |
name='chrono-manager-time-period-exception-list'), |
81 | 83 |
chrono/manager/views.py | ||
---|---|---|
746 | 746 |
class TimePeriodExceptionListView(ManagedDeskMixin, ListView): |
747 | 747 |
template_name = 'chrono/manager_time_period_exception_list.html' |
748 | 748 |
model = TimePeriodException |
749 |
paginate_by = 20 |
|
749 | 750 | |
750 | 751 |
def get_queryset(self): |
751 | 752 |
return self.model.objects.filter(desk=self.desk, end_datetime__gte=now()) |
... | ... | |
759 | 760 |
time_period_exception_list = TimePeriodExceptionListView.as_view() |
760 | 761 | |
761 | 762 | |
763 |
class TimePeriodExceptionExtractListView(TimePeriodExceptionListView): |
|
764 |
paginate_by = None # no pagination |
|
765 | ||
766 |
def get_queryset(self): |
|
767 |
# but limit queryset |
|
768 |
return super(TimePeriodExceptionExtractListView, self).get_queryset()[:10] |
|
769 | ||
770 | ||
771 |
time_period_exception_extract_list = TimePeriodExceptionExtractListView.as_view() |
|
772 | ||
773 | ||
762 | 774 |
class TimePeriodExceptionDeleteView(ManagedDeskSubobjectMixin, DeleteView): |
763 | 775 |
template_name = 'chrono/manager_confirm_delete.html' |
764 | 776 |
model = TimePeriodException |
tests/test_manager.py | ||
---|---|---|
909 | 909 |
assert TimePeriodException.objects.count() == 2 |
910 | 910 |
assert 'Exception 1' in resp.text |
911 | 911 |
assert 'Exception 2' not in resp.text |
912 |
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-list" % agenda.desk_set.first().pk) |
|
912 |
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-extract-list" % agenda.desk_set.first().pk)
|
|
913 | 913 |
assert 'Exception 1' in resp.text |
914 | 914 |
assert 'Exception 2' in resp.text |
915 | 915 | |
... | ... | |
1040 | 1040 |
assert '/manage/time-period-exceptions/%d/edit' % current_exception.pk in resp.text |
1041 | 1041 |
assert '/manage/time-period-exceptions/%d/edit' % future_exception.pk in resp.text |
1042 | 1042 | |
1043 |
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-extract-list" % desk.pk) |
|
1044 |
assert '/manage/time-period-exceptions/%d/edit' % past_exception.pk not in resp.text |
|
1045 |
assert '/manage/time-period-exceptions/%d/edit' % current_exception.pk in resp.text |
|
1046 |
assert '/manage/time-period-exceptions/%d/edit' % future_exception.pk in resp.text |
|
1047 | ||
1043 | 1048 |
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-list" % desk.pk) |
1044 | 1049 |
assert '/manage/time-period-exceptions/%d/edit' % past_exception.pk not in resp.text |
1045 | 1050 |
assert '/manage/time-period-exceptions/%d/edit' % current_exception.pk in resp.text |
1046 |
- |