Skip to content

Commit 9d0ecff

Browse files
Added table for full admin access (#165)
* Added table for full admin access * PR comments
1 parent 06b8c4e commit 9d0ecff

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

business_objects/user.py

+16
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,19 @@ def update_last_interaction(user_id: str) -> None:
179179
user_item = get(user_id)
180180
user_item.last_interaction = sql.func.now()
181181
general.commit()
182+
183+
184+
def check_email_in_full_admin(email: str) -> bool:
185+
email = email.lower()
186+
email = prevent_sql_injection(email, isinstance(email, str))
187+
query = f"""
188+
SELECT EXISTS (
189+
SELECT 1
190+
FROM global.full_admin_access
191+
WHERE email = '{email}'
192+
)
193+
"""
194+
result = general.execute_first(query)
195+
if result and result[0]:
196+
return True
197+
return False

enums.py

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ class Tablenames(Enum):
154154
EVALUATION_GROUP = "evaluation_group"
155155
EVALUATION_RUN = "evaluation_run"
156156
PLAYGROUND_QUESTION = "playground_question"
157+
FULL_ADMIN_ACCESS = "full_admin_access"
157158

158159
def snake_case_to_pascal_case(self):
159160
# the type name (written in PascalCase) of a table is needed to create backrefs

models.py

+8
Original file line numberDiff line numberDiff line change
@@ -2062,3 +2062,11 @@ class PlaygroundQuestion(Base):
20622062
# )
20632063
# record_ids = Column(JSON)
20642064
# meta_info = Column(JSON)
2065+
2066+
2067+
class FullAdminAccess(Base):
2068+
__tablename__ = Tablenames.FULL_ADMIN_ACCESS.value
2069+
__table_args__ = {"schema": "global"}
2070+
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
2071+
email = Column(String, unique=True)
2072+
meta_info = Column(JSON)

0 commit comments

Comments
 (0)