Skip to content

Commit

Permalink
Added guser.default_org_id field
Browse files Browse the repository at this point in the history
  • Loading branch information
jorvis committed Jan 16, 2024
1 parent 005d885 commit d2239de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CREATE TABLE guser (
is_admin TINYINT(1) DEFAULT 0,
help_id VARCHAR(50),
date_created DATETIME DEFAULT CURRENT_TIMESTAMP,
default_org_id INT DEFAULT 1,
is_gear_curator TINYINT(1) DEFAULT 0
) ENGINE=INNODB;

Expand Down
16 changes: 9 additions & 7 deletions lib/geardb.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,17 @@ def get_user_by_id(user_id):

qry = """
SELECT g.id, g.user_name, g.email, g.institution, g.pass, g.updates_wanted,
g.is_admin, g.is_gear_curator, g.help_id
g.is_admin, g.default_org_id, g.is_gear_curator, g.help_id
FROM guser g
WHERE g.id = %s
"""
cursor.execute(qry, (user_id, ) )

user = None
for (id, user_name, email, institution, password, updates_wanted, is_admin, is_gear_curator, help_id) in cursor:
for (id, user_name, email, institution, password, updates_wanted, is_admin, default_org_id, is_gear_curator, help_id) in cursor:
user = User(id=id, user_name=user_name, email=email, institution=institution,
password=password, updates_wanted=updates_wanted, is_admin=is_admin,
is_gear_curator=is_gear_curator, help_id=help_id)
default_org_id=default_org_id, is_gear_curator=is_gear_curator, help_id=help_id)
break

cursor.close()
Expand All @@ -348,18 +348,18 @@ def get_user_from_session_id(session_id):

qry = """
SELECT g.id, g.user_name, g.email, g.institution, g.pass, g.updates_wanted,
g.is_admin, g.is_gear_curator, g.help_id
g.is_admin, g.default_org_id, g.is_gear_curator, g.help_id
FROM guser g
JOIN user_session us ON g.id=us.user_id
WHERE us.session_id = %s
"""
cursor.execute(qry, (session_id, ) )

user = None
for (id, user_name, email, institution, password, updates_wanted, is_admin, is_gear_curator, help_id) in cursor:
for (id, user_name, email, institution, password, updates_wanted, is_admin, default_org_id, is_gear_curator, help_id) in cursor:
user = User(id=id, user_name=user_name, email=email, institution=institution,
password=password, updates_wanted=updates_wanted, is_admin=is_admin,
is_gear_curator=is_gear_curator, help_id=help_id)
default_org_id=default_org_id, is_gear_curator=is_gear_curator, help_id=help_id)
break

cursor.close()
Expand Down Expand Up @@ -2806,14 +2806,16 @@ class User:
table column name.
"""
def __init__(self, id=None, user_name=None, email=None, institution=None, password=None,
updates_wanted=None, is_admin=None, is_gear_curator=None, help_id=None):
updates_wanted=None, is_admin=None, default_org_id=None, is_gear_curator=None,
help_id=None):
self.id = id
self.user_name = user_name
self.email = email
self.institution = institution
self.password = password
self.updates_wanted = updates_wanted
self.is_admin = is_admin
self.default_org_id = default_org_id
self.is_gear_curator = is_gear_curator
self.help_id = help_id

Expand Down

0 comments on commit d2239de

Please sign in to comment.