Browse Source

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

middleware_test
Jonas Havelka 3 years ago
parent
commit
0bb0911830
  1. 2
      seminar/forms.py
  2. 1
      seminar/views/views_all.py

2
seminar/forms.py

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

1
seminar/views/views_all.py

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

Loading…
Cancel
Save