Skip to content
Snippets Groups Projects
Verified Commit 9ecc6742 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Use django.contrib.humanize instead of own functions for dashboard widget

parent 4a199dc9
No related branches found
No related tags found
1 merge request!36Dashboard widget for SMART PLAN
......@@ -22,7 +22,7 @@ from django_global_request.middleware import get_request
from aleksis.core.mixins import ExtensibleModel
from aleksis.core.models import Group, Person, DashboardWidget
from aleksis.apps.chronos.util.date import week_weekday_from_date, get_name_for_day_from_today
from aleksis.apps.chronos.util.date import week_weekday_from_date
from aleksis.core.util.core_helpers import has_person
......@@ -551,7 +551,6 @@ class TimetableWidget(DashboardWidget):
context["lesson_periods"] = OrderedDict(sorted(per_period.items()))
context["type"] = type_
context["day"] = wanted_day
context["day_label"] = get_name_for_day_from_today(wanted_day)
context["periods"] = TimePeriod.get_times_dict()
context["smart"] = True
return context
......
{# -*- engine:django -*- #}
{% load i18n static %}
{% load i18n static humanize %}
<div class="card">
<div class="card-content">
<span class="card-title">
{% blocktrans with day_label=day_label %}
My timetable for {{ day_label }}
{% blocktrans with day=day|naturalday:"l" %}
My timetable for {{ day }}
{% endblocktrans %}
</span>
<div class="timetable-plan">
......
......@@ -31,21 +31,3 @@ def get_weeks_for_year(year: int) -> List[CalendarWeek]:
current_week += 1
return weeks
def get_name_for_day_from_today(next_day: date) -> str:
"""
Return the next week day as you would say it from today: "today", "tomorrow" or "<weekday>"
"""
if next_day == timezone.now().date():
# Today
date_formatted = _("today")
elif next_day == timezone.now().date() + timezone.timedelta(days=1):
# Tomorrow
date_formatted = _("tomorrow")
else:
# Other weekday
date_formatted = i18n_day_names()[next_day.weekday()]
return date_formatted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment