Fixed projector broadcast if projector is deleted. Fixed #2646.

This commit is contained in:
Norman Jäckel 2016-11-19 13:04:24 +01:00
parent 577d0bf3cc
commit 28059698c7

View File

@ -204,13 +204,20 @@ class ProjectorViewSet(ModelViewSet):
result = False
return result
# Assign all ProjectionDefault objects from this projector to the default projector (pk=1).
def destroy(self, *args, **kwargs):
"""
REST API operation for DELETE requests.
Assigns all ProjectionDefault objects from this projector to the
default projector (pk=1). Resets broadcast if set to this projector.
"""
projector_instance = self.get_object()
for projection_default in ProjectionDefault.objects.all():
if projection_default.projector.id == projector_instance.id:
projection_default.projector_id = 1
projection_default.save()
if config['projector_broadcast'] == projector_instance.pk:
config['projector_broadcast'] = 0
return super(ProjectorViewSet, self).destroy(*args, **kwargs)
@detail_route(methods=['post'])