diff --git a/tm_admin/projects/api.py b/tm_admin/projects/api.py index a11f8fd..25a8e23 100755 --- a/tm_admin/projects/api.py +++ b/tm_admin/projects/api.py @@ -32,13 +32,14 @@ import geojson from shapely.geometry import shape from shapely import centroid -from tm_admin.types_tm import Mappingtypes, Projectstatus, Taskcreationmode, Editors, Permissions, Projectpriority, Projectdifficulty, Teamrole +from tm_admin.types_tm import Mappingtypes, Projectstatus, Taskcreationmode, Editors, Permissions, Projectpriority, Projectdifficulty from tm_admin.projects.projects_class import ProjectsTable from tm_admin.tasks.tasks_class import TasksTable from shapely import wkb, get_coordinates from tm_admin.pgsupport import PGSupport from osm_rawdata.pgasync import PostgresClient import re +from tm_admin.access import Roles # from progress import Bar, PixelBar from tqdm import tqdm import tqdm.asyncio @@ -63,11 +64,11 @@ def __init__(self): Returns: (ProjectsAPI): An instance of this class """ - self.allowed_roles = [ - Teamrole.TEAM_MAPPER, - Teamrole.TEAM_VALIDATOR, - Teamrole.TEAM_MANAGER, - ] + # self.allowed_roles = [ + # Teamrole.MAPPER, + # Teamrole.VALIDATOR, + # Teamrole.MANAGER, + # ] from tm_admin.users.api import UsersAPI self.users = None self.tasks = None @@ -122,7 +123,8 @@ async def getTeamRole(self, #data = await self.getColumns(['id', 'teams'], where) # The role is in a list of dicts in a jsonb column. - sql = f"SELECT jsonb_path_query(teams, '$.teams[*] ? (@.team_id[*] == {team_id})') AS results FROM projects WHERE id = {project_id};" + sql = f"SELECT jsonb_path_query(members, '$.members[*] ? (@.team_id[*] == {team_id})') AS results FROM projects WHERE id = {project_id};" + # print(sql) results = await self.execute(sql) # There should only be one item in the results. Since it's a jsonb column @@ -131,7 +133,7 @@ async def getTeamRole(self, if len(results) > 0: if results[0]['results'][0] == '{': tmp1 = eval(results[0]['results']) - tmp2 = f"Teamrole.{tmp1['role']}" + tmp2 = f"Roles.{tmp1['role']}" role = eval(tmp2) return role diff --git a/tm_admin/tasks/api.py b/tm_admin/tasks/api.py index 2db4f7f..bee41c9 100755 --- a/tm_admin/tasks/api.py +++ b/tm_admin/tasks/api.py @@ -271,7 +271,7 @@ async def updateHistory(self, data += f'" {v}", ' #asc = str(entry).replace("'", '"').replace("\\'", "'") sql = "UPDATE tasks SET history = '{\"history\": [%s]}' WHERE id=%d AND project_id=%d" % (data[:-2], task_id, project_id) - print(sql) + # print(sql) result = await self.execute(sql) async def appendHistory(self, @@ -350,8 +350,8 @@ async def updateIssues(self, result = await self.execute(sql) async def mapAllAPI(self, - project_id: int, - ): + project_id: int, + ): """ Map all tasks on a project. Can only be done by the project manager. @@ -386,7 +386,7 @@ async def validateAllAPI(self, return False - async def resetBadImageryAllAPI(self): + async def resetBadImagery(self): """ Set all bad imagery tasks as ready for mapping. diff --git a/tm_admin/users/api.py b/tm_admin/users/api.py index 4eb7861..7374691 100755 --- a/tm_admin/users/api.py +++ b/tm_admin/users/api.py @@ -40,17 +40,14 @@ from shapely import wkb, get_coordinates from tm_admin.pgsupport import PGSupport import typing -#if typing.TYPE_CHECKING: -# from tm_admin.projects.api import ProjectsAPI -# from tm_admin.tasks.api import TasksAPI import tm_admin import re -# from progress import Bar, PixelBar from tqdm import tqdm import tqdm.asyncio from codetiming import Timer import asyncio from http import HTTPStatus +from tm_admin.access import Roles # The number of threads is based on the CPU cores info = get_cpu_info()