def check_input(cls, values: dict): doc_slug = values.get('document_slug', None) doc_id = values.get('document_id', None) print('validation doc id', doc_id) print('validation doc slug', doc_slug) if doc_slug is None and doc_id is None: raise ValueError('document_slug or document_id is required') if doc_slug is not None and doc_id is not None: raise ValueError('provide only document_slug or only document_id') if doc_slug is not None: must_exist_by(InstructionDocumentRepository(), by='slug', value=doc_slug) if doc_id is not None: must_exist_by_pk(InstructionDocumentRepository(), doc_id) return values
def doc_must_exist(cls, v: int): must_exist_by_pk(InstructionDocumentRepository(), v) return v
def page_must_exist(cls, v: int): must_exist_by_pk(InstructionDocumentPageRepository(), v) return v
def user_must_exist(cls, v: int): must_exist_by_pk(UserRepository(), v) return v