Skip to content
Snippets Groups Projects
Commit 4cb30c33 authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

Fix timezone-caused offset when directly creating a new slot in scheduler

parent 45ed45f8
No related branches found
No related tags found
No related merge requests found
......@@ -37,3 +37,12 @@ class AKSlotSerializer(serializers.ModelSerializer):
class Meta:
model = AKSlot
fields = '__all__'
treat_as_local = serializers.BooleanField(required=False, default=False, write_only=True)
def create(self, validated_data:dict):
if validated_data['treat_as_local']:
validated_data['start'] = validated_data['start'].replace(tzinfo=None).astimezone(
validated_data['event'].timezone)
del validated_data['treat_as_local']
return super().create(validated_data)
......@@ -261,7 +261,8 @@
duration: $('#id_duration').val(),
room: $('#id_room').val(),
ak: ak,
event: "{{ event.pk }}"
event: "{{ event.pk }}",
treat_as_local: true,
},
success: function (response) {
$('#newAKSlotModal').modal('hide');
......
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