Skip to content
Snippets Groups Projects
Commit a9d5ce30 authored by Tim-Oliver Husser's avatar Tim-Oliver Husser
Browse files

Merge branch 'develop' into 'main'

v1.25.5

See merge request !143
parents 7aa59b85 7d032925
No related branches found
No related tags found
1 merge request!143v1.25.5
......@@ -34,10 +34,6 @@ class Semester(models.Model):
week_day = models.IntegerField() # 0=Mon, 1=Tue, ...
active = models.BooleanField(default=True)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__original_dates = (self.lecture_start, self.lecture_end, self.week_day)
def __str__(self):
if self.semester == 0:
return f"Winter Term {self.year}/{str(self.year + 1)[-2:]}"
......@@ -70,24 +66,26 @@ class Semester(models.Model):
# set code
self.code = self.short_name()
# did the dates change?
need_create_dates = True
if self.pk is not None:
orig = Semester.objects.get(pk=self.pk)
need_create_dates = (
self.lecture_start != orig.lecture_start
or self.lecture_end != orig.lecture_end
or self.week_day != orig.week_day
)
# save model
super().save(*args, **kwargs)
# deactivate all semesters except this one
Semester.objects.exclude(id=self.id).update(active=False)
# did the dates change?
if self.__original_dates != (
self.lecture_start,
self.lecture_end,
self.week_day,
):
# create dates
# create dates?
if need_create_dates:
self._create_dates()
# store new dates
self.__original_dates = (self.lecture_start, self.lecture_end, self.week_day)
@staticmethod
def current():
"""Return current semester."""
......
[tool.poetry]
name = "labcourse"
version = "1.25.4"
version = "1.25.5"
description = ""
authors = ["Tim-Oliver Husser <thusser@uni-goettingen.de>"]
......
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