def update_collection( *, _: bool = Depends(is_authenticated), repository: CollectionRepository = Depends(get_collection_repository), id: int, collection_update: CollectionUpdate): db_collection: DBCollection = or_404(repository.get(id)) updated: DBCollection = repository.update( db_collection, collection_update.dict(skip_defaults=True)) return updated
def update_keyword( *, _: bool = Depends(is_authenticated), repository: KeywordRepository = Depends(get_keyword_repository), id: int, keyword_update: KeywordUpdate): db_keyword: DBKeyword = or_404(repository.get(id)) updated: DBKeyword = repository.update( db_keyword, keyword_update.dict(skip_defaults=True)) return updated
def update_keyword( *, _: bool = Depends(is_authenticated), repository: KeywordRepository = Depends(get_keyword_repository), id: int, keyword_update: KeywordUpdate, ): db_keyword: DBKeyword = or_404(repository.get(id)) updated: DBKeyword = repository.update( db_keyword, keyword_update.dict(exclude_unset=True)) return updated.to_model()
def update_collection( *, _: bool = Depends(is_authenticated), repository: CollectionRepository = Depends(get_collection_repository), id: int, collection_update: CollectionUpdate, ): db_collection: DBCollection = or_404(repository.get(id)) updated: DBCollection = repository.update( db_collection, collection_update.dict(exclude_unset=True)) return updated.to_model()
def base_doc_view(request: Request, repository: CollectionRepository, collection_id: int, keyword_id: Optional[int] = None): collection = or_404(repository.get(collection_id)) collections = repository.get_all() context = { "request": request, "collection": collection, "keyword_id": keyword_id, "hierarchy": collections, "version": version } return templates.TemplateResponse("library.html", context)
def get_keyword( *, repository: KeywordRepository = Depends(get_keyword_repository), id: int): keyword: Optional[DBKeyword] = repository.get(id) return or_404(keyword)
def get_collection( *, repository: CollectionRepository = Depends(get_collection_repository), id: int): collection: Optional[DBCollection] = repository.get(id) return or_404(collection)
def get_keyword_with_stats( *, repository: KeywordRepository = Depends(get_keyword_repository), id: int): keyword: Optional[KeywordWithStats] = repository.get_with_stats(id) return or_404(keyword)
def get_collection_with_stats( *, repository: CollectionRepository = Depends(get_collection_repository), id: int): collection: Optional[CollectionWithStats] = repository.get_with_stats(id) return or_404(collection)