示例#1
0
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
示例#2
0
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
示例#3
0
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()
示例#4
0
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()
示例#5
0
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)
示例#6
0
def get_keyword(
        *,
        repository: KeywordRepository = Depends(get_keyword_repository),
        id: int):
    keyword: Optional[DBKeyword] = repository.get(id)
    return or_404(keyword)
示例#7
0
def get_collection(
        *,
        repository: CollectionRepository = Depends(get_collection_repository),
        id: int):
    collection: Optional[DBCollection] = repository.get(id)
    return or_404(collection)
示例#8
0
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)
示例#9
0
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)