Verified Commit 4a1bfc36 authored by Sli's avatar Sli
Browse files

sas: fix 500 error when tagging the same user twice or adding a non existing user

parent ebee8c34
Pipeline #2169 passed with stage
in 37 minutes and 45 seconds
......@@ -180,6 +180,12 @@ class PictureView(CanViewMixin, DetailView, FormMixin):
if self.form.is_valid():
for uid in self.form.cleaned_data["users"]:
u = User.objects.filter(id=uid).first()
if not u: # Don't use a non existing user
if PeoplePictureRelation.objects.filter(
user=u, picture=self.form.cleaned_data["picture"]
).exists(): # Avoid existing relation
user=u, picture=self.form.cleaned_data["picture"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment