Skip to content

Commit

Permalink
ADD: add post request for enum types
Browse files Browse the repository at this point in the history
  • Loading branch information
violetbrina committed Jul 18, 2023
1 parent 95fb0ba commit 9c885d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/routes/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def _create_route(e: Type[EnumTable]):
async def get(connection=get_projectless_db_connection) -> list[str]:
return await e(connection).get()

@router.post('/' + hyphenated_name, operation_id='post' + camel_case_name + 's')
async def post(
new_type: str, connection=get_projectless_db_connection
) -> list[str]:
return await e(connection).insert(new_type)


for enum in enum_tables.__dict__.values():
if not isclass(enum):
Expand Down
1 change: 1 addition & 0 deletions db/python/enum_tables/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ async def insert(self, value: str):
await self.connection.execute(_query, {'name': value.lower()})
# clear the cache so results are up-to-date
self.get.cache_clear() # pylint: disable=no-member
return value

0 comments on commit 9c885d2

Please sign in to comment.