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

Commit

Permalink
fix: Use Access.Roles instead of Userrole
Browse files Browse the repository at this point in the history
  • Loading branch information
robsavoye committed Mar 26, 2024
1 parent a2b8852 commit 5688f04
Show file tree
Hide file tree
Showing 13 changed files with 512 additions and 28 deletions.
3 changes: 1 addition & 2 deletions tm_admin/campaigns/campaigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@
from datetime import datetime
from dateutil.parser import parse
import tm_admin.types_tm
from tm_admin.types_tm import Userrole, Mappinglevel, Teammemberfunctions
from tm_admin.types_tm import Roles, Mappinglevel, Teammemberfunctions
import concurrent.futures
from cpuinfo import get_cpu_info
from tm_admin.dbsupport import DBSupport
from tm_admin.users.users_class import UsersTable
from osm_rawdata.pgasync import PostgresClient
from tm_admin.types_tm import Userrole
from tqdm import tqdm
import tqdm.asyncio
from codetiming import Timer
Expand Down
2 changes: 1 addition & 1 deletion tm_admin/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def __init__(self,
out += f"{k}: datetime = '{datetime.now()}', "
elif k1[:7] == 'public.':
defined = f"tm_admin.types_tm.{k1[7:].capitalize()}"
log.warning(f"SQL ENUM {k1}!!")
# log.warning(f"SQL ENUM {k1}!!")
default = eval(f"{defined}(1)")
out += f"{k}: {defined} = {defined}.{default.name}, "
# out += f"{k}: int = 1, "
Expand Down
3 changes: 1 addition & 2 deletions tm_admin/messages/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
from datetime import datetime
from dateutil.parser import parse
import tm_admin.types_tm
from tm_admin.types_tm import Userrole, Mappinglevel, Teammemberfunctions
from tm_admin.types_tm import Roles, Mappinglevel, Teammemberfunctions
import concurrent.futures
from cpuinfo import get_cpu_info
from tm_admin.dbsupport import DBSupport
from tm_admin.users.users_class import UsersTable
from tm_admin.messages.messages_class import MessagesTable
from osm_rawdata.postgres import uriParser, PostgresClient
from tm_admin.types_tm import Userrole
from tqdm import tqdm
from codetiming import Timer
import threading
Expand Down
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion tm_admin/organizations/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def mergeManagers(self,
pbar = tqdm.tqdm(result)
for record in result:
sql = f" UPDATE organizations SET managers = managers||{record['user_id']} WHERE id={record['organisation_id']};"
# print(sql)
print(sql)
await self.pg.execute(sql)

async def main():
Expand Down
9 changes: 2 additions & 7 deletions tm_admin/projects/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from dateutil.parser import parse
import tm_admin.types_tm
import geojson
from cpuinfo import get_cpu_info
from shapely.geometry import shape
from shapely import centroid
from tm_admin.types_tm import Mappingtypes, Projectstatus, Taskcreationmode, Editors, Permissions, Projectpriority, Projectdifficulty, Teamrole
Expand All @@ -46,13 +45,9 @@
from codetiming import Timer
import asyncio
from shapely import wkb, wkt
import typing
import tm_admin
#if typing.TYPE_CHECKING:
# from tm_admin.users.api import UsersAPI
# from tm_admin.tasks.api import TasksAPI
# from tm_admin.projects.api import ProjectsAPI
# The number of threads is based on the CPU cores

from cpuinfo import get_cpu_info
info = get_cpu_info()
cores = info["count"] * 2

Expand Down
Empty file.
2 changes: 1 addition & 1 deletion tm_admin/projects/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from cpuinfo import get_cpu_info
from shapely.geometry import shape
from shapely import centroid
from tm_admin.types_tm import Mappingtypes, Projectstatus, Taskcreationmode, Editors, Permissions, Projectpriority, Projectdifficulty, Teamrole, Userrole
from tm_admin.types_tm import Mappingtypes, Projectstatus, Taskcreationmode, Editors, Permissions, Projectpriority, Projectdifficulty, Roles
from tm_admin.projects.projects_class import ProjectsTable
from shapely import wkb, get_coordinates
from tm_admin.dbsupport import DBSupport
Expand Down
66 changes: 62 additions & 4 deletions tm_admin/tasks/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,27 +349,70 @@ async def updateIssues(self,
# print(sql)
result = await self.execute(sql)

async def markAllMapped(self):
async def mapAllAPI(self,
project_id: int,
):
"""
Map all tasks on a project. Can only be done by the project
manager.
Args:
Returns:
"""
log.warning(f"markAllMapped(): unimplemented!")
# FIXME use Access() class
log.warning(f"mapAllAPI(): unimplemented!")

return False

async def resetBadImagery(self):
async def validateAllAPI(self,
project_id: int,
flip: bool,
):
"""
Validate or invalidate all tasks on a project. Can only be done
by the project manager.
Args:
project_id (id): The project ID
flip: Invalidate all tasks
Returns:
"""
log.warning(f"resetBadImagery(): unimplemented!")
# FIXME use Access() class
log.warning(f"validateAllAPI(): unimplemented!")

return False

async def resetBadImageryAllAPI(self):
"""
Set all bad imagery tasks as ready for mapping.
Args:
Returns:
"""
# FIXME use Access() class,
log.warning(f"resetBadImageryAllAPI(): unimplemented!")

return False

async def resetAllAPI(self,
project_id: int,
):
"""
Reset all tasks on project back to ready, preserving history.
Args:
Returns:
"""
# FIXME use Access() class,
log.warning(f"resetAllAPI(): unimplemented!")

return False

Expand All @@ -385,6 +428,21 @@ async def undoMapping(self):

return False

async def permittedUser(self,
user_id: int,
project_id: int,
):
"""
Is user action permitted on project.
# FIXME: See if team role is project manager
# FIXME: See if user role is project manager
# FIXME: See if user is org manager
"""

async def main():
"""This main function lets this class be run standalone by a bash script."""
parser = argparse.ArgumentParser()
Expand Down
Loading

0 comments on commit 5688f04

Please sign in to comment.