mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 00:07:22 +00:00
Merge pull request #114 from DanielGrams/issue/113-pagination
Pagination with more info #113
This commit is contained in:
commit
953feb4d4f
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -19,5 +19,8 @@
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports": true
|
||||
}
|
||||
},
|
||||
"[html]": {
|
||||
"editor.formatOnSave": false
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,12 @@
|
||||
from datetime import datetime
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from sqlalchemy import and_, func, or_
|
||||
from sqlalchemy.orm import contains_eager, defaultload, joinedload
|
||||
from sqlalchemy.sql import extract
|
||||
|
||||
from project import db
|
||||
from project.dateutils import date_add_time, dates_from_recurrence_rule, today
|
||||
from project.dateutils import date_add_time, dates_from_recurrence_rule
|
||||
from project.models import (
|
||||
AdminUnit,
|
||||
Event,
|
||||
@ -67,7 +69,7 @@ def fill_event_filter(event_filter, params):
|
||||
|
||||
def get_event_dates_query(params):
|
||||
event_filter = 1 == 1
|
||||
date_filter = EventDate.start >= today
|
||||
date_filter = EventDate.start >= datetime.min
|
||||
|
||||
event_filter = fill_event_filter(event_filter, params)
|
||||
|
||||
@ -197,7 +199,7 @@ def get_event_with_details_or_404(event_id):
|
||||
|
||||
def get_events_query(params):
|
||||
event_filter = 1 == 1
|
||||
date_filter = EventDate.start >= today
|
||||
date_filter = EventDate.start >= datetime.min
|
||||
|
||||
event_filter = fill_event_filter(event_filter, params)
|
||||
|
||||
|
||||
@ -585,20 +585,21 @@
|
||||
{% endmacro %}
|
||||
|
||||
{% macro render_pagination(pagination) %}
|
||||
{% if 'prev_url' in pagination or 'next_url' in pagination %}
|
||||
{% if pagination['prev_url'] or pagination['next_url'] %}
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
{% if pagination['prev_url'] %}
|
||||
<li class="page-item"> <a class="page-link" href="{{ pagination['prev_url'] }}">{{ _('Previous') }}</a></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link btn disabled" href="#">{{ _('Previous') }}</a></li>
|
||||
{% endif %}
|
||||
{% if pagination['next_url'] %}
|
||||
<li class="page-item"> <a class="page-link" href="{{ pagination['next_url'] }}">{{ _('Next') }}</a></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link btn disabled" href="#">{{ _('Next') }}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<ul class="pagination">
|
||||
{% if pagination['prev_url'] %}
|
||||
<li class="page-item"> <a class="page-link" href="{{ pagination['prev_url'] }}">{{ _('Previous') }}</a></li>
|
||||
{% else %}
|
||||
<li class="page-item disabled"><a class="page-link" href="#">{{ _('Previous') }}</a></li>
|
||||
{% endif %}
|
||||
<li class="page-item disabled"><span class="page-link">{{ _('Page %(page)d of %(pages)d (%(total)d total)', page=pagination["page"], pages=pagination["pages"], total=pagination["total"]) }}</span></li>
|
||||
{% if pagination['next_url'] %}
|
||||
<li class="page-item"> <a class="page-link" href="{{ pagination['next_url'] }}">{{ _('Next') }}</a></li>
|
||||
{% else %}
|
||||
<li class="page-item disabled"><a class="page-link" href="#">{{ _('Next') }}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
@ -209,6 +209,13 @@
|
||||
$('#next_item').addClass('disabled');
|
||||
}
|
||||
|
||||
if (data.has_prev || data.has_next) {
|
||||
$('#page_info_text').text("Seite " + data.page + " von " + data.pages + " (" + data.total + " insgesamt)")
|
||||
$('#page_info').show();
|
||||
} else {
|
||||
$('#page_info').hide();
|
||||
}
|
||||
|
||||
handle_request_success();
|
||||
|
||||
if (leaflet_map != null) {
|
||||
@ -270,6 +277,7 @@
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
<li class="page-item disabled" id="prev_item"><a class="page-link" id="prev_link" href="#">{{ _('Previous') }}</a></li>
|
||||
<li class="page-item disabled" id="page_info d-none"><span class="page-link" id="page_info_text"></span></li>
|
||||
<li class="page-item disabled" id="next_item"><a class="page-link" id="next_link" href="#">{{ _('Next') }}</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -104,7 +104,6 @@ def manage_admin_unit_events(id):
|
||||
admin_unit = get_admin_unit_for_manage_or_404(id)
|
||||
|
||||
params = EventSearchParams()
|
||||
params.set_default_date_range()
|
||||
|
||||
form = FindEventForm(formdata=request.args, obj=params)
|
||||
form.category_id.choices = get_event_category_choices()
|
||||
|
||||
@ -42,6 +42,10 @@ def get_pagination_urls(pagination, **kwargs):
|
||||
result = {}
|
||||
|
||||
if pagination:
|
||||
result["page"] = pagination.page
|
||||
result["pages"] = pagination.pages
|
||||
result["total"] = pagination.total
|
||||
|
||||
if pagination.has_prev:
|
||||
args = request.args.copy()
|
||||
args.update(kwargs)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user