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

Move append_if_all to util and add typing/docstring

parent 7ec9ca07
No related branches found
No related tags found
1 merge request!73Resolve "Add week select to week view"
Pipeline #3268 passed
from typing import List
def append_if_all(iterable: List, *args) -> List:
"""Append args to a list if all args are true-like."""
if all(args):
for a in args:
iterable.append(a)
return iterable
......@@ -13,6 +13,7 @@ from django_tables2 import SingleTableView
from reversion.views import RevisionMixin
from rules.contrib.views import PermissionRequiredMixin
from aleksis.apps.alsijil.util import append_if_all
from aleksis.apps.chronos.managers import TimetableType
from aleksis.apps.chronos.models import LessonPeriod
from aleksis.apps.chronos.util.chronos_helpers import get_el_by_pk
......@@ -294,11 +295,6 @@ def week_view(
lesson_periods, key=lambda x: (x.period.weekday, x.period.period)
)
def append_if_all(iterable, *args):
if all(args):
for a in args:
iterable.append(a)
context["extra_marks"] = ExtraMark.objects.all()
context["week"] = wanted_week
context["weeks"] = get_weeks_for_year(year=wanted_week.year)
......
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