Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
fix: Drop create, update, delete as they're now in pgsupport
Browse files Browse the repository at this point in the history
  • Loading branch information
rsavoye committed Mar 7, 2024
1 parent 9419915 commit a790874
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 386 deletions.
18 changes: 1 addition & 17 deletions tm_admin/campaigns/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def initialize(self,
Args:
inuri (str): The URI for the TM Admin output database
"""
await self.connect(uri)
await self.connect(inuri)
await self.getTypes("campaigns")
#await self.usersdb.connect(uri)
#await self.teamsdb.connect(uri)
Expand Down Expand Up @@ -159,22 +159,6 @@ async def update(self,

return False

async def delete(self,
campaign_id: int,
):
"""
Delete a campaign from the database.
Args:
campaign_id (id): The campaign data
Returns:
(bool): Whether the campaign got deleted
"""
log.warning(f"delete(): unimplemented!")

return False

async def main():
"""This main function lets this class be run standalone by a bash script."""
parser = argparse.ArgumentParser()
Expand Down
55 changes: 0 additions & 55 deletions tm_admin/messages/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,61 +121,6 @@ async def getByName(self,
results = await self.execute(sql)
return results

async def create(self,
message: MessagesTable,
):
"""
Create a message and add it to the database.
Args:
message (MessagesTable): The team data
Returns:
(bool): Whether the message got created
"""
# log.warning(f"create(): unimplemented!")

result = await self.insertRecords([message])

# The ID of the record that just got inserted is returned
if result:
return True

return False

async def update(self,
message: MessagesTable,
):
"""
Update a message that is already in the database.
Args:
message (MessagesTable): The message data
Returns:
(bool): Whether the message got updated
"""
log.warning(f"update(): unimplemented!")

return False

async def delete(self,
message_ids: list,
):
"""
Delete messages from the database.
Args:
message_ids (list): The messages
Returns:
(bool): Whether the messages got deleted
"""
# log.warning(f"delete(): unimplemented!")
await self.deleteRecords(message_ids)

return False

async def main():
"""This main function lets this class be run standalone by a bash script."""
parser = argparse.ArgumentParser()
Expand Down
68 changes: 2 additions & 66 deletions tm_admin/organizations/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def initialize(self,
Args:
inuri (str): The URI for the TM Admin output database
"""
await self.connect(uri)
await self.connect(inuri)
await self.getTypes("organizations")
#await self.messagesdb.connect(uri)
#await self.usersdb.connect(uri)
Expand Down Expand Up @@ -111,57 +111,6 @@ async def getByName(self,
results = await self.execute(sql)
return results

async def create(self,
org: OrganizationsTable,
):
"""
Create a project and add it to the database.
Args:
org (OrganizationsTable): The organization data
Returns:
(bool): Whether the organization got created
"""
# log.warning(f"create(): unimplemented!")
result = await self.insertRecords([org])

# The ID of the record that just got inserted is returned
if result:
return True

return False

async def update(self,
organization: OrganizationsTable,
):
"""
Update a organization that is already in the database.
Args:
organization (OrganizationsTable): The organization data
Returns:
(bool): Whether the organization got updated
"""
log.warning(f"update(): unimplemented!")

return False

async def delete(self,
org_id: int,
):
"""
Delete an organization from the database.
Args:
org_id (id): The organization ID
Returns:
(bool): Whether the organization got deleted
"""
log.warning(f"delete(): unimplemented!")

async def getStats(self,
org_id: int,
):
Expand All @@ -175,19 +124,6 @@ async def getStats(self,
"""
log.warning(f"getStats(): unimplemented!")

async def isManager(self,
user_id: int,
):
"""
Args:
Returns:
"""
log.warning(f"isManager(): unimplemented!")

async def validateName(self,
name: str,
):
Expand Down Expand Up @@ -219,7 +155,7 @@ async def main():
"""This main function lets this class be run standalone by a bash script."""
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", nargs="?", const="0", help="verbose output")
parser.add_argument("-u", "--uri", default='localhost/tm_admin', help="Database URI")
parser.add_argument("-u", "--uri", default='localhost/testdata', help="Database URI")

args = parser.parse_args()

Expand Down
99 changes: 9 additions & 90 deletions tm_admin/projects/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,60 +89,6 @@ async def initialize(self,
await self.connect(inuri)
await self.getTypes("projects")

async def create(self,
project: ProjectsTable,
):
"""
Create a project and add it to the database.
Args:
project (ProjectsTable): The team data
Returns:
(bool): Whether the project got created
"""
# log.warning(f"--- create() ---")
result = await self.insertRecords([project])

# The ID of the record that just got inserted is returned
if result > 0:
return True

return False

async def update(self,
project: ProjectsTable,
):
"""
Update a project that is already in the database.
Args:
project (ProjectsTable): The project data
Returns:
(bool): Whether the project got updated
"""
log.warning(f"update(): unimplemented!")

return False

async def delete(self,
project_ids: int,
):
"""
Delete a project from the database.
Args:
project_ids (id): The project to delete
Returns:
(bool): Whether the project got deleted
"""
# log.warning(f"delete(): unimplemented!")
await self.deleteRecords([project_ids])

return False

async def evaluateMappingPermissions(self,
uid: int,
pid: int,
Expand Down Expand Up @@ -208,13 +154,14 @@ async def getTeamRole(self,
# There should only be one item in the results. Since it's a jsonb column
# the data is returned as a string. In the string is an enum value, which
# gets converted to the actual enum for Teamroles.
if results[0]['results'][0] == '{':
tmp1 = eval(results[0]['results'])
tmp2 = f"Teamroles.{tmp1['role']}"
role = eval(tmp2)
return role
else:
# we should never get here, but you never know...
if len(results) > 0:
if results[0]['results'][0] == '{':
tmp1 = eval(results[0]['results'])
tmp2 = f"Teamroles.{tmp1['role']}"
role = eval(tmp2)
return role

# we should never get here, but you never know...
return None

async def getByName(self,
Expand Down Expand Up @@ -249,7 +196,7 @@ async def changeStatus(self,
Returns:
(bool): Whether locking/unlocking the task was sucessful
"""
log.warning(f"delete(): unimplemented!")
log.warning(f"changeStatus(): unimplemented!")

return False

Expand Down Expand Up @@ -327,34 +274,6 @@ async def getProjectStats(self,

return False

async def deleteTasks(self,
project_id: int,
):
"""
Args:
Returns:
"""
log.warning(f"deleteTasks(): Unimplemented!")

return False

async def getTasks(self):
"""
Args:
Returns:
"""
log.warning(f"getTasks(): Unimplemented!")

return False

async def getAOI(self,
project_id: int,
):
Expand Down
55 changes: 1 addition & 54 deletions tm_admin/tasks/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,59 +139,6 @@ async def getByUser(self,
results = await self.execute(sql)
return results

async def create(self,
task: TasksTable,
):
"""
Create a task and add it to the database.
Args:
task (TasksTable): The task data
Returns:
(bool): Whether the task got created
"""
# log.warning(f"create(): unimplemented!")
result = await self.insertRecords([task])

# The ID of the record that just got inserted is returned
if result:
return True

return False

async def update(self,
task: TasksTable,
):
"""
Update a task that is already in the database.
Args:
task (TasksTable): The task data
Returns:
(bool): Whether the task got updated
"""
log.warning(f"update(): unimplemented!")

return False

async def delete(self,
task_id: int,
):
"""
Delete a task from the database.
Args:
task_id (int): The team to delete
Returns:
(bool): Whether the task got deleted
"""
log.warning(f"delete(): unimplemented!")

return False

async def changeStatus(self,
user_id: int,
task_id: int,
Expand All @@ -211,7 +158,7 @@ async def changeStatus(self,
Returns:
(bool): Whether locking/unlocking the task was sucessful
"""
log.warning(f"delete(): unimplemented!")
log.warning(f"changeStatus(): unimplemented!")

async def markAllMapped(self):
"""
Expand Down
Loading

0 comments on commit a790874

Please sign in to comment.