mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 18:44:23 +00:00
sas: fix 500 error when tagging the same user twice or adding a non existing user
This commit is contained in:
parent
ebee8c34e1
commit
4a1bfc366d
@ -180,6 +180,12 @@ class PictureView(CanViewMixin, DetailView, FormMixin):
|
|||||||
if self.form.is_valid():
|
if self.form.is_valid():
|
||||||
for uid in self.form.cleaned_data["users"]:
|
for uid in self.form.cleaned_data["users"]:
|
||||||
u = User.objects.filter(id=uid).first()
|
u = User.objects.filter(id=uid).first()
|
||||||
|
if not u: # Don't use a non existing user
|
||||||
|
continue
|
||||||
|
if PeoplePictureRelation.objects.filter(
|
||||||
|
user=u, picture=self.form.cleaned_data["picture"]
|
||||||
|
).exists(): # Avoid existing relation
|
||||||
|
continue
|
||||||
PeoplePictureRelation(
|
PeoplePictureRelation(
|
||||||
user=u, picture=self.form.cleaned_data["picture"]
|
user=u, picture=self.form.cleaned_data["picture"]
|
||||||
).save()
|
).save()
|
||||||
|
Loading…
Reference in New Issue
Block a user