flows: fix error clearing flow background when no files have been uploaded

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
master
Jens Langhammer 2021-06-13 14:14:41 +02:00
parent 82b2c7e3f0
commit afb84c7bc5
2 changed files with 6 additions and 12 deletions

View File

@ -3,16 +3,6 @@
{% load static %}
{% load i18n %}
{% block head %}
{{ block.super }}
<style>
.pf-c-background-image::before {
background-image: url("{% static 'dist/assets/images/flow_background.jpg' %}");
background-position: center;
}
</style>
{% endblock %}
{% block title %}
{% trans 'End session' %} - {{ tenant.branding_title }}
{% endblock %}

View File

@ -303,8 +303,12 @@ class FlowViewSet(UsedByMixin, ModelViewSet):
background = request.FILES.get("file", None)
clear = request.data.get("clear", False)
if clear:
# .delete() saves the model by default
flow.background.delete()
if flow.background_url.startswith("/media"):
# .delete() saves the model by default
flow.background.delete()
else:
flow.background = None
flow.save()
return Response({})
if background:
flow.background = background