Skip to content
Snippets Groups Projects
Verified Commit 25178e84 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: check for permissions before updating a timeslot

parent 212faf0c
No related branches found
No related tags found
No related merge requests found
......@@ -998,6 +998,18 @@ class TimeSlotSerializer(serializers.ModelSerializer):
def update(self, instance, validated_data):
"""Update and return an existing Show instance, given the validated data."""
user = self.context.get("request").user
user_is_owner = user in instance.schedule.show.owners.all()
# Having the update_timeslot permission overrides the ownership
if not (
user.has_perm("program.update_timeslot")
or (user.has_perm("program.change_timeslot") and user_is_owner)
):
raise exceptions.PermissionDenied(
detail="You are not allowed to update this timeslot."
)
if "memo" in validated_data:
instance.memo = validated_data.get("memo")
......
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