feat: frontend create & delete collections

This commit is contained in:
swve 2022-12-22 21:18:12 +01:00
parent bca6c3000a
commit ce785fd078
6 changed files with 255 additions and 9 deletions

View file

@ -238,7 +238,7 @@ async def verify_rights(course_id: str, current_user: PublicUser, action: str):
if not course:
raise HTTPException(
status_code=status.HTTP_409_CONFLICT, detail=f"Course/CourseChapter does not exist")
status_code=status.HTTP_409_CONFLICT, detail=f"Course does not exist")
hasRoleRights = await verify_user_rights_with_roles(action, current_user.user_id, course_id)
isAuthor = current_user.user_id in course["authors"]

View file

@ -15,6 +15,7 @@ class Collection(BaseModel):
name: str
description: str
courses: List[str] # course_id
org_id: str # org_id
class CollectionInDB(Collection):
@ -51,7 +52,8 @@ async def create_collection(collection_object: Collection, current_user: PublicU
# find if collection already exists using name
isCollectionNameAvailable = collections.find_one({"name": collection_object.name})
await verify_collection_rights("*", current_user, "create")
# TODO
# await verify_collection_rights("*", current_user, "create")
if isCollectionNameAvailable:
raise HTTPException(
@ -139,7 +141,7 @@ async def verify_collection_rights(collection_id: str, current_user: PublicUser
collection = collections.find_one({"collection_id": collection_id})
if not collection:
if not collection and action != "create":
raise HTTPException(
status_code=status.HTTP_409_CONFLICT, detail="Collection does not exist")