diff --git a/aleksis/apps/kolego/migrations/0001_initial.py b/aleksis/apps/kolego/migrations/0001_initial.py index 6cdb6149fd6267977843a4f32626dd9b1e5fbde3..d0ff4e5d18a96a25010b2a4a95a82ac95b8ef5c8 100644 --- a/aleksis/apps/kolego/migrations/0001_initial.py +++ b/aleksis/apps/kolego/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.3 on 2023-07-31 15:16 +# Generated by Django 4.2.4 on 2023-08-17 19:59 import aleksis.core.managers from django.db import migrations, models @@ -11,7 +11,7 @@ class Migration(migrations.Migration): dependencies = [ ("sites", "0002_alter_domain_unique"), - ("core", "0052_site_related_name"), + ("core", "0053_freebusy"), ] operations = [ @@ -62,25 +62,16 @@ class Migration(migrations.Migration): name="Absence", fields=[ ( - "id", - models.BigAutoField( - auto_created=True, primary_key=True, serialize=False, verbose_name="ID" - ), - ), - ( - "managed_by_app_label", - models.CharField( - blank=True, - editable=False, - max_length=255, - verbose_name="App label of app responsible for managing this instance", + "freebusy_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="core.freebusy", ), ), - ("extended_data", models.JSONField(default=dict, editable=False)), - ("date_start", models.DateField(verbose_name="Start date")), - ("date_end", models.DateField(verbose_name="End date")), - ("time_start", models.TimeField(blank=True, null=True, verbose_name="Start time")), - ("time_end", models.TimeField(blank=True, null=True, verbose_name="End time")), ("comment", models.TextField(blank=True, verbose_name="Comment")), ( "person", @@ -102,22 +93,12 @@ class Migration(migrations.Migration): verbose_name="Absence reason", ), ), - ( - "site", - models.ForeignKey( - default=1, - editable=False, - on_delete=django.db.models.deletion.CASCADE, - related_name="+", - to="sites.site", - ), - ), ], options={ "verbose_name": "Absence", "verbose_name_plural": "Absences", - "ordering": ["date_start"], }, + bases=("core.freebusy",), ), migrations.AddConstraint( model_name="absencereason", @@ -126,10 +107,4 @@ class Migration(migrations.Migration): name="kolego_unique_short_name_per_site_absence_reason", ), ), - migrations.AddIndex( - model_name="absence", - index=models.Index( - fields=["date_start", "date_end"], name="kolego_abse_date_st_846150_idx" - ), - ), ] diff --git a/aleksis/apps/kolego/models/absence.py b/aleksis/apps/kolego/models/absence.py index 0c47f4770cc3621a94fef0d88ce202b5fd1c66e6..07ed7b2319561e2cffed304153586aa2403fc75f 100644 --- a/aleksis/apps/kolego/models/absence.py +++ b/aleksis/apps/kolego/models/absence.py @@ -3,6 +3,7 @@ from django.utils.translation import gettext_lazy as _ from aleksis.core.managers import CurrentSiteManagerWithoutMigrations from aleksis.core.mixins import ExtensibleModel +from aleksis.core.models import FreeBusy from ..managers import AbsenceQuerySet @@ -28,7 +29,7 @@ class AbsenceReason(ExtensibleModel): ] -class Absence(ExtensibleModel): +class Absence(FreeBusy): objects = CurrentSiteManagerWithoutMigrations.from_queryset(AbsenceQuerySet)() reason = models.ForeignKey( @@ -47,17 +48,11 @@ class Absence(ExtensibleModel): verbose_name=_("Person"), ) - date_start = models.DateField(verbose_name=_("Start date")) - date_end = models.DateField(verbose_name=_("End date")) - time_start = models.TimeField(verbose_name=_("Start time"), blank=True, null=True) - time_end = models.TimeField(verbose_name=_("End time"), blank=True, null=True) comment = models.TextField(verbose_name=_("Comment"), blank=True) def __str__(self): return f"{self.person} ({self.date_start} - {self.date_end})" class Meta: - ordering = ["date_start"] - indexes = [models.Index(fields=["date_start", "date_end"])] verbose_name = _("Absence") verbose_name_plural = _("Absences")