mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: init collectionid page
This commit is contained in:
parent
dea720c871
commit
27cd84127f
8 changed files with 126 additions and 2 deletions
|
|
@ -38,6 +38,18 @@ async def get_collection(request: Request,collection_id: str, current_user: Publ
|
|||
status_code=status.HTTP_409_CONFLICT, detail="Collection does not exist")
|
||||
|
||||
collection = Collection(**collection)
|
||||
|
||||
# add courses to collection
|
||||
courses = request.app.db["courses"]
|
||||
courseids = [course for course in collection.courses]
|
||||
|
||||
collection.courses = []
|
||||
collection.courses = courses.find(
|
||||
{"course_id": {"$in": courseids}}, {'_id': 0})
|
||||
|
||||
collection.courses = [course for course in await collection.courses.to_list(length=100)]
|
||||
|
||||
|
||||
return collection
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue