Skip to content

Commit

Permalink
Merge pull request #521 from kirkus/develop
Browse files Browse the repository at this point in the history
Allow override of prev_url and next_url links
  • Loading branch information
llazzaro committed Aug 21, 2022
2 parents 625f952 + 278686a commit 51b2612
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions schedule/templates/schedule/_next.html
@@ -0,0 +1 @@
<a href="{{ url|safe }}"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>
1 change: 1 addition & 0 deletions schedule/templates/schedule/_prev.html
@@ -0,0 +1 @@
<a href="{{ url|safe }}"><span class="glyphicon glyphicon-circle-arrow-left"></span></a>
19 changes: 9 additions & 10 deletions schedule/templatetags/scheduletags.py
Expand Up @@ -3,11 +3,11 @@

from django import template
from django.conf import settings
from django.template.loader import get_template
from django.urls import reverse
from django.utils import timezone
from django.utils.dateformat import format
from django.utils.html import escape
from django.utils.safestring import mark_safe

from schedule.models import Calendar
from schedule.periods import weekday_abbrs, weekday_names
Expand Down Expand Up @@ -209,14 +209,13 @@ def prev_url(target, calendar, period):
slug = calendar.slug
if delta.total_seconds() > SCHEDULER_PREVNEXT_LIMIT_SECONDS:
return ""

return mark_safe(
'<a href="%s%s"><span class="glyphicon glyphicon-circle-arrow-left"></span></a>'
% (
context = {
"url": "{}{}".format(
reverse(target, kwargs={"calendar_slug": slug}),
querystring_for_date(period.prev().start),
)
)
}
return get_template("schedule/_prev.html").render(context)


@register.simple_tag
Expand All @@ -228,13 +227,13 @@ def next_url(target, calendar, period):
if delta.total_seconds() > SCHEDULER_PREVNEXT_LIMIT_SECONDS:
return ""

return mark_safe(
'<a href="%s%s"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>'
% (
context = {
"url": "{}{}".format(
reverse(target, kwargs={"calendar_slug": slug}),
querystring_for_date(period.next().start),
)
)
}
return get_template("schedule/_next.html").render(context)


@register.inclusion_tag("schedule/_prevnext.html")
Expand Down

0 comments on commit 51b2612

Please sign in to comment.