diff options
-rw-r--r-- | db/create.sql | 1 | ||||
-rw-r--r-- | server/user_session.py | 12 |
2 files changed, 7 insertions, 6 deletions
diff --git a/db/create.sql b/db/create.sql index c0e95fa..31b0f5f 100644 --- a/db/create.sql +++ b/db/create.sql @@ -35,6 +35,7 @@ create table codeq_user ( last_login timestamp not null, gui_lang varchar(2), robot_address varchar(30), + gui_layout varchar(30), constraint codeq_user_pk primary key (id), constraint codeq_user_uq1 unique (username) ); diff --git a/server/user_session.py b/server/user_session.py index dbf886c..976f144 100644 --- a/server/user_session.py +++ b/server/user_session.py @@ -71,7 +71,7 @@ class UserSession(object): try: cur = conn.cursor() try: - cur.execute('select id, password, name, email, date_joined, gui_lang, robot_address from codeq_user where username = %s', (username,)) + cur.execute('select id, password, name, email, date_joined, gui_lang, robot_address, gui_layout from codeq_user where username = %s', (username,)) row = cur.fetchone() if row is None: raise AuthenticationFailed('No such user: {}'.format(username)) @@ -79,7 +79,7 @@ class UserSession(object): cur.execute('update codeq_user set last_login = %s where id = %s', (str(now), row[0],)) self.uid = row[0] self.username = username - self.settings = {'gui_lang': row[5], 'robot_address': row[6]} + self.settings = {'gui_lang': row[5], 'robot_address': row[6], 'gui_layout': row[7]} return row[2], row[3], row[4], now else: raise AuthenticationFailed('Password mismatch') @@ -129,12 +129,12 @@ class UserSession(object): try: cur = conn.cursor() try: - cur.execute('update codeq_user set name = %s, email = %s, saml_data = %s, last_login = %s where username = %s and saml_data is not null returning id, gui_lang, date_joined, robot_address', (name, email, psycopg2.extras.Json(saml_data), str(now), uuid)) + cur.execute('update codeq_user set name = %s, email = %s, saml_data = %s, last_login = %s where username = %s and saml_data is not null returning id, gui_lang, date_joined, robot_address, gui_layout', (name, email, psycopg2.extras.Json(saml_data), str(now), uuid)) row = cur.fetchone() if row: self.uid = row[0] self.username = uuid - self.settings = {'gui_lang': row[1], 'robot_address': row[3]} + self.settings = {'gui_lang': row[1], 'robot_address': row[3], 'gui_layout': row[4]} return name, email, row[2], now else: cur.execute('insert into codeq_user (username, name, email, is_admin, is_active, date_joined, last_login, gui_lang, saml_data) values (%s, %s, %s, %s, %s, %s, %s, %s, %s) returning id', (uuid, name, email, False, True, str(now), str(now), gui_lang, psycopg2.extras.Json(saml_data))) @@ -143,7 +143,7 @@ class UserSession(object): raise SignupFailed('Sign-up failed') self.uid = row[0] self.username = uuid - self.settings = {'gui_lang': gui_lang, 'robot_address': None} + self.settings = {'gui_lang': gui_lang, 'robot_address': None, 'gui_layout': None} return name, email, now, now finally: cur.close() @@ -202,7 +202,7 @@ class UserSession(object): try: cur = conn.cursor() try: - cur.execute("update codeq_user set gui_lang = %s, robot_address = %s where id = %s", (self.settings['gui_lang'], self.settings['robot_address'], self.uid)) + cur.execute("update codeq_user set gui_lang = %s, robot_address = %s, gui_layout = %s where id = %s", (self.settings['gui_lang'], self.settings['robot_address'], self.settings['gui_layout'],self.uid)) finally: cur.close() conn.commit() |