fix(members): move util function, remove blank space

pull/174/head
mariusrklein 5 months ago
parent 9b1426bc0d
commit d13143fbf0

@ -892,11 +892,6 @@ class GroupAdmin(CommonAdminMixin, admin.ModelAdmin):
} }
return render_tex(f"Gruppen-Checkliste", 'members/group_checklist.tex', context) return render_tex(f"Gruppen-Checkliste", 'members/group_checklist.tex', context)
def mondays_until_nth(n):
today = datetime.today()
next_monday = today + timedelta(days=(7 - today.weekday()) % 7 or 7)
return [(next_monday + timedelta(weeks=i)).date() for i in range(n + 1)]
class ActivityCategoryAdmin(admin.ModelAdmin): class ActivityCategoryAdmin(admin.ModelAdmin):
fields = ['name', 'ljp_category', 'description'] fields = ['name', 'ljp_category', 'description']

@ -376,7 +376,6 @@ class Member(Person):
@property @property
def ticket_tag(self): def ticket_tag(self):
"""Returning the ticket number stripped of strings and spaces""" """Returning the ticket number stripped of strings and spaces"""
return "{" + ''.join(re.findall(r'\d', self.ticket_no)) + "}" return "{" + ''.join(re.findall(r'\d', self.ticket_no)) + "}"
@property @property

@ -1,4 +1,4 @@
from datetime import datetime from datetime import datetime, timedelta
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
@ -88,3 +88,11 @@ def coming_midnight():
return timezone.datetime(year=base.year, month=base.month, day=base.day, return timezone.datetime(year=base.year, month=base.month, day=base.day,
hour=0, minute=0, second=0, microsecond=0, hour=0, minute=0, second=0, microsecond=0,
tzinfo=base.tzinfo) tzinfo=base.tzinfo)
def mondays_until_nth(n):
""" Returns a list of dates for the next n Mondays, starting from the next Monday.
This functions aids in the generation of weekly schedules or reports."""
today = datetime.today()
next_monday = today + timedelta(days=(7 - today.weekday()) % 7 or 7)
return [(next_monday + timedelta(weeks=i)).date() for i in range(n + 1)]

Loading…
Cancel
Save