Fix oncall shifts serializer, fix migration, update oncall shift log text
This commit is contained in:
parent
59e88d0c43
commit
b7a0411142
3 changed files with 8 additions and 10 deletions
|
|
@ -46,7 +46,6 @@ class OnCallShiftSerializer(EagerLoadingMixin, serializers.ModelSerializer):
|
|||
"until",
|
||||
"frequency",
|
||||
"interval",
|
||||
"until",
|
||||
"by_day",
|
||||
"source",
|
||||
"rolling_users",
|
||||
|
|
@ -74,7 +73,7 @@ class OnCallShiftSerializer(EagerLoadingMixin, serializers.ModelSerializer):
|
|||
result = super().to_representation(instance)
|
||||
return result
|
||||
|
||||
def validate_name(self, name): # todo
|
||||
def validate_name(self, name):
|
||||
organization = self.context["request"].auth.organization
|
||||
if name is None:
|
||||
return name
|
||||
|
|
@ -147,12 +146,15 @@ class OnCallShiftSerializer(EagerLoadingMixin, serializers.ModelSerializer):
|
|||
"interval",
|
||||
"by_day",
|
||||
"until",
|
||||
"rotation_start",
|
||||
]
|
||||
if event_type == CustomOnCallShift.TYPE_OVERRIDE:
|
||||
for field in fields_to_update_for_overrides:
|
||||
value = None
|
||||
if field == "priority_level":
|
||||
value = 0
|
||||
elif field == "rotation_start":
|
||||
value = validated_data["start"]
|
||||
validated_data[field] = value
|
||||
|
||||
self._validate_frequency(
|
||||
|
|
|
|||
|
|
@ -1,17 +1,12 @@
|
|||
# Generated by Django 3.2.13 on 2022-07-12 08:03
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.db.models import F
|
||||
|
||||
|
||||
def fill_rotation_start_field(apps, schema_editor):
|
||||
CustomOnCallShift = apps.get_model("schedules", "CustomOnCallShift")
|
||||
shifts = CustomOnCallShift.objects.all()
|
||||
shifts_to_update = []
|
||||
for shift in shifts:
|
||||
shift.rotation_start = shift.start
|
||||
shifts_to_update.append(shift)
|
||||
|
||||
CustomOnCallShift.objects.bulk_update(shifts_to_update, ["rotation_start"], batch_size=5000)
|
||||
CustomOnCallShift.objects.update(rotation_start=F("start"))
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
|
|||
|
|
@ -236,7 +236,8 @@ class CustomOnCallShift(models.Model):
|
|||
result += (
|
||||
f", frequency: {self.get_frequency_display()}, interval: {self.interval}, "
|
||||
f"week start: {self.week_start}, by day: {self.by_day}, by month: {self.by_month}, "
|
||||
f"by monthday: {self.by_monthday}, until: {self.until.isoformat() if self.until else None}"
|
||||
f"by monthday: {self.by_monthday}, rotation start: {self.rotation_start.isoformat()}, "
|
||||
f"until: {self.until.isoformat() if self.until else None}"
|
||||
)
|
||||
return result
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue