[odrs-web/oscp] trivial: Fix a traceback when logging in as a new moderator



commit 10584ce1d84539a54612ebc2164f2b8ccb191070
Author: Richard Hughes <richard hughsie com>
Date:   Wed Apr 29 16:56:30 2020 +0100

    trivial: Fix a traceback when logging in as a new moderator

 app_data/odrs/models.py          | 3 ++-
 app_data/odrs/tests/odrs_test.py | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/app_data/odrs/models.py b/app_data/odrs/models.py
index 49a8997..14a7355 100644
--- a/app_data/odrs/models.py
+++ b/app_data/odrs/models.py
@@ -349,7 +349,8 @@ class Moderator(db.Model):
         self.is_enabled = True
         self.is_admin = False
         self.locales = None
-        self.locales = password
+        if password:
+            self.password = password
 
     @property
     def password(self):
diff --git a/app_data/odrs/tests/odrs_test.py b/app_data/odrs/tests/odrs_test.py
index 42e4e74..09adb62 100644
--- a/app_data/odrs/tests/odrs_test.py
+++ b/app_data/odrs/tests/odrs_test.py
@@ -184,8 +184,14 @@ class OdrsTest(unittest.TestCase):
         # duplicate
         rv = self._admin_moderator_add()
         assert b'Already a entry with that username' in rv.data, rv.data
+        self.logout()
+
+        # test this actually works
+        self.login(username='dave dave com', password='foobarbaz123.')
+        self.logout()
 
         # remove
+        self.login()
         rv = self.app.get('admin/moderator/2/delete', follow_redirects=True)
         assert b'Deleted user' in rv.data, rv.data
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]