From 0e77d298407ed5bd92b605ff429fee2c815f2341 Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Tue, 30 Mar 2021 15:56:31 +0200
Subject: [PATCH] Opravena editace orga orgem

---
 mo/web/org_users.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mo/web/org_users.py b/mo/web/org_users.py
index d3eb9d08..0281e2ba 100644
--- a/mo/web/org_users.py
+++ b/mo/web/org_users.py
@@ -390,10 +390,11 @@ def org_user_edit(id: int):
     if form.validate_on_submit():
         check = True
 
-        other_user = mo.users.user_by_email(form.email.data)
-        if other_user is not None and other_user != user:
-            flash('Zadaný e-mail nelze použít, existuje jiný účet s tímto e-mailem', 'danger')
-            check = False
+        if hasattr(form, 'email') and form.email is not None:
+            other_user = mo.users.user_by_email(form.email.data)
+            if other_user is not None and other_user != user:
+                flash('Zadaný e-mail nelze použít, existuje jiný účet s tímto e-mailem', 'danger')
+                check = False
 
         if check:
             form.populate_obj(user)
-- 
GitLab