async def create_console_subject(connect_id, subject: ConsoleSpaceSubject = Body(...), current_user: User = Depends(deps.get_current_user)): if check_fake_id(subject.subjectId): subject.subjectId = None console_space = load_console_space_by_id(connect_id) for report in subject.reports: report.reportId = get_surrogate_key() subject.reportIds.append(report.reportId) subject = create_console_subject_to_storage(subject) console_space.subjectIds.append(subject.subjectId) save_console_space(console_space) return subject else: raise Exception("id is not fake ID")
async def save_console_subject(subject: ConsoleSpaceSubject, current_user: User = Depends( deps.get_current_user)): subject.reports = [] return update_console_subject(subject)
def create_console_subject_to_storage(subject: ConsoleSpaceSubject): if subject.subjectId is None or check_fake_id(subject.subjectId): subject.subjectId = get_surrogate_key() return template.create(CONSOLE_SPACE_SUBJECTS, subject, ConsoleSpaceSubject)