Fix Duplikátní e-mail v editu (nebrat sebe)

This commit is contained in:
Jonas Havelka 2021-09-05 22:10:12 +02:00
parent 9462c78fb8
commit 0bb0911830
2 changed files with 2 additions and 1 deletions

View file

@ -199,7 +199,7 @@ class ProfileEditForm(forms.Form):
err_logger = logging.getLogger('seminar.prihlaska.problem')
email = self.cleaned_data.get('email')
try:
Osoba.objects.get(email=email)
Osoba.objects.exclude(user__username=self.username).get(email=email)
msg = "Email {} exists (in edit)".format(email)
err_logger.info(msg)
raise forms.ValidationError('Email je již použit')

View file

@ -1162,6 +1162,7 @@ def resitelEditView(request):
form = PoMaturiteProfileEditForm(POST)
else:
form = ProfileEditForm(POST)
form.username = user_edit.username
if form.is_valid():
## Změny v osobě
fcd = form.cleaned_data