From 9f71832a822be0abffc406038465f9553d908939 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 08:49:01 +0100 Subject: [PATCH 01/87] add childanswers and base answer model --- .../src/mondey_backend/models/questions.py | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/mondey_backend/src/mondey_backend/models/questions.py b/mondey_backend/src/mondey_backend/models/questions.py index e74c9240..a9f66653 100644 --- a/mondey_backend/src/mondey_backend/models/questions.py +++ b/mondey_backend/src/mondey_backend/models/questions.py @@ -30,29 +30,35 @@ class UserQuestionTextPublic(UserQuestionTextBase): class UserQuestion(SQLModel, table=True): id: int | None = Field(default=None, primary_key=True) order: int = 0 - input: str = "text" + component: str = "select" + type: str = "text" options: str = "" text: Mapped[dict[str, UserQuestionText]] = dict_relationship(key="lang_id") + additional_option: str = "" class UserQuestionPublic(SQLModel): id: int - input: str + component: str = "select" + type: str = "text" text: dict[str, UserQuestionTextPublic] = {} + additional_option: str = "" class UserQuestionAdmin(SQLModel): id: int order: int - input: str + component: str = "select" + type: str = "text" options: str text: dict[str, UserQuestionText] = {} + additional_option: str = "" # Answers to user questions. Internal model and 'public' model exposed to the forntend app -class UserAnswer(SQLModel, table=True): +class Answer(SQLModel): """ Internal model for user answers. @@ -69,11 +75,21 @@ class UserAnswer(SQLModel, table=True): default=None, primary_key=True, foreign_key="userquestion.id" ) answer: str - # flag that tells the frontend if the answer has been given via an additional text field => won´t be correctly displayed otherwise - non_standard: bool + additional_answer: str | None -class UserAnswerPublic(SQLModel): +class UserAnswer(Answer, table=True): + pass + + +class ChildAnswer(Answer, table=True): + child_id: int = Field( + default=None, + primary_key=True, + ) + + +class AnswerPublic(SQLModel): """ External data model for UserAnswers @@ -84,4 +100,12 @@ class UserAnswerPublic(SQLModel): answer: str question_id: int - non_standard: bool + additional_answer: str | None + + +class UserAnswerPublic(AnswerPublic): + pass + + +class ChildAnswerPublic(AnswerPublic): + child_id: int From 4e0311d0b59215bfc3e263afeb9aa99bc9b0b520 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 09:01:00 +0100 Subject: [PATCH 02/87] add child question models --- .../src/mondey_backend/models/questions.py | 90 ++++++++++++++----- 1 file changed, 70 insertions(+), 20 deletions(-) diff --git a/mondey_backend/src/mondey_backend/models/questions.py b/mondey_backend/src/mondey_backend/models/questions.py index a9f66653..fe1395ea 100644 --- a/mondey_backend/src/mondey_backend/models/questions.py +++ b/mondey_backend/src/mondey_backend/models/questions.py @@ -8,12 +8,13 @@ from .utils import fixed_length_string_field -class UserQuestionTextBase(SQLModel): +# Base model for all questions text elements +class QuestionTextBase(SQLModel): question: str = "" options_json: str = "" -class UserQuestionText(UserQuestionTextBase, table=True): +class QuestionText(QuestionTextBase): user_question_id: int | None = Field( default=None, foreign_key="userquestion.id", primary_key=True ) @@ -23,51 +24,69 @@ class UserQuestionText(UserQuestionTextBase, table=True): options: str = "" -class UserQuestionTextPublic(UserQuestionTextBase): +class QuestionTextPublic(QuestionTextBase): pass -class UserQuestion(SQLModel, table=True): +class Question(SQLModel, table=True): id: int | None = Field(default=None, primary_key=True) order: int = 0 component: str = "select" type: str = "text" options: str = "" - text: Mapped[dict[str, UserQuestionText]] = dict_relationship(key="lang_id") + text: Mapped[dict[str, QuestionText]] = dict_relationship(key="lang_id") additional_option: str = "" -class UserQuestionPublic(SQLModel): +class QuestionPublic(SQLModel): id: int component: str = "select" type: str = "text" - text: dict[str, UserQuestionTextPublic] = {} + text: dict[str, QuestionTextPublic] = {} additional_option: str = "" -class UserQuestionAdmin(SQLModel): +class QuestionAdmin(SQLModel): id: int order: int component: str = "select" type: str = "text" options: str - text: dict[str, UserQuestionText] = {} + text: dict[str, QuestionText] = {} additional_option: str = "" -# Answers to user questions. Internal model and 'public' model exposed to the forntend app +class UserQuestion(Question, table=True): + pass + + +class UserQuestionPublic(QuestionPublic): + pass + + +class UserQuestionAdmin(QuestionAdmin): + pass + + +class ChildQuestion(Question, table=True): + pass + + +class ChildQuestionPublic(QuestionPublic): + pass + + +class ChildQuestionAdmin(QuestionAdmin): + pass class Answer(SQLModel): """ - Internal model for user answers. + Base Answer model for all internal data that holds answers to questions. Parameters ---------- - UserAnswerBase : Base type for all UserAnswer models - - table : bool, True - Makes sure this is created as a table in the database, by default True + SQLModel: Makes this into a pydantic model for an SQL table entry. """ user_id: int = Field(default=None, primary_key=True) @@ -79,19 +98,34 @@ class Answer(SQLModel): class UserAnswer(Answer, table=True): + """ + Internal model for UserAnswer with the same content as the base `Answer` type. + + Parameters + ---------- + Answer : Base Answer model for all internal data that holds answers to questions. + table : bool, optional + Makes this a SQL table + """ + pass class ChildAnswer(Answer, table=True): - child_id: int = Field( - default=None, - primary_key=True, - ) + """ + Internal model for child answer data which adds the child ID. + + Parameters + ---------- + AnswerPublic : Basic Model for all Answers to questions in Mondey + """ + + child_id: int = Field(default=None, primary_key=True, foreign_key="child.id") class AnswerPublic(SQLModel): """ - External data model for UserAnswers + Internal data model for UserAnswers Parameters ---------- @@ -104,8 +138,24 @@ class AnswerPublic(SQLModel): class UserAnswerPublic(AnswerPublic): + """ + Model for public user answer data with the same content as AnswerPublic + + Parameters + ---------- + AnswerPublic : Basic Model for all Answers to questions in Mondey + """ + pass class ChildAnswerPublic(AnswerPublic): + """ + Model for public child answer data which adds the child ID. + + Parameters + ---------- + AnswerPublic : Basic Model for all Answers to questions in Mondey + """ + child_id: int From 6c29ad0319dc74392d7870ed1aed382ed404fb7e Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 09:19:08 +0100 Subject: [PATCH 03/87] add question admin endpoints --- .../src/mondey_backend/models/questions.py | 2 +- .../src/mondey_backend/routers/admin.py | 50 +++++++++++++++++-- .../src/mondey_backend/routers/questions.py | 9 ++++ .../src/mondey_backend/routers/utils.py | 13 +++-- 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/mondey_backend/src/mondey_backend/models/questions.py b/mondey_backend/src/mondey_backend/models/questions.py index fe1395ea..8cd03a2f 100644 --- a/mondey_backend/src/mondey_backend/models/questions.py +++ b/mondey_backend/src/mondey_backend/models/questions.py @@ -15,7 +15,7 @@ class QuestionTextBase(SQLModel): class QuestionText(QuestionTextBase): - user_question_id: int | None = Field( + question_id: int | None = Field( default=None, foreign_key="userquestion.id", primary_key=True ) lang_id: str | None = fixed_length_string_field( diff --git a/mondey_backend/src/mondey_backend/routers/admin.py b/mondey_backend/src/mondey_backend/routers/admin.py index 24a49f47..a68fdcb3 100644 --- a/mondey_backend/src/mondey_backend/routers/admin.py +++ b/mondey_backend/src/mondey_backend/routers/admin.py @@ -19,12 +19,15 @@ from ..models.milestones import MilestoneGroupText from ..models.milestones import MilestoneImage from ..models.milestones import MilestoneText +from ..models.questions import ChildQuestion +from ..models.questions import ChildQuestionAdmin +from ..models.questions import QuestionText from ..models.questions import UserQuestion from ..models.questions import UserQuestionAdmin -from ..models.questions import UserQuestionText from ..settings import app_settings from .utils import add from .utils import get +from .utils import update_child_question_text from .utils import update_milestone_group_text from .utils import update_milestone_text from .utils import update_user_question_text @@ -174,9 +177,7 @@ def create_user_question(session: SessionDep): user_question = UserQuestion() add(session, user_question) for language in session.exec(select(Language)).all(): - session.add( - UserQuestionText(user_question_id=user_question.id, lang_id=language.id) - ) + session.add(QuestionText(question_id=user_question.id, lang_id=language.id)) session.commit() session.refresh(user_question) return user_question @@ -200,4 +201,45 @@ def delete_user_question(session: SessionDep, user_question_id: int): session.commit() return {"ok": True} + @router.get("/child-questions/", response_model=list[ChildQuestionAdmin]) + def get_child_questions_admin(session: SessionDep): + user_questions = session.exec( + select(ChildQuestion).order_by(col(ChildQuestion.order)) + ).all() + return user_questions + + @router.post("/child-questions/", response_model=ChildQuestionAdmin) + def create_child_question( + session: SessionDep, + ): + child_question = ChildQuestion() + add(session, child_question) + for language in session.exec(select(Language)).all(): + session.add( + QuestionText(question_id=child_question.id, lang_id=language.id) + ) + session.commit() + session.refresh(child_question) + return child_question + + @router.put("/child-questions/", response_model=ChildQuestionAdmin) + def update_child_question( + session: SessionDep, + child_question: ChildQuestionAdmin, + ): + db_child_question = get(session, ChildQuestion, child_question.id) + + for key, value in child_question.model_dump(exclude={"text"}).items(): + setattr(db_child_question, key, value) + update_child_question_text(session, child_question) + add(session, db_child_question) + return db_child_question + + @router.delete("/child-questions/{child_question_id}") + def delete_child_question(session: SessionDep, child_question_id: int): + question = get(session, ChildQuestion, child_question_id) + session.delete(question) + session.commit() + return {"ok": True} + return router diff --git a/mondey_backend/src/mondey_backend/routers/questions.py b/mondey_backend/src/mondey_backend/routers/questions.py index 354baf35..a5975702 100644 --- a/mondey_backend/src/mondey_backend/routers/questions.py +++ b/mondey_backend/src/mondey_backend/routers/questions.py @@ -5,6 +5,8 @@ from sqlmodel import select from ..dependencies import SessionDep +from ..models.questions import ChildQuestion +from ..models.questions import ChildQuestionPublic from ..models.questions import UserQuestion from ..models.questions import UserQuestionPublic @@ -22,4 +24,11 @@ def get_user_questions( return user_questions + @router.get("/child-questions/", response_model=list[ChildQuestionPublic]) + def get_child_questions(session: SessionDep): + child_questions = session.exec( + select(ChildQuestion).order_by(col(ChildQuestion.order)) + ).all() + return child_questions + return router diff --git a/mondey_backend/src/mondey_backend/routers/utils.py b/mondey_backend/src/mondey_backend/routers/utils.py index 89ab0e7e..05600278 100644 --- a/mondey_backend/src/mondey_backend/routers/utils.py +++ b/mondey_backend/src/mondey_backend/routers/utils.py @@ -18,11 +18,12 @@ from ..models.milestones import MilestoneGroupAdmin from ..models.milestones import MilestoneGroupText from ..models.milestones import MilestoneText +from ..models.questions import ChildQuestionAdmin +from ..models.questions import QuestionText from ..models.questions import UserQuestionAdmin -from ..models.questions import UserQuestionText from ..users import User -Text = MilestoneText | MilestoneGroupText | UserQuestionText +Text = MilestoneText | MilestoneGroupText | QuestionText def write_file(file: UploadFile, filename: str): @@ -80,9 +81,11 @@ def update_milestone_group_text( def update_user_question_text(session: SessionDep, user_question: UserQuestionAdmin): - _update_text( - session, UserQuestionText, user_question.text.values(), user_question.id - ) + _update_text(session, QuestionText, user_question.text.values(), user_question.id) + + +def update_child_question_text(session: SessionDep, child_question: ChildQuestionAdmin): + _update_text(session, QuestionText, child_question.text.values(), child_question.id) def _session_has_expired(milestone_answer_session: MilestoneAnswerSession) -> bool: From 9c226d578806bbd0bd5988a9fd62a515d78d655c Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 10:30:27 +0100 Subject: [PATCH 04/87] make current tests work again --- .../src/mondey_backend/models/questions.py | 42 ++++++++++++------- mondey_backend/tests/conftest.py | 12 +++++- mondey_backend/tests/routers/test_users.py | 40 +++++++++--------- 3 files changed, 57 insertions(+), 37 deletions(-) diff --git a/mondey_backend/src/mondey_backend/models/questions.py b/mondey_backend/src/mondey_backend/models/questions.py index 8cd03a2f..80d955f3 100644 --- a/mondey_backend/src/mondey_backend/models/questions.py +++ b/mondey_backend/src/mondey_backend/models/questions.py @@ -8,36 +8,34 @@ from .utils import fixed_length_string_field -# Base model for all questions text elements +# Base model classes for all questions text elements. Does not define any tables itself, but only the basic structure. These are not intended for direct use! +# Create derived models that implemenet proper key relations with descriptive names instead and use those in your endpoints class QuestionTextBase(SQLModel): question: str = "" options_json: str = "" class QuestionText(QuestionTextBase): - question_id: int | None = Field( - default=None, foreign_key="userquestion.id", primary_key=True - ) + question_id: int | None lang_id: str | None = fixed_length_string_field( max_length=2, default=None, foreign_key="language.id", primary_key=True ) options: str = "" -class QuestionTextPublic(QuestionTextBase): - pass - - -class Question(SQLModel, table=True): +class Question(SQLModel): id: int | None = Field(default=None, primary_key=True) order: int = 0 component: str = "select" type: str = "text" options: str = "" - text: Mapped[dict[str, QuestionText]] = dict_relationship(key="lang_id") additional_option: str = "" +class QuestionTextPublic(QuestionTextBase): + pass + + class QuestionPublic(SQLModel): id: int component: str = "select" @@ -56,23 +54,37 @@ class QuestionAdmin(SQLModel): additional_option: str = "" +# User Question classes +class UserQuestionText(QuestionText, table=True): + question_id: int | None = Field( + default=None, foreign_key="userquestion.id", primary_key=True + ) + + +class ChildQuestionText(QuestionText, table=True): + question_id: int | None = Field( + default=None, foreign_key="childquestion.id", primary_key=True + ) + + class UserQuestion(Question, table=True): - pass + text: Mapped[dict[str, UserQuestionText]] = dict_relationship(key="lang_id") class UserQuestionPublic(QuestionPublic): pass -class UserQuestionAdmin(QuestionAdmin): - pass +# Child question classes +class ChildQuestion(Question, table=True): + text: Mapped[dict[str, ChildQuestionText]] = dict_relationship(key="lang_id") -class ChildQuestion(Question, table=True): +class ChildQuestionPublic(QuestionPublic): pass -class ChildQuestionPublic(QuestionPublic): +class UserQuestionAdmin(QuestionAdmin): pass diff --git a/mondey_backend/tests/conftest.py b/mondey_backend/tests/conftest.py index ecccff34..d4976a6d 100644 --- a/mondey_backend/tests/conftest.py +++ b/mondey_backend/tests/conftest.py @@ -178,12 +178,20 @@ def session(): # add user answers for user 1 session.add( UserAnswer( - id=1, question_id=1, user_id=1, answer="lorem ipsum", non_standard=False + id=1, + question_id=1, + user_id=1, + answer="lorem ipsum", + additional_answer=None, ) ) session.add( UserAnswer( - id=2, question_id=2, user_id=1, answer="dolor sit", non_standard=True + id=2, + question_id=2, + user_id=1, + answer="other", + additional_answer="dolor sit", ) ) diff --git a/mondey_backend/tests/routers/test_users.py b/mondey_backend/tests/routers/test_users.py index 0f4b7b74..a0def375 100644 --- a/mondey_backend/tests/routers/test_users.py +++ b/mondey_backend/tests/routers/test_users.py @@ -193,8 +193,8 @@ def test_get_current_user_answers_works(user_client: TestClient): response = user_client.get("/users/user-answers/") assert response.status_code == 200 assert response.json() == [ - {"answer": "lorem ipsum", "non_standard": False, "question_id": 1}, - {"answer": "dolor sit", "non_standard": True, "question_id": 2}, + {"answer": "lorem ipsum", "additional_answer": None, "question_id": 1}, + {"answer": "other", "additional_answer": "dolor sit", "question_id": 2}, ] @@ -208,14 +208,14 @@ def test_update_current_answers_prexisting(user_client: TestClient): "/users/user-answers/", json=[ { - "answer": "dolor", + "answer": "other", "question_id": 1, - "non_standard": True, + "additional_answer": "dolor", }, { "answer": "amet", "question_id": 2, - "non_standard": False, + "additional_answer": None, }, ], ) @@ -223,14 +223,14 @@ def test_update_current_answers_prexisting(user_client: TestClient): assert response.status_code == 200 assert response.json() == [ { - "answer": "dolor", + "answer": "other", "question_id": 1, - "non_standard": True, + "additional_answer": "dolor", }, { "answer": "amet", "question_id": 2, - "non_standard": False, + "additional_answer": None, }, ] @@ -238,14 +238,14 @@ def test_update_current_answers_prexisting(user_client: TestClient): assert response.status_code == 200 assert response.json() == [ { - "answer": "dolor", + "answer": "other", "question_id": 1, - "non_standard": True, + "additional_answer": "dolor", }, { "answer": "amet", "question_id": 2, - "non_standard": False, + "additional_answer": None, }, ] @@ -255,14 +255,14 @@ def test_update_current_answers_no_prexisting(second_user_client: TestClient): "/users/user-answers/", json=[ { - "answer": "dolor", + "answer": "other", "question_id": 1, - "non_standard": True, + "additional_answer": "dolor", }, { "answer": "amet", "question_id": 2, - "non_standard": False, + "additional_answer": None, }, ], ) @@ -270,14 +270,14 @@ def test_update_current_answers_no_prexisting(second_user_client: TestClient): assert response.status_code == 200 assert response.json() == [ { - "answer": "dolor", + "answer": "other", "question_id": 1, - "non_standard": True, + "additional_answer": "dolor", }, { "answer": "amet", "question_id": 2, - "non_standard": False, + "additional_answer": None, }, ] @@ -285,13 +285,13 @@ def test_update_current_answers_no_prexisting(second_user_client: TestClient): assert response.status_code == 200 assert response.json() == [ { - "answer": "dolor", + "answer": "other", "question_id": 1, - "non_standard": True, + "additional_answer": "dolor", }, { "answer": "amet", "question_id": 2, - "non_standard": False, + "additional_answer": None, }, ] From 13e8ea9211f178b098e8db5a136f7bec03759e7e Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 10:53:47 +0100 Subject: [PATCH 05/87] adjust imports, add test skeleton --- .../src/mondey_backend/routers/admin.py | 2 + .../src/mondey_backend/routers/users.py | 38 ++++++++ mondey_backend/tests/routers/test_admin.py | 89 +++++++++++++++++++ 3 files changed, 129 insertions(+) diff --git a/mondey_backend/src/mondey_backend/routers/admin.py b/mondey_backend/src/mondey_backend/routers/admin.py index a68fdcb3..04e749e7 100644 --- a/mondey_backend/src/mondey_backend/routers/admin.py +++ b/mondey_backend/src/mondey_backend/routers/admin.py @@ -165,6 +165,7 @@ async def upload_milestone_image( session.refresh(milestone_image) return milestone_image + # User question CRUD endpoints @router.get("/user-questions/", response_model=list[UserQuestionAdmin]) def get_user_questions_admin(session: SessionDep): user_questions = session.exec( @@ -201,6 +202,7 @@ def delete_user_question(session: SessionDep, user_question_id: int): session.commit() return {"ok": True} + # Child question CRUD endpoints @router.get("/child-questions/", response_model=list[ChildQuestionAdmin]) def get_child_questions_admin(session: SessionDep): user_questions = session.exec( diff --git a/mondey_backend/src/mondey_backend/routers/users.py b/mondey_backend/src/mondey_backend/routers/users.py index 49618871..a2d10b13 100644 --- a/mondey_backend/src/mondey_backend/routers/users.py +++ b/mondey_backend/src/mondey_backend/routers/users.py @@ -18,6 +18,8 @@ from ..models.milestones import MilestoneAnswerPublic from ..models.milestones import MilestoneAnswerSession from ..models.milestones import MilestoneAnswerSessionPublic +from ..models.questions import ChildAnswer +from ..models.questions import ChildAnswerPublic from ..models.questions import UserAnswer from ..models.questions import UserAnswerPublic from ..models.users import UserRead @@ -187,4 +189,40 @@ def update_current_user_answers( session.commit() return new_answers + # Endpoints for answers to child question + @router.get("/children-answers/", response_model=list[ChildAnswerPublic]) + def get_current_children_answers( + session: SessionDep, current_active_user: CurrentActiveUserDep + ): + answers = session.exec( + select(ChildAnswer).where( + col(ChildAnswer.user_id) == current_active_user.id + ) + ).all() + + return answers + + @router.put("/children-answers/", response_model=list[ChildAnswerPublic]) + def update_current_children_answers( + session: SessionDep, + current_active_user: CurrentActiveUserDep, + new_answers: list[ChildAnswerPublic], + ): + for new_answer in new_answers: + current_answer = session.get( + ChildAnswer, (current_active_user.id, new_answer.question_id) + ) + + if current_answer is None: + current_answer = ChildAnswer.model_validate( + new_answer, update={"user_id": current_active_user.id} + ) + add(session, current_answer) + else: + for key, value in new_answer.model_dump().items(): + setattr(current_answer, key, value) + + session.commit() + return new_answers + return router diff --git a/mondey_backend/tests/routers/test_admin.py b/mondey_backend/tests/routers/test_admin.py index 18e84e0a..16bd1e31 100644 --- a/mondey_backend/tests/routers/test_admin.py +++ b/mondey_backend/tests/routers/test_admin.py @@ -248,3 +248,92 @@ def test_post_milestone_image( assert len(admin_client.get("/milestones/3").json()["images"]) == 1 assert len(admin_client.get("/milestones/4").json()["images"]) == 1 assert len(admin_client.get("/milestones/5").json()["images"]) == 1 + + +# tests for user questions +def test_get_user_question_admin_works(): + assert 3 == 5 + + +def test_get_user_question_admin_userid_not_there(): + assert 3 == 5 + + +def test_create_user_question_works(): + assert 3 == 5 + + +def test_create_user_question_id_exists(): + assert 3 == 5 + + +def test_create_user_question_id_database_error(): + assert 3 == 5 + + +def test_update_user_question_works(): + assert 3 == 5 + + +def test_update_user_question_id_not_there(): + assert 3 == 5 + + +def test_update_user_question_database_error(): + assert 3 == 5 + + +def test_delete_user_question_works(): + assert 3 == 5 + + +def test_delete_user_question_id_not_there(): + assert 3 == 5 + + +def test_delete_user_question_database_error(): + assert 3 == 5 + + +def test_get_child_question_admin_works(): + assert 3 == 5 + + +def test_get_child_question_admin_userid_not_there(): + assert 3 == 5 + + +def test_create_child_question_works(): + assert 3 == 5 + + +def test_create_child_question_id_exists(): + assert 3 == 5 + + +def test_create_child_question_id_database_error(): + assert 3 == 5 + + +def test_update_child_question_works(): + assert 3 == 5 + + +def test_update_child_question_id_not_there(): + assert 3 == 5 + + +def test_update_child_question_database_error(): + assert 3 == 5 + + +def test_delete_child_question_works(): + assert 3 == 5 + + +def test_delete_child_question_id_not_there(): + assert 3 == 5 + + +def test_delete_child_question_database_error(): + assert 3 == 5 From ebf850f03c59dede166971ad2a812562041fe2d5 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 11:10:43 +0100 Subject: [PATCH 06/87] add dummy questions to test fixtures --- mondey_backend/tests/conftest.py | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/mondey_backend/tests/conftest.py b/mondey_backend/tests/conftest.py index d4976a6d..ca3d6839 100644 --- a/mondey_backend/tests/conftest.py +++ b/mondey_backend/tests/conftest.py @@ -26,7 +26,11 @@ from mondey_backend.models.milestones import MilestoneGroupText from mondey_backend.models.milestones import MilestoneImage from mondey_backend.models.milestones import MilestoneText +from mondey_backend.models.questions import ChildQuestion +from mondey_backend.models.questions import ChildQuestionText from mondey_backend.models.questions import UserAnswer +from mondey_backend.models.questions import UserQuestion +from mondey_backend.models.questions import UserQuestionText from mondey_backend.models.users import UserRead @@ -175,6 +179,72 @@ def session(): ) session.add(MilestoneAnswer(answer_session_id=3, milestone_id=7, answer=2)) + # add user questions for user 1 + session.add( + UserQuestion( + id=1, + order=0, + options="[a,b,c,other]", + additional_option="", + text={ + "de": UserQuestionText(question_id=1, lang_id=1, options="[x,y,z]"), + "en": UserQuestionText(question_id=1, lang_id=2, options="[1,2,3]"), + }, + ) + ) + + session.add( + UserQuestion( + id=2, + order=1, + options="[a2,b2,c2,other]", + additional_option="other", + text={ + "de": UserQuestionText( + question_id=2, lang_id=1, options="[x2,y2,z2]" + ), + "en": UserQuestionText( + question_id=2, lang_id=2, options="[12,22,32]" + ), + }, + ) + ) + + # add child questions for user 1 + session.add( + ChildQuestion( + id=1, + order=0, + options="[a,b,c,other]", + additional_option="", + text={ + "de": ChildQuestionText( + question_id=1, lang_id=1, options="[x,y,z]" + ), + "en": ChildQuestionText( + question_id=1, lang_id=2, options="[1,2,3]" + ), + }, + ) + ) + + session.add( + ChildQuestion( + id=2, + order=1, + options="[a2,b2,c2,other]", + additional_option="other", + text={ + "de": ChildQuestionText( + question_id=2, lang_id=1, options="[x2,y2,z2]" + ), + "en": ChildQuestionText( + question_id=2, lang_id=2, options="[12,22,32]" + ), + }, + ) + ) + # add user answers for user 1 session.add( UserAnswer( @@ -195,6 +265,8 @@ def session(): ) ) + # add child answers for user 1 + yield session From c001d855731e05e4b7f13de9b9ecfc5c61ab24f6 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 11:37:15 +0100 Subject: [PATCH 07/87] start working on backend tests --- .../src/mondey_backend/models/questions.py | 1 - .../src/mondey_backend/routers/admin.py | 9 ++- mondey_backend/tests/conftest.py | 47 +++++++++++----- mondey_backend/tests/routers/test_admin.py | 56 +++++++++++++++++-- 4 files changed, 90 insertions(+), 23 deletions(-) diff --git a/mondey_backend/src/mondey_backend/models/questions.py b/mondey_backend/src/mondey_backend/models/questions.py index 80d955f3..361ec6b8 100644 --- a/mondey_backend/src/mondey_backend/models/questions.py +++ b/mondey_backend/src/mondey_backend/models/questions.py @@ -16,7 +16,6 @@ class QuestionTextBase(SQLModel): class QuestionText(QuestionTextBase): - question_id: int | None lang_id: str | None = fixed_length_string_field( max_length=2, default=None, foreign_key="language.id", primary_key=True ) diff --git a/mondey_backend/src/mondey_backend/routers/admin.py b/mondey_backend/src/mondey_backend/routers/admin.py index 04e749e7..27bd6a9b 100644 --- a/mondey_backend/src/mondey_backend/routers/admin.py +++ b/mondey_backend/src/mondey_backend/routers/admin.py @@ -21,9 +21,10 @@ from ..models.milestones import MilestoneText from ..models.questions import ChildQuestion from ..models.questions import ChildQuestionAdmin -from ..models.questions import QuestionText +from ..models.questions import ChildQuestionText from ..models.questions import UserQuestion from ..models.questions import UserQuestionAdmin +from ..models.questions import UserQuestionText from ..settings import app_settings from .utils import add from .utils import get @@ -178,7 +179,9 @@ def create_user_question(session: SessionDep): user_question = UserQuestion() add(session, user_question) for language in session.exec(select(Language)).all(): - session.add(QuestionText(question_id=user_question.id, lang_id=language.id)) + session.add( + UserQuestionText(question_id=user_question.id, lang_id=language.id) + ) session.commit() session.refresh(user_question) return user_question @@ -218,7 +221,7 @@ def create_child_question( add(session, child_question) for language in session.exec(select(Language)).all(): session.add( - QuestionText(question_id=child_question.id, lang_id=language.id) + ChildQuestionText(question_id=child_question.id, lang_id=language.id) ) session.commit() session.refresh(child_question) diff --git a/mondey_backend/tests/conftest.py b/mondey_backend/tests/conftest.py index ca3d6839..274bf200 100644 --- a/mondey_backend/tests/conftest.py +++ b/mondey_backend/tests/conftest.py @@ -183,12 +183,22 @@ def session(): session.add( UserQuestion( id=1, - order=0, + order=1, options="[a,b,c,other]", - additional_option="", + additional_option="other", text={ - "de": UserQuestionText(question_id=1, lang_id=1, options="[x,y,z]"), - "en": UserQuestionText(question_id=1, lang_id=2, options="[1,2,3]"), + "de": UserQuestionText( + question_id=1, + lang_id=1, + options="[x,y,z]", + question="Wo sonst?", + ), + "en": UserQuestionText( + question_id=1, + lang_id=2, + options="[1,2,3]", + question="Where else?", + ), }, ) ) @@ -196,15 +206,22 @@ def session(): session.add( UserQuestion( id=2, - order=1, + order=2, + componet="textarea", options="[a2,b2,c2,other]", additional_option="other", text={ "de": UserQuestionText( - question_id=2, lang_id=1, options="[x2,y2,z2]" + question_id=2, + lang_id=1, + options="[x2,y2,z2]", + question="Was noch?", ), "en": UserQuestionText( - question_id=2, lang_id=2, options="[12,22,32]" + question_id=2, + lang_id=2, + options="[12,22,32]", + question="What else?", ), }, ) @@ -218,12 +235,8 @@ def session(): options="[a,b,c,other]", additional_option="", text={ - "de": ChildQuestionText( - question_id=1, lang_id=1, options="[x,y,z]" - ), - "en": ChildQuestionText( - question_id=1, lang_id=2, options="[1,2,3]" - ), + "de": ChildQuestionText(question_id=1, lang_id=1, question="was?"), + "en": ChildQuestionText(question_id=1, lang_id=2, question="what?"), }, ) ) @@ -236,10 +249,14 @@ def session(): additional_option="other", text={ "de": ChildQuestionText( - question_id=2, lang_id=1, options="[x2,y2,z2]" + question_id=2, + lang_id=1, + question="Wo?", ), "en": ChildQuestionText( - question_id=2, lang_id=2, options="[12,22,32]" + question_id=2, + lang_id=2, + question="Where?", ), }, ) diff --git a/mondey_backend/tests/routers/test_admin.py b/mondey_backend/tests/routers/test_admin.py index 16bd1e31..b5edf1a3 100644 --- a/mondey_backend/tests/routers/test_admin.py +++ b/mondey_backend/tests/routers/test_admin.py @@ -251,12 +251,60 @@ def test_post_milestone_image( # tests for user questions -def test_get_user_question_admin_works(): - assert 3 == 5 -def test_get_user_question_admin_userid_not_there(): - assert 3 == 5 +def test_get_user_question_admin_works(admin_client: TestClient): + response = admin_client.get("/admin/user-questions") + + assert response.status_code == 200 + + assert [element["order"] for element in response.json()] == [1, 2] + assert response.json() == [ + { + "id": 1, + "order": 1, + "component": "select", + "options": "[a,b,c,other]", + "additional_option": "other", + "type": "text", + "text": { + "de": { + "question_id": "1", + "lang_id": "1", + "options": "[x,y,z]", + "question": "Wo sonst?", + }, + "en": { + "question_id": "1", + "lang_id": "2", + "options": "[1,2,3]", + "question": "Where else?", + }, + }, + }, + { + "id": 2, + "order": 2, + "component": "textarea", + "options": "[a2,b2,c2,other]", + "additional_option": "other", + "type": "text", + "text": { + "de": { + "question_id": "2", + "lang_id": "1", + "options": "[x2,y2,z2]", + "question": "Was noch?", + }, + "en": { + "question_id": "2", + "lang_id": "2", + "options": "[12,22,32]", + "question": "What else?", + }, + }, + }, + ] def test_create_user_question_works(): From 2866ab9202d00ddc0471e2d489b3f0844b0d5e35 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 13:42:13 +0100 Subject: [PATCH 08/87] work more on backend tests and model inheritance --- mondey_backend/openapi.json | 2 +- .../src/mondey_backend/models/questions.py | 6 +- .../src/mondey_backend/routers/admin.py | 2 + mondey_backend/tests/conftest.py | 51 +++++++----- mondey_backend/tests/routers/test_admin.py | 80 ++++++++++++++++--- 5 files changed, 108 insertions(+), 33 deletions(-) diff --git a/mondey_backend/openapi.json b/mondey_backend/openapi.json index e5131133..37c837b8 100644 --- a/mondey_backend/openapi.json +++ b/mondey_backend/openapi.json @@ -1 +1 @@ -{"openapi": "3.1.0", "info": {"title": "MONDEY API", "version": "0.1.0"}, "paths": {"/languages/": {"get": {"tags": ["milestones"], "summary": "Get Languages", "operationId": "get_languages", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"type": "string"}, "type": "array", "title": "Response Get Languages Languages Get"}}}}}}}, "/milestones/": {"get": {"tags": ["milestones"], "summary": "Get Milestones", "operationId": "get_milestones", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestonePublic"}, "type": "array", "title": "Response Get Milestones Milestones Get"}}}}}}}, "/milestones/{milestone_id}": {"get": {"tags": ["milestones"], "summary": "Get Milestone", "operationId": "get_milestone", "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestonePublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/milestone-groups/": {"get": {"tags": ["milestones"], "summary": "Get Milestone Groups", "operationId": "get_milestone_groups", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestoneGroupPublic"}, "type": "array", "title": "Response Get Milestone Groups Milestone Groups Get"}}}}}}}, "/milestone-groups/{milestone_group_id}": {"get": {"tags": ["milestones"], "summary": "Get Milestone Group", "operationId": "get_milestone_group", "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/user-questions/": {"get": {"tags": ["questions"], "summary": "Get User Questions", "operationId": "get_user_questions", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserQuestionPublic"}, "type": "array", "title": "Response Get User Questions User Questions Get"}}}}}}}, "/admin/languages/": {"post": {"tags": ["admin"], "summary": "Create Language", "operationId": "create_language", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Language"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Language"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/languages/{language_id}": {"delete": {"tags": ["admin"], "summary": "Delete Language", "operationId": "delete_language", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "language_id", "in": "path", "required": true, "schema": {"type": "string", "title": "Language Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/i18n/{language_id}": {"put": {"tags": ["admin"], "summary": "Update I18N", "operationId": "update_i18n", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "language_id", "in": "path", "required": true, "schema": {"type": "string", "title": "Language Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": {"type": "object", "additionalProperties": {"type": "string"}}, "title": "I18Dict"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-groups/": {"get": {"tags": ["admin"], "summary": "Get Milestone Groups Admin", "operationId": "get_milestone_groups_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}, "type": "array", "title": "Response Get Milestone Groups Admin Admin Milestone Groups Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create Milestone Group Admin", "operationId": "create_milestone_group_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestone-groups": {"put": {"tags": ["admin"], "summary": "Update Milestone Group Admin", "operationId": "update_milestone_group_admin", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestone-groups/{milestone_group_id}": {"delete": {"tags": ["admin"], "summary": "Delete Milestone Group Admin", "operationId": "delete_milestone_group_admin", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-group-images/{milestone_group_id}": {"put": {"tags": ["admin"], "summary": "Upload Milestone Group Image", "operationId": "upload_milestone_group_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestones/{milestone_group_id}": {"post": {"tags": ["admin"], "summary": "Create Milestone", "operationId": "create_milestone", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestones/": {"put": {"tags": ["admin"], "summary": "Update Milestone", "operationId": "update_milestone", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestones/{milestone_id}": {"delete": {"tags": ["admin"], "summary": "Delete Milestone", "operationId": "delete_milestone", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-images/{milestone_id}": {"post": {"tags": ["admin"], "summary": "Upload Milestone Image", "operationId": "upload_milestone_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_milestone_image_admin_milestone_images__milestone_id__post"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneImage"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/user-questions/": {"get": {"tags": ["admin"], "summary": "Get User Questions Admin", "operationId": "get_user_questions_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserQuestionAdmin"}, "type": "array", "title": "Response Get User Questions Admin Admin User Questions Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["admin"], "summary": "Update User Question", "operationId": "update_user_question", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create User Question", "operationId": "create_user_question", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/user-questions/{user_question_id}": {"delete": {"tags": ["admin"], "summary": "Delete User Question", "operationId": "delete_user_question", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "user_question_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "User Question Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/me": {"get": {"tags": ["users"], "summary": "Users:Current User", "operationId": "users:current_user", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}}, "security": [{"APIKeyCookie": []}]}, "patch": {"tags": ["users"], "summary": "Users:Patch Current User", "operationId": "users:patch_current_user", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserUpdate"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"UPDATE_USER_EMAIL_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS"}}, "UPDATE_USER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "UPDATE_USER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/{id}": {"get": {"tags": ["users"], "summary": "Users:User", "operationId": "users:user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "patch": {"tags": ["users"], "summary": "Users:Patch User", "operationId": "users:patch_user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserUpdate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "400": {"content": {"application/json": {"examples": {"UPDATE_USER_EMAIL_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS"}}, "UPDATE_USER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "UPDATE_USER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}, "schema": {"$ref": "#/components/schemas/ErrorModel"}}}, "description": "Bad Request"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "delete": {"tags": ["users"], "summary": "Users:Delete User", "operationId": "users:delete_user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "responses": {"204": {"description": "Successful Response"}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/children/": {"get": {"tags": ["users"], "summary": "Get Children", "operationId": "get_children", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildPublic"}, "type": "array", "title": "Response Get Children Users Children Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Child", "operationId": "update_child", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["users"], "summary": "Create Child", "operationId": "create_child", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildCreate"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/children/{child_id}": {"delete": {"tags": ["users"], "summary": "Delete Child", "operationId": "delete_child", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/children-images/{child_id}": {"get": {"tags": ["users"], "summary": "Get Child Image", "operationId": "get_child_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "put": {"tags": ["users"], "summary": "Upload Child Image", "operationId": "upload_child_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_child_image_users_children_images__child_id__put"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/milestone-answers/{child_id}": {"get": {"tags": ["users"], "summary": "Get Current Milestone Answer Session", "operationId": "get_current_milestone_answer_session", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerSessionPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/milestone-answers/{milestone_answer_session_id}": {"put": {"tags": ["users"], "summary": "Update Milestone Answer", "operationId": "update_milestone_answer", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_answer_session_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Answer Session Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/user-answers/": {"get": {"tags": ["users"], "summary": "Get Current User Answers", "operationId": "get_current_user_answers", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "Response Get Current User Answers Users User Answers Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Current User Answers", "operationId": "update_current_user_answers", "requestBody": {"content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "New Answers"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "Response Update Current User Answers Users User Answers Put"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/auth/login": {"post": {"tags": ["auth"], "summary": "Auth:Cookie.Login", "operationId": "auth:cookie.login", "requestBody": {"content": {"application/x-www-form-urlencoded": {"schema": {"$ref": "#/components/schemas/Body_auth_cookie_login_auth_login_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"LOGIN_BAD_CREDENTIALS": {"summary": "Bad credentials or the user is inactive.", "value": {"detail": "LOGIN_BAD_CREDENTIALS"}}, "LOGIN_USER_NOT_VERIFIED": {"summary": "The user is not verified.", "value": {"detail": "LOGIN_USER_NOT_VERIFIED"}}}}}}, "204": {"description": "No Content"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/logout": {"post": {"tags": ["auth"], "summary": "Auth:Cookie.Logout", "operationId": "auth:cookie.logout", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "401": {"description": "Missing token or inactive user."}, "204": {"description": "No Content"}}, "security": [{"APIKeyCookie": []}]}}, "/auth/register": {"post": {"tags": ["auth"], "summary": "Register:Register", "operationId": "register:register", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserCreate"}}}, "required": true}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"REGISTER_USER_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "REGISTER_USER_ALREADY_EXISTS"}}, "REGISTER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "REGISTER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/forgot-password": {"post": {"tags": ["auth"], "summary": "Reset:Forgot Password", "operationId": "reset:forgot_password", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_reset_forgot_password_auth_forgot_password_post"}}}, "required": true}, "responses": {"202": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/reset-password": {"post": {"tags": ["auth"], "summary": "Reset:Reset Password", "operationId": "reset:reset_password", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_reset_reset_password_auth_reset_password_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"RESET_PASSWORD_BAD_TOKEN": {"summary": "Bad or expired token.", "value": {"detail": "RESET_PASSWORD_BAD_TOKEN"}}, "RESET_PASSWORD_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "RESET_PASSWORD_INVALID_PASSWORD", "reason": "Password should be at least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/request-verify-token": {"post": {"tags": ["auth"], "summary": "Verify:Request-Token", "operationId": "verify:request-token", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_verify_request_token_auth_request_verify_token_post"}}}, "required": true}, "responses": {"202": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/verify": {"post": {"tags": ["auth"], "summary": "Verify:Verify", "operationId": "verify:verify", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_verify_verify_auth_verify_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"VERIFY_USER_BAD_TOKEN": {"summary": "Bad token, not existing user ornot the e-mail currently set for the user.", "value": {"detail": "VERIFY_USER_BAD_TOKEN"}}, "VERIFY_USER_ALREADY_VERIFIED": {"summary": "The user is already verified.", "value": {"detail": "VERIFY_USER_ALREADY_VERIFIED"}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/research/auth/": {"get": {"tags": ["research"], "summary": "Auth", "operationId": "auth", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}, "security": [{"APIKeyCookie": []}]}}}, "components": {"schemas": {"Body_auth_cookie_login_auth_login_post": {"properties": {"grant_type": {"anyOf": [{"type": "string", "pattern": "password"}, {"type": "null"}], "title": "Grant Type"}, "username": {"type": "string", "title": "Username"}, "password": {"type": "string", "title": "Password"}, "scope": {"type": "string", "title": "Scope", "default": ""}, "client_id": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Client Id"}, "client_secret": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Client Secret"}}, "type": "object", "required": ["username", "password"], "title": "Body_auth_cookie_login_auth_login_post"}, "Body_reset_forgot_password_auth_forgot_password_post": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}}, "type": "object", "required": ["email"], "title": "Body_reset_forgot_password_auth_forgot_password_post"}, "Body_reset_reset_password_auth_reset_password_post": {"properties": {"token": {"type": "string", "title": "Token"}, "password": {"type": "string", "title": "Password"}}, "type": "object", "required": ["token", "password"], "title": "Body_reset_reset_password_auth_reset_password_post"}, "Body_upload_child_image_users_children_images__child_id__put": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_child_image_users_children_images__child_id__put"}, "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put"}, "Body_upload_milestone_image_admin_milestone_images__milestone_id__post": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_milestone_image_admin_milestone_images__milestone_id__post"}, "Body_verify_request_token_auth_request_verify_token_post": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}}, "type": "object", "required": ["email"], "title": "Body_verify_request_token_auth_request_verify_token_post"}, "Body_verify_verify_auth_verify_post": {"properties": {"token": {"type": "string", "title": "Token"}}, "type": "object", "required": ["token"], "title": "Body_verify_verify_auth_verify_post"}, "ChildCreate": {"properties": {"name": {"type": "string", "title": "Name", "default": ""}, "birth_year": {"type": "integer", "title": "Birth Year"}, "birth_month": {"type": "integer", "title": "Birth Month"}}, "type": "object", "required": ["birth_year", "birth_month"], "title": "ChildCreate"}, "ChildPublic": {"properties": {"name": {"type": "string", "title": "Name", "default": ""}, "birth_year": {"type": "integer", "title": "Birth Year"}, "birth_month": {"type": "integer", "title": "Birth Month"}, "id": {"type": "integer", "title": "Id"}, "has_image": {"type": "boolean", "title": "Has Image"}}, "type": "object", "required": ["birth_year", "birth_month", "id", "has_image"], "title": "ChildPublic"}, "ErrorModel": {"properties": {"detail": {"anyOf": [{"type": "string"}, {"additionalProperties": {"type": "string"}, "type": "object"}], "title": "Detail"}}, "type": "object", "required": ["detail"], "title": "ErrorModel"}, "HTTPValidationError": {"properties": {"detail": {"items": {"$ref": "#/components/schemas/ValidationError"}, "type": "array", "title": "Detail"}}, "type": "object", "title": "HTTPValidationError"}, "Language": {"properties": {"id": {"type": "string", "maxLength": 2, "title": "Id"}}, "type": "object", "required": ["id"], "title": "Language"}, "MilestoneAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "group_id": {"type": "integer", "title": "Group Id"}, "order": {"type": "integer", "title": "Order"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneText"}, "type": "object", "title": "Text", "default": {}}, "images": {"items": {"$ref": "#/components/schemas/MilestoneImage"}, "type": "array", "title": "Images", "default": []}}, "type": "object", "required": ["id", "group_id", "order"], "title": "MilestoneAdmin"}, "MilestoneAnswerPublic": {"properties": {"milestone_id": {"type": "integer", "title": "Milestone Id"}, "answer": {"type": "integer", "title": "Answer"}}, "type": "object", "required": ["milestone_id", "answer"], "title": "MilestoneAnswerPublic"}, "MilestoneAnswerSessionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "child_id": {"type": "integer", "title": "Child Id"}, "created_at": {"type": "string", "format": "date-time", "title": "Created At"}, "answers": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}, "type": "object", "title": "Answers"}}, "type": "object", "required": ["id", "child_id", "created_at", "answers"], "title": "MilestoneAnswerSessionPublic"}, "MilestoneGroupAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneGroupText"}, "type": "object", "title": "Text", "default": {}}, "milestones": {"items": {"$ref": "#/components/schemas/MilestoneAdmin"}, "type": "array", "title": "Milestones", "default": []}}, "type": "object", "required": ["id", "order"], "title": "MilestoneGroupAdmin"}, "MilestoneGroupPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneGroupTextPublic"}, "type": "object", "title": "Text", "default": {}}, "milestones": {"items": {"$ref": "#/components/schemas/MilestonePublic"}, "type": "array", "title": "Milestones", "default": []}}, "type": "object", "required": ["id"], "title": "MilestoneGroupPublic"}, "MilestoneGroupText": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "group_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Group Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}}, "type": "object", "title": "MilestoneGroupText"}, "MilestoneGroupTextPublic": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}}, "type": "object", "title": "MilestoneGroupTextPublic"}, "MilestoneImage": {"properties": {"id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id"}, "milestone_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Milestone Id"}, "filename": {"type": "string", "title": "Filename", "default": ""}, "approved": {"type": "boolean", "title": "Approved", "default": false}}, "type": "object", "title": "MilestoneImage"}, "MilestoneImagePublic": {"properties": {"filename": {"type": "string", "title": "Filename"}, "approved": {"type": "boolean", "title": "Approved"}}, "type": "object", "required": ["filename", "approved"], "title": "MilestoneImagePublic"}, "MilestonePublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneTextPublic"}, "type": "object", "title": "Text", "default": {}}, "images": {"items": {"$ref": "#/components/schemas/MilestoneImagePublic"}, "type": "array", "title": "Images", "default": []}}, "type": "object", "required": ["id"], "title": "MilestonePublic"}, "MilestoneText": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "obs": {"type": "string", "title": "Obs", "default": ""}, "help": {"type": "string", "title": "Help", "default": ""}, "milestone_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Milestone Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}}, "type": "object", "title": "MilestoneText"}, "MilestoneTextPublic": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "obs": {"type": "string", "title": "Obs", "default": ""}, "help": {"type": "string", "title": "Help", "default": ""}}, "type": "object", "title": "MilestoneTextPublic"}, "UserAnswerPublic": {"properties": {"answer": {"type": "string", "title": "Answer"}, "question_id": {"type": "integer", "title": "Question Id"}, "non_standard": {"type": "boolean", "title": "Non Standard"}}, "type": "object", "required": ["answer", "question_id", "non_standard"], "title": "UserAnswerPublic", "description": "External data model for UserAnswers\n\nParameters\n----------\nSQLModel : Pydantic model basic sqlmodel pydantic type"}, "UserCreate": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}, "password": {"type": "string", "title": "Password"}, "is_active": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Active", "default": true}, "is_superuser": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Superuser", "default": false}, "is_verified": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Verified", "default": false}, "is_researcher": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Researcher", "default": false}}, "type": "object", "required": ["email", "password"], "title": "UserCreate"}, "UserQuestionAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "input": {"type": "string", "title": "Input"}, "options": {"type": "string", "title": "Options"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/UserQuestionText"}, "type": "object", "title": "Text", "default": {}}}, "type": "object", "required": ["id", "order", "input", "options"], "title": "UserQuestionAdmin"}, "UserQuestionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "input": {"type": "string", "title": "Input"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/UserQuestionTextPublic"}, "type": "object", "title": "Text", "default": {}}}, "type": "object", "required": ["id", "input"], "title": "UserQuestionPublic"}, "UserQuestionText": {"properties": {"question": {"type": "string", "title": "Question", "default": ""}, "options_json": {"type": "string", "title": "Options Json", "default": ""}, "user_question_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "User Question Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}, "options": {"type": "string", "title": "Options", "default": ""}}, "type": "object", "title": "UserQuestionText"}, "UserQuestionTextPublic": {"properties": {"question": {"type": "string", "title": "Question", "default": ""}, "options_json": {"type": "string", "title": "Options Json", "default": ""}}, "type": "object", "title": "UserQuestionTextPublic"}, "UserRead": {"properties": {"id": {"type": "integer", "title": "Id"}, "email": {"type": "string", "format": "email", "title": "Email"}, "is_active": {"type": "boolean", "title": "Is Active", "default": true}, "is_superuser": {"type": "boolean", "title": "Is Superuser", "default": false}, "is_verified": {"type": "boolean", "title": "Is Verified", "default": false}, "is_researcher": {"type": "boolean", "title": "Is Researcher"}}, "type": "object", "required": ["id", "email", "is_researcher"], "title": "UserRead"}, "UserUpdate": {"properties": {"password": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Password"}, "email": {"anyOf": [{"type": "string", "format": "email"}, {"type": "null"}], "title": "Email"}, "is_active": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Active"}, "is_superuser": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Superuser"}, "is_verified": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Verified"}, "is_researcher": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Researcher"}}, "type": "object", "title": "UserUpdate"}, "ValidationError": {"properties": {"loc": {"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, "type": "array", "title": "Location"}, "msg": {"type": "string", "title": "Message"}, "type": {"type": "string", "title": "Error Type"}}, "type": "object", "required": ["loc", "msg", "type"], "title": "ValidationError"}}, "securitySchemes": {"APIKeyCookie": {"type": "apiKey", "in": "cookie", "name": "fastapiusersauth"}}}} \ No newline at end of file +{"openapi": "3.1.0", "info": {"title": "MONDEY API", "version": "0.1.0"}, "paths": {"/languages/": {"get": {"tags": ["milestones"], "summary": "Get Languages", "operationId": "get_languages", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"type": "string"}, "type": "array", "title": "Response Get Languages Languages Get"}}}}}}}, "/milestones/": {"get": {"tags": ["milestones"], "summary": "Get Milestones", "operationId": "get_milestones", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestonePublic"}, "type": "array", "title": "Response Get Milestones Milestones Get"}}}}}}}, "/milestones/{milestone_id}": {"get": {"tags": ["milestones"], "summary": "Get Milestone", "operationId": "get_milestone", "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestonePublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/milestone-groups/": {"get": {"tags": ["milestones"], "summary": "Get Milestone Groups", "operationId": "get_milestone_groups", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestoneGroupPublic"}, "type": "array", "title": "Response Get Milestone Groups Milestone Groups Get"}}}}}}}, "/milestone-groups/{milestone_group_id}": {"get": {"tags": ["milestones"], "summary": "Get Milestone Group", "operationId": "get_milestone_group", "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/user-questions/": {"get": {"tags": ["questions"], "summary": "Get User Questions", "operationId": "get_user_questions", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserQuestionPublic"}, "type": "array", "title": "Response Get User Questions User Questions Get"}}}}}}}, "/child-questions/": {"get": {"tags": ["questions"], "summary": "Get Child Questions", "operationId": "get_child_questions", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildQuestionPublic"}, "type": "array", "title": "Response Get Child Questions Child Questions Get"}}}}}}}, "/admin/languages/": {"post": {"tags": ["admin"], "summary": "Create Language", "operationId": "create_language", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Language"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Language"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/languages/{language_id}": {"delete": {"tags": ["admin"], "summary": "Delete Language", "operationId": "delete_language", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "language_id", "in": "path", "required": true, "schema": {"type": "string", "title": "Language Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/i18n/{language_id}": {"put": {"tags": ["admin"], "summary": "Update I18N", "operationId": "update_i18n", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "language_id", "in": "path", "required": true, "schema": {"type": "string", "title": "Language Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": {"type": "object", "additionalProperties": {"type": "string"}}, "title": "I18Dict"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-groups/": {"get": {"tags": ["admin"], "summary": "Get Milestone Groups Admin", "operationId": "get_milestone_groups_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}, "type": "array", "title": "Response Get Milestone Groups Admin Admin Milestone Groups Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create Milestone Group Admin", "operationId": "create_milestone_group_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestone-groups": {"put": {"tags": ["admin"], "summary": "Update Milestone Group Admin", "operationId": "update_milestone_group_admin", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestone-groups/{milestone_group_id}": {"delete": {"tags": ["admin"], "summary": "Delete Milestone Group Admin", "operationId": "delete_milestone_group_admin", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-group-images/{milestone_group_id}": {"put": {"tags": ["admin"], "summary": "Upload Milestone Group Image", "operationId": "upload_milestone_group_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestones/{milestone_group_id}": {"post": {"tags": ["admin"], "summary": "Create Milestone", "operationId": "create_milestone", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestones/": {"put": {"tags": ["admin"], "summary": "Update Milestone", "operationId": "update_milestone", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestones/{milestone_id}": {"delete": {"tags": ["admin"], "summary": "Delete Milestone", "operationId": "delete_milestone", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-images/{milestone_id}": {"post": {"tags": ["admin"], "summary": "Upload Milestone Image", "operationId": "upload_milestone_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_milestone_image_admin_milestone_images__milestone_id__post"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneImage"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/user-questions/": {"get": {"tags": ["admin"], "summary": "Get User Questions Admin", "operationId": "get_user_questions_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserQuestionAdmin"}, "type": "array", "title": "Response Get User Questions Admin Admin User Questions Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["admin"], "summary": "Update User Question", "operationId": "update_user_question", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create User Question", "operationId": "create_user_question", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/user-questions/{user_question_id}": {"delete": {"tags": ["admin"], "summary": "Delete User Question", "operationId": "delete_user_question", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "user_question_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "User Question Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/child-questions/": {"get": {"tags": ["admin"], "summary": "Get Child Questions Admin", "operationId": "get_child_questions_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildQuestionAdmin"}, "type": "array", "title": "Response Get Child Questions Admin Admin Child Questions Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["admin"], "summary": "Update Child Question", "operationId": "update_child_question", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildQuestionAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildQuestionAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create Child Question", "operationId": "create_child_question", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildQuestionAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/child-questions/{child_question_id}": {"delete": {"tags": ["admin"], "summary": "Delete Child Question", "operationId": "delete_child_question", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_question_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Question Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/me": {"get": {"tags": ["users"], "summary": "Users:Current User", "operationId": "users:current_user", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}}, "security": [{"APIKeyCookie": []}]}, "patch": {"tags": ["users"], "summary": "Users:Patch Current User", "operationId": "users:patch_current_user", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserUpdate"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"UPDATE_USER_EMAIL_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS"}}, "UPDATE_USER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "UPDATE_USER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/{id}": {"get": {"tags": ["users"], "summary": "Users:User", "operationId": "users:user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "patch": {"tags": ["users"], "summary": "Users:Patch User", "operationId": "users:patch_user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserUpdate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "400": {"content": {"application/json": {"examples": {"UPDATE_USER_EMAIL_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS"}}, "UPDATE_USER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "UPDATE_USER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}, "schema": {"$ref": "#/components/schemas/ErrorModel"}}}, "description": "Bad Request"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "delete": {"tags": ["users"], "summary": "Users:Delete User", "operationId": "users:delete_user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "responses": {"204": {"description": "Successful Response"}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/children/": {"get": {"tags": ["users"], "summary": "Get Children", "operationId": "get_children", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildPublic"}, "type": "array", "title": "Response Get Children Users Children Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Child", "operationId": "update_child", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["users"], "summary": "Create Child", "operationId": "create_child", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildCreate"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/children/{child_id}": {"delete": {"tags": ["users"], "summary": "Delete Child", "operationId": "delete_child", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/children-images/{child_id}": {"get": {"tags": ["users"], "summary": "Get Child Image", "operationId": "get_child_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "put": {"tags": ["users"], "summary": "Upload Child Image", "operationId": "upload_child_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_child_image_users_children_images__child_id__put"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/milestone-answers/{child_id}": {"get": {"tags": ["users"], "summary": "Get Current Milestone Answer Session", "operationId": "get_current_milestone_answer_session", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerSessionPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/milestone-answers/{milestone_answer_session_id}": {"put": {"tags": ["users"], "summary": "Update Milestone Answer", "operationId": "update_milestone_answer", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_answer_session_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Answer Session Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/user-answers/": {"get": {"tags": ["users"], "summary": "Get Current User Answers", "operationId": "get_current_user_answers", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "Response Get Current User Answers Users User Answers Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Current User Answers", "operationId": "update_current_user_answers", "requestBody": {"content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "New Answers"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "Response Update Current User Answers Users User Answers Put"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/children-answers/": {"get": {"tags": ["users"], "summary": "Get Current Children Answers", "operationId": "get_current_children_answers", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildAnswerPublic"}, "type": "array", "title": "Response Get Current Children Answers Users Children Answers Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Current Children Answers", "operationId": "update_current_children_answers", "requestBody": {"content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildAnswerPublic"}, "type": "array", "title": "New Answers"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildAnswerPublic"}, "type": "array", "title": "Response Update Current Children Answers Users Children Answers Put"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/auth/login": {"post": {"tags": ["auth"], "summary": "Auth:Cookie.Login", "operationId": "auth:cookie.login", "requestBody": {"content": {"application/x-www-form-urlencoded": {"schema": {"$ref": "#/components/schemas/Body_auth_cookie_login_auth_login_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"LOGIN_BAD_CREDENTIALS": {"summary": "Bad credentials or the user is inactive.", "value": {"detail": "LOGIN_BAD_CREDENTIALS"}}, "LOGIN_USER_NOT_VERIFIED": {"summary": "The user is not verified.", "value": {"detail": "LOGIN_USER_NOT_VERIFIED"}}}}}}, "204": {"description": "No Content"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/logout": {"post": {"tags": ["auth"], "summary": "Auth:Cookie.Logout", "operationId": "auth:cookie.logout", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "401": {"description": "Missing token or inactive user."}, "204": {"description": "No Content"}}, "security": [{"APIKeyCookie": []}]}}, "/auth/register": {"post": {"tags": ["auth"], "summary": "Register:Register", "operationId": "register:register", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserCreate"}}}, "required": true}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"REGISTER_USER_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "REGISTER_USER_ALREADY_EXISTS"}}, "REGISTER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "REGISTER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/forgot-password": {"post": {"tags": ["auth"], "summary": "Reset:Forgot Password", "operationId": "reset:forgot_password", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_reset_forgot_password_auth_forgot_password_post"}}}, "required": true}, "responses": {"202": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/reset-password": {"post": {"tags": ["auth"], "summary": "Reset:Reset Password", "operationId": "reset:reset_password", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_reset_reset_password_auth_reset_password_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"RESET_PASSWORD_BAD_TOKEN": {"summary": "Bad or expired token.", "value": {"detail": "RESET_PASSWORD_BAD_TOKEN"}}, "RESET_PASSWORD_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "RESET_PASSWORD_INVALID_PASSWORD", "reason": "Password should be at least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/request-verify-token": {"post": {"tags": ["auth"], "summary": "Verify:Request-Token", "operationId": "verify:request-token", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_verify_request_token_auth_request_verify_token_post"}}}, "required": true}, "responses": {"202": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/verify": {"post": {"tags": ["auth"], "summary": "Verify:Verify", "operationId": "verify:verify", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_verify_verify_auth_verify_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"VERIFY_USER_BAD_TOKEN": {"summary": "Bad token, not existing user ornot the e-mail currently set for the user.", "value": {"detail": "VERIFY_USER_BAD_TOKEN"}}, "VERIFY_USER_ALREADY_VERIFIED": {"summary": "The user is already verified.", "value": {"detail": "VERIFY_USER_ALREADY_VERIFIED"}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/research/auth/": {"get": {"tags": ["research"], "summary": "Auth", "operationId": "auth", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}, "security": [{"APIKeyCookie": []}]}}}, "components": {"schemas": {"Body_auth_cookie_login_auth_login_post": {"properties": {"grant_type": {"anyOf": [{"type": "string", "pattern": "password"}, {"type": "null"}], "title": "Grant Type"}, "username": {"type": "string", "title": "Username"}, "password": {"type": "string", "title": "Password"}, "scope": {"type": "string", "title": "Scope", "default": ""}, "client_id": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Client Id"}, "client_secret": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Client Secret"}}, "type": "object", "required": ["username", "password"], "title": "Body_auth_cookie_login_auth_login_post"}, "Body_reset_forgot_password_auth_forgot_password_post": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}}, "type": "object", "required": ["email"], "title": "Body_reset_forgot_password_auth_forgot_password_post"}, "Body_reset_reset_password_auth_reset_password_post": {"properties": {"token": {"type": "string", "title": "Token"}, "password": {"type": "string", "title": "Password"}}, "type": "object", "required": ["token", "password"], "title": "Body_reset_reset_password_auth_reset_password_post"}, "Body_upload_child_image_users_children_images__child_id__put": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_child_image_users_children_images__child_id__put"}, "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put"}, "Body_upload_milestone_image_admin_milestone_images__milestone_id__post": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_milestone_image_admin_milestone_images__milestone_id__post"}, "Body_verify_request_token_auth_request_verify_token_post": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}}, "type": "object", "required": ["email"], "title": "Body_verify_request_token_auth_request_verify_token_post"}, "Body_verify_verify_auth_verify_post": {"properties": {"token": {"type": "string", "title": "Token"}}, "type": "object", "required": ["token"], "title": "Body_verify_verify_auth_verify_post"}, "ChildAnswerPublic": {"properties": {"answer": {"type": "string", "title": "Answer"}, "question_id": {"type": "integer", "title": "Question Id"}, "additional_answer": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Additional Answer"}, "child_id": {"type": "integer", "title": "Child Id"}}, "type": "object", "required": ["answer", "question_id", "additional_answer", "child_id"], "title": "ChildAnswerPublic", "description": "Model for public child answer data which adds the child ID.\n\nParameters\n----------\nAnswerPublic : Basic Model for all Answers to questions in Mondey"}, "ChildCreate": {"properties": {"name": {"type": "string", "title": "Name", "default": ""}, "birth_year": {"type": "integer", "title": "Birth Year"}, "birth_month": {"type": "integer", "title": "Birth Month"}}, "type": "object", "required": ["birth_year", "birth_month"], "title": "ChildCreate"}, "ChildPublic": {"properties": {"name": {"type": "string", "title": "Name", "default": ""}, "birth_year": {"type": "integer", "title": "Birth Year"}, "birth_month": {"type": "integer", "title": "Birth Month"}, "id": {"type": "integer", "title": "Id"}, "has_image": {"type": "boolean", "title": "Has Image"}}, "type": "object", "required": ["birth_year", "birth_month", "id", "has_image"], "title": "ChildPublic"}, "ChildQuestionAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "options": {"type": "string", "title": "Options"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/QuestionText"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id", "order", "options"], "title": "ChildQuestionAdmin"}, "ChildQuestionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/QuestionTextPublic"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id"], "title": "ChildQuestionPublic"}, "ErrorModel": {"properties": {"detail": {"anyOf": [{"type": "string"}, {"additionalProperties": {"type": "string"}, "type": "object"}], "title": "Detail"}}, "type": "object", "required": ["detail"], "title": "ErrorModel"}, "HTTPValidationError": {"properties": {"detail": {"items": {"$ref": "#/components/schemas/ValidationError"}, "type": "array", "title": "Detail"}}, "type": "object", "title": "HTTPValidationError"}, "Language": {"properties": {"id": {"type": "string", "maxLength": 2, "title": "Id"}}, "type": "object", "required": ["id"], "title": "Language"}, "MilestoneAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "group_id": {"type": "integer", "title": "Group Id"}, "order": {"type": "integer", "title": "Order"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneText"}, "type": "object", "title": "Text", "default": {}}, "images": {"items": {"$ref": "#/components/schemas/MilestoneImage"}, "type": "array", "title": "Images", "default": []}}, "type": "object", "required": ["id", "group_id", "order"], "title": "MilestoneAdmin"}, "MilestoneAnswerPublic": {"properties": {"milestone_id": {"type": "integer", "title": "Milestone Id"}, "answer": {"type": "integer", "title": "Answer"}}, "type": "object", "required": ["milestone_id", "answer"], "title": "MilestoneAnswerPublic"}, "MilestoneAnswerSessionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "child_id": {"type": "integer", "title": "Child Id"}, "created_at": {"type": "string", "format": "date-time", "title": "Created At"}, "answers": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}, "type": "object", "title": "Answers"}}, "type": "object", "required": ["id", "child_id", "created_at", "answers"], "title": "MilestoneAnswerSessionPublic"}, "MilestoneGroupAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneGroupText"}, "type": "object", "title": "Text", "default": {}}, "milestones": {"items": {"$ref": "#/components/schemas/MilestoneAdmin"}, "type": "array", "title": "Milestones", "default": []}}, "type": "object", "required": ["id", "order"], "title": "MilestoneGroupAdmin"}, "MilestoneGroupPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneGroupTextPublic"}, "type": "object", "title": "Text", "default": {}}, "milestones": {"items": {"$ref": "#/components/schemas/MilestonePublic"}, "type": "array", "title": "Milestones", "default": []}}, "type": "object", "required": ["id"], "title": "MilestoneGroupPublic"}, "MilestoneGroupText": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "group_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Group Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}}, "type": "object", "title": "MilestoneGroupText"}, "MilestoneGroupTextPublic": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}}, "type": "object", "title": "MilestoneGroupTextPublic"}, "MilestoneImage": {"properties": {"id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id"}, "milestone_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Milestone Id"}, "filename": {"type": "string", "title": "Filename", "default": ""}, "approved": {"type": "boolean", "title": "Approved", "default": false}}, "type": "object", "title": "MilestoneImage"}, "MilestoneImagePublic": {"properties": {"filename": {"type": "string", "title": "Filename"}, "approved": {"type": "boolean", "title": "Approved"}}, "type": "object", "required": ["filename", "approved"], "title": "MilestoneImagePublic"}, "MilestonePublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneTextPublic"}, "type": "object", "title": "Text", "default": {}}, "images": {"items": {"$ref": "#/components/schemas/MilestoneImagePublic"}, "type": "array", "title": "Images", "default": []}}, "type": "object", "required": ["id"], "title": "MilestonePublic"}, "MilestoneText": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "obs": {"type": "string", "title": "Obs", "default": ""}, "help": {"type": "string", "title": "Help", "default": ""}, "milestone_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Milestone Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}}, "type": "object", "title": "MilestoneText"}, "MilestoneTextPublic": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "obs": {"type": "string", "title": "Obs", "default": ""}, "help": {"type": "string", "title": "Help", "default": ""}}, "type": "object", "title": "MilestoneTextPublic"}, "QuestionText": {"properties": {"question": {"type": "string", "title": "Question", "default": ""}, "options_json": {"type": "string", "title": "Options Json", "default": ""}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}, "options": {"type": "string", "title": "Options", "default": ""}}, "type": "object", "title": "QuestionText"}, "QuestionTextPublic": {"properties": {"question": {"type": "string", "title": "Question", "default": ""}, "options_json": {"type": "string", "title": "Options Json", "default": ""}}, "type": "object", "title": "QuestionTextPublic"}, "UserAnswerPublic": {"properties": {"answer": {"type": "string", "title": "Answer"}, "question_id": {"type": "integer", "title": "Question Id"}, "additional_answer": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Additional Answer"}}, "type": "object", "required": ["answer", "question_id", "additional_answer"], "title": "UserAnswerPublic", "description": "Model for public user answer data with the same content as AnswerPublic\n\nParameters\n----------\nAnswerPublic : Basic Model for all Answers to questions in Mondey"}, "UserCreate": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}, "password": {"type": "string", "title": "Password"}, "is_active": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Active", "default": true}, "is_superuser": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Superuser", "default": false}, "is_verified": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Verified", "default": false}, "is_researcher": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Researcher", "default": false}}, "type": "object", "required": ["email", "password"], "title": "UserCreate"}, "UserQuestionAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "options": {"type": "string", "title": "Options"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/QuestionText"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id", "order", "options"], "title": "UserQuestionAdmin"}, "UserQuestionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/QuestionTextPublic"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id"], "title": "UserQuestionPublic"}, "UserRead": {"properties": {"id": {"type": "integer", "title": "Id"}, "email": {"type": "string", "format": "email", "title": "Email"}, "is_active": {"type": "boolean", "title": "Is Active", "default": true}, "is_superuser": {"type": "boolean", "title": "Is Superuser", "default": false}, "is_verified": {"type": "boolean", "title": "Is Verified", "default": false}, "is_researcher": {"type": "boolean", "title": "Is Researcher"}}, "type": "object", "required": ["id", "email", "is_researcher"], "title": "UserRead"}, "UserUpdate": {"properties": {"password": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Password"}, "email": {"anyOf": [{"type": "string", "format": "email"}, {"type": "null"}], "title": "Email"}, "is_active": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Active"}, "is_superuser": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Superuser"}, "is_verified": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Verified"}, "is_researcher": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Researcher"}}, "type": "object", "title": "UserUpdate"}, "ValidationError": {"properties": {"loc": {"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, "type": "array", "title": "Location"}, "msg": {"type": "string", "title": "Message"}, "type": {"type": "string", "title": "Error Type"}}, "type": "object", "required": ["loc", "msg", "type"], "title": "ValidationError"}}, "securitySchemes": {"APIKeyCookie": {"type": "apiKey", "in": "cookie", "name": "fastapiusersauth"}}}} \ No newline at end of file diff --git a/mondey_backend/src/mondey_backend/models/questions.py b/mondey_backend/src/mondey_backend/models/questions.py index 361ec6b8..db76d251 100644 --- a/mondey_backend/src/mondey_backend/models/questions.py +++ b/mondey_backend/src/mondey_backend/models/questions.py @@ -16,6 +16,10 @@ class QuestionTextBase(SQLModel): class QuestionText(QuestionTextBase): + question_id: int | None = Field( + default=None, foreign_key="question.id", primary_key=True + ) + lang_id: str | None = fixed_length_string_field( max_length=2, default=None, foreign_key="language.id", primary_key=True ) @@ -84,7 +88,7 @@ class ChildQuestionPublic(QuestionPublic): class UserQuestionAdmin(QuestionAdmin): - pass + text: Mapped[dict[str, UserQuestionText]] = dict_relationship(key="lang_id") class ChildQuestionAdmin(QuestionAdmin): diff --git a/mondey_backend/src/mondey_backend/routers/admin.py b/mondey_backend/src/mondey_backend/routers/admin.py index 27bd6a9b..3cc7b177 100644 --- a/mondey_backend/src/mondey_backend/routers/admin.py +++ b/mondey_backend/src/mondey_backend/routers/admin.py @@ -172,6 +172,8 @@ def get_user_questions_admin(session: SessionDep): user_questions = session.exec( select(UserQuestion).order_by(col(UserQuestion.order)) ).all() + + print("user questions retrieved from database: ", user_questions) return user_questions @router.post("/user-questions/", response_model=UserQuestionAdmin) diff --git a/mondey_backend/tests/conftest.py b/mondey_backend/tests/conftest.py index 274bf200..4c642bcd 100644 --- a/mondey_backend/tests/conftest.py +++ b/mondey_backend/tests/conftest.py @@ -179,69 +179,72 @@ def session(): ) session.add(MilestoneAnswer(answer_session_id=3, milestone_id=7, answer=2)) - # add user questions for user 1 - session.add( + # add user questions for admin + user_questions = [ UserQuestion( id=1, order=1, options="[a,b,c,other]", additional_option="other", + component="select", text={ "de": UserQuestionText( question_id=1, - lang_id=1, + lang_id="de", options="[x,y,z]", question="Wo sonst?", + options_json="", ), "en": UserQuestionText( question_id=1, - lang_id=2, + lang_id="en", options="[1,2,3]", question="Where else?", + options_json="", ), }, - ) - ) - - session.add( + ), UserQuestion( id=2, order=2, - componet="textarea", + component="textarea", options="[a2,b2,c2,other]", additional_option="other", text={ "de": UserQuestionText( question_id=2, - lang_id=1, + lang_id="de", options="[x2,y2,z2]", question="Was noch?", + options_json="", ), "en": UserQuestionText( question_id=2, - lang_id=2, + lang_id="en", options="[12,22,32]", question="What else?", + options_json="", ), }, - ) - ) + ), + ] + for user_question in user_questions: + session.add(user_question) + for lang in user_question.text: + session.add(user_question.text[lang]) # add child questions for user 1 - session.add( + child_questions = [ ChildQuestion( id=1, order=0, options="[a,b,c,other]", - additional_option="", + additional_option="other", text={ "de": ChildQuestionText(question_id=1, lang_id=1, question="was?"), "en": ChildQuestionText(question_id=1, lang_id=2, question="what?"), }, - ) - ) - - session.add( + ), ChildQuestion( id=2, order=1, @@ -259,8 +262,13 @@ def session(): question="Where?", ), }, - ) - ) + ), + ] + + for child_question in child_questions: + session.add(child_question) + for lang in child_question.text: + session.add(child_question.text[lang]) # add user answers for user 1 session.add( @@ -281,6 +289,7 @@ def session(): additional_answer="dolor sit", ) ) + session.commit() # add child answers for user 1 diff --git a/mondey_backend/tests/routers/test_admin.py b/mondey_backend/tests/routers/test_admin.py index b5edf1a3..ce59e236 100644 --- a/mondey_backend/tests/routers/test_admin.py +++ b/mondey_backend/tests/routers/test_admin.py @@ -259,6 +259,7 @@ def test_get_user_question_admin_works(admin_client: TestClient): assert response.status_code == 200 assert [element["order"] for element in response.json()] == [1, 2] + print("response: ", response.json()) assert response.json() == [ { "id": 1, @@ -269,16 +270,18 @@ def test_get_user_question_admin_works(admin_client: TestClient): "type": "text", "text": { "de": { - "question_id": "1", - "lang_id": "1", + "question_id": 1, + "lang_id": "de", "options": "[x,y,z]", + "options_json": "", "question": "Wo sonst?", }, "en": { - "question_id": "1", - "lang_id": "2", + "question_id": 1, + "lang_id": "en", "options": "[1,2,3]", "question": "Where else?", + "options_json": "", }, }, }, @@ -291,16 +294,18 @@ def test_get_user_question_admin_works(admin_client: TestClient): "type": "text", "text": { "de": { - "question_id": "2", - "lang_id": "1", + "question_id": 2, + "lang_id": "de", "options": "[x2,y2,z2]", + "options_json": "", "question": "Was noch?", }, "en": { - "question_id": "2", - "lang_id": "2", + "question_id": 2, + "lang_id": "en", "options": "[12,22,32]", "question": "What else?", + "options_json": "", }, }, }, @@ -343,8 +348,63 @@ def test_delete_user_question_database_error(): assert 3 == 5 -def test_get_child_question_admin_works(): - assert 3 == 5 +def test_get_child_question_admin_works(admin_client: TestClient): + response = admin_client.get("/admin/child-questions") + + assert response.status_code == 200 + + assert [element["order"] for element in response.json()] == [1, 2] + print("response: ", response.json()) + assert response.json() == [ + { + "id": 1, + "order": 0, + "component": "select", + "options": "[a,b,c,other]", + "additional_option": "other", + "type": "text", + "text": { + "de": { + "question_id": 1, + "lang_id": "de", + "options": "[x,y,z]", + "options_json": "", + "question": "Wo sonst?", + }, + "en": { + "question_id": 1, + "lang_id": "en", + "options": "[1,2,3]", + "question": "Where else?", + "options_json": "", + }, + }, + }, + { + "id": 2, + "order": 1, + "component": "textarea", + "options": "[a2,b2,c2,other]", + "additional_option": "other", + "type": "text", + "text": { + "de": { + "question_id": 2, + "lang_id": "de", + "options": "[x2,y2,z2]", + "options_json": "", + "question": "Was noch?", + }, + "en": { + "question_id": 2, + "lang_id": "en", + "options": "[12,22,32]", + "question": "What else?", + "options_json": "", + }, + }, + }, + ] def test_get_child_question_admin_userid_not_there(): From a5cd5a1adf69b351c85b23ee8ee5e6526aa102ac Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 14:27:12 +0100 Subject: [PATCH 09/87] fix errors in test data --- mondey_backend/tests/conftest.py | 20 ++++++++++++++++---- mondey_backend/tests/routers/test_admin.py | 17 ++++++----------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/mondey_backend/tests/conftest.py b/mondey_backend/tests/conftest.py index 4c642bcd..8cf0c2d2 100644 --- a/mondey_backend/tests/conftest.py +++ b/mondey_backend/tests/conftest.py @@ -241,8 +241,18 @@ def session(): options="[a,b,c,other]", additional_option="other", text={ - "de": ChildQuestionText(question_id=1, lang_id=1, question="was?"), - "en": ChildQuestionText(question_id=1, lang_id=2, question="what?"), + "de": ChildQuestionText( + question_id=1, + lang_id="de", + question="was?", + options="[x,y,z]", + ), + "en": ChildQuestionText( + question_id=1, + lang_id="en", + question="what?", + options="[1,2,3]", + ), }, ), ChildQuestion( @@ -253,13 +263,15 @@ def session(): text={ "de": ChildQuestionText( question_id=2, - lang_id=1, + lang_id="de", question="Wo?", + options="[x2,y2,z2]", ), "en": ChildQuestionText( question_id=2, - lang_id=2, + lang_id="en", question="Where?", + options="[12,22,32]", ), }, ), diff --git a/mondey_backend/tests/routers/test_admin.py b/mondey_backend/tests/routers/test_admin.py index ce59e236..7cb838c8 100644 --- a/mondey_backend/tests/routers/test_admin.py +++ b/mondey_backend/tests/routers/test_admin.py @@ -353,8 +353,7 @@ def test_get_child_question_admin_works(admin_client: TestClient): assert response.status_code == 200 - assert [element["order"] for element in response.json()] == [1, 2] - print("response: ", response.json()) + assert [element["order"] for element in response.json()] == [0, 1] assert response.json() == [ { "id": 1, @@ -369,13 +368,13 @@ def test_get_child_question_admin_works(admin_client: TestClient): "lang_id": "de", "options": "[x,y,z]", "options_json": "", - "question": "Wo sonst?", + "question": "was?", }, "en": { "question_id": 1, "lang_id": "en", "options": "[1,2,3]", - "question": "Where else?", + "question": "what?", "options_json": "", }, }, @@ -383,7 +382,7 @@ def test_get_child_question_admin_works(admin_client: TestClient): { "id": 2, "order": 1, - "component": "textarea", + "component": "select", "options": "[a2,b2,c2,other]", "additional_option": "other", "type": "text", @@ -393,13 +392,13 @@ def test_get_child_question_admin_works(admin_client: TestClient): "lang_id": "de", "options": "[x2,y2,z2]", "options_json": "", - "question": "Was noch?", + "question": "Wo?", }, "en": { "question_id": 2, "lang_id": "en", "options": "[12,22,32]", - "question": "What else?", + "question": "Where?", "options_json": "", }, }, @@ -407,10 +406,6 @@ def test_get_child_question_admin_works(admin_client: TestClient): ] -def test_get_child_question_admin_userid_not_there(): - assert 3 == 5 - - def test_create_child_question_works(): assert 3 == 5 From e8772fd3e2f57f3025c6e3b5f7178ecffae2e72f Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 15:39:58 +0100 Subject: [PATCH 10/87] try to get sqlmodel inheritnace to work --- .../src/mondey_backend/models/questions.py | 8 +- mondey_backend/tests/conftest.py | 162 +++++++++++ mondey_backend/tests/routers/test_admin.py | 268 +++++++++--------- 3 files changed, 296 insertions(+), 142 deletions(-) diff --git a/mondey_backend/src/mondey_backend/models/questions.py b/mondey_backend/src/mondey_backend/models/questions.py index db76d251..30f8ee80 100644 --- a/mondey_backend/src/mondey_backend/models/questions.py +++ b/mondey_backend/src/mondey_backend/models/questions.py @@ -78,6 +78,10 @@ class UserQuestionPublic(QuestionPublic): pass +class UserQuestionAdmin(QuestionAdmin): + text: Mapped[dict[str, UserQuestionText]] = dict_relationship(key="lang_id") + + # Child question classes class ChildQuestion(Question, table=True): text: Mapped[dict[str, ChildQuestionText]] = dict_relationship(key="lang_id") @@ -87,10 +91,6 @@ class ChildQuestionPublic(QuestionPublic): pass -class UserQuestionAdmin(QuestionAdmin): - text: Mapped[dict[str, UserQuestionText]] = dict_relationship(key="lang_id") - - class ChildQuestionAdmin(QuestionAdmin): pass diff --git a/mondey_backend/tests/conftest.py b/mondey_backend/tests/conftest.py index 8cf0c2d2..a270c631 100644 --- a/mondey_backend/tests/conftest.py +++ b/mondey_backend/tests/conftest.py @@ -202,6 +202,13 @@ def session(): question="Where else?", options_json="", ), + "fr": UserQuestionText( + question_id=1, + lang_id="fr", + options="[1,2,3]", + question="french words", + options_json="", + ), }, ), UserQuestion( @@ -225,6 +232,13 @@ def session(): question="What else?", options_json="", ), + "fr": UserQuestionText( + question_id=2, + lang_id="fr", + options="[12,22,32]", + question="french words", + options_json="", + ), }, ), ] @@ -253,6 +267,12 @@ def session(): question="what?", options="[1,2,3]", ), + "fr": ChildQuestionText( + question_id=1, + lang_id="fr", + question="french...", + options="[1,2,3]", + ), }, ), ChildQuestion( @@ -273,6 +293,12 @@ def session(): question="Where?", options="[12,22,32]", ), + "fr": ChildQuestionText( + question_id=2, + lang_id="fr", + question="french...", + options="[12,22,32]", + ), }, ), ] @@ -308,6 +334,142 @@ def session(): yield session +@pytest.fixture +def user_questions(): + return [ + { + "id": 1, + "order": 1, + "component": "select", + "options": "[a,b,c,other]", + "additional_option": "other", + "type": "text", + "text": { + "de": { + "question_id": 1, + "lang_id": "de", + "options": "[x,y,z]", + "options_json": "", + "question": "Wo sonst?", + }, + "en": { + "question_id": 1, + "lang_id": "en", + "options": "[1,2,3]", + "question": "Where else?", + "options_json": "", + }, + "fr": { + "question_id": 1, + "lang_id": "fr", + "options": "[1,2,3]", + "question": "french words", + "options_json": "", + }, + }, + }, + { + "id": 2, + "order": 2, + "component": "textarea", + "options": "[a2,b2,c2,other]", + "additional_option": "other", + "type": "text", + "text": { + "de": { + "question_id": 2, + "lang_id": "de", + "options": "[x2,y2,z2]", + "options_json": "", + "question": "Was noch?", + }, + "en": { + "question_id": 2, + "lang_id": "en", + "options": "[12,22,32]", + "question": "What else?", + "options_json": "", + }, + "fr": { + "question_id": 2, + "lang_id": "fr", + "options": "[12,22,32]", + "question": "french words", + "options_json": "", + }, + }, + }, + ] + + +@pytest.fixture +def child_questions(): + return [ + { + "id": 1, + "order": 0, + "component": "select", + "options": "[a,b,c,other]", + "additional_option": "other", + "type": "text", + "text": { + "de": { + "question_id": 1, + "lang_id": "de", + "options": "[x,y,z]", + "options_json": "", + "question": "was?", + }, + "en": { + "question_id": 1, + "lang_id": "en", + "options": "[1,2,3]", + "question": "what?", + "options_json": "", + }, + "fr": { + "question_id": 1, + "lang_id": "fr", + "question": "french...", + "options": "[1,2,3]", + "options_json": "", + }, + }, + }, + { + "id": 2, + "order": 1, + "component": "select", + "options": "[a2,b2,c2,other]", + "additional_option": "other", + "type": "text", + "text": { + "de": { + "question_id": 2, + "lang_id": "de", + "options": "[x2,y2,z2]", + "options_json": "", + "question": "Wo?", + }, + "en": { + "question_id": 2, + "lang_id": "en", + "options": "[12,22,32]", + "question": "Where?", + "options_json": "", + }, + "fr": { + "question_id": 2, + "lang_id": "fr", + "question": "french...", + "options": "[12,22,32]", + "options_json": "", + }, + }, + }, + ] + + @pytest.fixture def active_admin_user(): return UserRead( diff --git a/mondey_backend/tests/routers/test_admin.py b/mondey_backend/tests/routers/test_admin.py index 7cb838c8..9e2714c4 100644 --- a/mondey_backend/tests/routers/test_admin.py +++ b/mondey_backend/tests/routers/test_admin.py @@ -253,190 +253,182 @@ def test_post_milestone_image( # tests for user questions -def test_get_user_question_admin_works(admin_client: TestClient): +def test_get_user_question_admin_works(admin_client: TestClient, user_questions): response = admin_client.get("/admin/user-questions") assert response.status_code == 200 assert [element["order"] for element in response.json()] == [1, 2] - print("response: ", response.json()) - assert response.json() == [ - { - "id": 1, - "order": 1, - "component": "select", - "options": "[a,b,c,other]", - "additional_option": "other", - "type": "text", - "text": { - "de": { - "question_id": 1, - "lang_id": "de", - "options": "[x,y,z]", - "options_json": "", - "question": "Wo sonst?", - }, - "en": { - "question_id": 1, - "lang_id": "en", - "options": "[1,2,3]", - "question": "Where else?", - "options_json": "", - }, + assert response.json() == user_questions + + +def test_create_user_question_works(admin_client: TestClient): + response = admin_client.post("/admin/user-questions") + assert response.status_code == 200 + assert response.json() == { + "id": 3, + "order": 0, + "component": "select", + "type": "text", + "options": "", + "text": { + "de": { + "options_json": "", + "question_id": 3, + "options": "", + "lang_id": "de", + "question": "", }, - }, - { - "id": 2, - "order": 2, - "component": "textarea", - "options": "[a2,b2,c2,other]", - "additional_option": "other", - "type": "text", - "text": { - "de": { - "question_id": 2, - "lang_id": "de", - "options": "[x2,y2,z2]", - "options_json": "", - "question": "Was noch?", - }, - "en": { - "question_id": 2, - "lang_id": "en", - "options": "[12,22,32]", - "question": "What else?", - "options_json": "", - }, + "en": { + "options_json": "", + "question_id": 3, + "options": "", + "lang_id": "en", + "question": "", + }, + "fr": { + "options_json": "", + "question_id": 3, + "options": "", + "lang_id": "fr", + "question": "", }, }, - ] + "additional_option": "", + } -def test_create_user_question_works(): - assert 3 == 5 +def test_update_user_question_works(admin_client: TestClient): + user_question_admin = { + "id": "1", + "component": "textarea", + "type": "other_thing", + "order": 0, + "options": "some_options", + "text": { + "de": { + "options_json": "", + "question_id": 1, + "options": "", + "lang_id": "de", + "question": "", + }, + "en": { + "options_json": "", + "question_id": 1, + "options": "", + "lang_id": "en", + "question": "", + }, + "fr": { + "options_json": "", + "question_id": 1, + "options": "", + "lang_id": "fr", + "question": "", + }, + }, + "additional_option": "nothing", + } + response = admin_client.put("/admin/user-questions", json=user_question_admin) -def test_create_user_question_id_exists(): - assert 3 == 5 + assert response.status_code == 200 -def test_create_user_question_id_database_error(): - assert 3 == 5 +# def test_update_user_question_id_not_there(): +# assert 3 == 5 -def test_update_user_question_works(): - assert 3 == 5 +# def test_update_user_question_database_error(): +# assert 3 == 5 -def test_update_user_question_id_not_there(): - assert 3 == 5 +# def test_delete_user_question_works(): +# assert 3 == 5 -def test_update_user_question_database_error(): - assert 3 == 5 +# def test_delete_user_question_id_not_there(): +# assert 3 == 5 -def test_delete_user_question_works(): - assert 3 == 5 +# def test_delete_user_question_database_error(): +# assert 3 == 5 -def test_delete_user_question_id_not_there(): - assert 3 == 5 +def test_get_child_question_admin_works(admin_client: TestClient, child_questions): + response = admin_client.get("/admin/child-questions") + assert response.status_code == 200 -def test_delete_user_question_database_error(): - assert 3 == 5 + assert [element["order"] for element in response.json()] == [0, 1] + assert response.json() == child_questions -def test_get_child_question_admin_works(admin_client: TestClient): - response = admin_client.get("/admin/child-questions") +def test_create_child_question_works(admin_client: TestClient): + response = admin_client.post("/admin/child-questions") assert response.status_code == 200 - - assert [element["order"] for element in response.json()] == [0, 1] - assert response.json() == [ - { - "id": 1, - "order": 0, - "component": "select", - "options": "[a,b,c,other]", - "additional_option": "other", - "type": "text", - "text": { - "de": { - "question_id": 1, - "lang_id": "de", - "options": "[x,y,z]", - "options_json": "", - "question": "was?", - }, - "en": { - "question_id": 1, - "lang_id": "en", - "options": "[1,2,3]", - "question": "what?", - "options_json": "", - }, + assert response.json() == { + "id": 3, + "order": 0, + "component": "select", + "type": "text", + "options": "", + "text": { + "de": { + "options_json": "", + "question_id": 3, + "options": "", + "lang_id": "de", + "question": "", }, - }, - { - "id": 2, - "order": 1, - "component": "select", - "options": "[a2,b2,c2,other]", - "additional_option": "other", - "type": "text", - "text": { - "de": { - "question_id": 2, - "lang_id": "de", - "options": "[x2,y2,z2]", - "options_json": "", - "question": "Wo?", - }, - "en": { - "question_id": 2, - "lang_id": "en", - "options": "[12,22,32]", - "question": "Where?", - "options_json": "", - }, + "en": { + "options_json": "", + "question_id": 3, + "options": "", + "lang_id": "en", + "question": "", + }, + "fr": { + "options_json": "", + "question_id": 3, + "options": "", + "lang_id": "fr", + "question": "", }, }, - ] - - -def test_create_child_question_works(): - assert 3 == 5 + "additional_option": "", + } -def test_create_child_question_id_exists(): - assert 3 == 5 +# def test_create_child_question_id_exists(): +# assert 3 == 5 -def test_create_child_question_id_database_error(): - assert 3 == 5 +# def test_create_child_question_id_database_error(): +# assert 3 == 5 -def test_update_child_question_works(): - assert 3 == 5 +# def test_update_child_question_works(): +# assert 3 == 5 -def test_update_child_question_id_not_there(): - assert 3 == 5 +# def test_update_child_question_id_not_there(): +# assert 3 == 5 -def test_update_child_question_database_error(): - assert 3 == 5 +# def test_update_child_question_database_error(): +# assert 3 == 5 -def test_delete_child_question_works(): - assert 3 == 5 +# def test_delete_child_question_works(): +# assert 3 == 5 -def test_delete_child_question_id_not_there(): - assert 3 == 5 +# def test_delete_child_question_id_not_there(): +# assert 3 == 5 -def test_delete_child_question_database_error(): - assert 3 == 5 +# def test_delete_child_question_database_error(): +# assert 3 == 5 From 608dc8ce2f430114df95eb901753189db3e83782 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 16:00:44 +0100 Subject: [PATCH 11/87] get rid of inheritance in question models for now --- .../src/mondey_backend/models/questions.py | 151 +++++++++--------- .../src/mondey_backend/routers/admin.py | 6 +- .../src/mondey_backend/routers/utils.py | 13 +- mondey_backend/tests/conftest.py | 48 +++--- mondey_backend/tests/routers/test_admin.py | 18 +-- 5 files changed, 121 insertions(+), 115 deletions(-) diff --git a/mondey_backend/src/mondey_backend/models/questions.py b/mondey_backend/src/mondey_backend/models/questions.py index 30f8ee80..e4f23ee1 100644 --- a/mondey_backend/src/mondey_backend/models/questions.py +++ b/mondey_backend/src/mondey_backend/models/questions.py @@ -8,100 +8,115 @@ from .utils import fixed_length_string_field -# Base model classes for all questions text elements. Does not define any tables itself, but only the basic structure. These are not intended for direct use! -# Create derived models that implemenet proper key relations with descriptive names instead and use those in your endpoints -class QuestionTextBase(SQLModel): +# user questions +class UserQuestionTextBase(SQLModel): question: str = "" options_json: str = "" -class QuestionText(QuestionTextBase): - question_id: int | None = Field( - default=None, foreign_key="question.id", primary_key=True +class UserQuestionText(UserQuestionTextBase, table=True): + user_question_id: int | None = Field( + default=None, foreign_key="userquestion.id", primary_key=True ) - lang_id: str | None = fixed_length_string_field( max_length=2, default=None, foreign_key="language.id", primary_key=True ) options: str = "" -class Question(SQLModel): +class UserQuestionTextPublic(UserQuestionTextBase): + pass + + +class UserQuestion(SQLModel, table=True): id: int | None = Field(default=None, primary_key=True) order: int = 0 component: str = "select" type: str = "text" options: str = "" + text: Mapped[dict[str, UserQuestionText]] = dict_relationship(key="lang_id") additional_option: str = "" -class QuestionTextPublic(QuestionTextBase): - pass - - -class QuestionPublic(SQLModel): +class UserQuestionPublic(SQLModel): id: int component: str = "select" type: str = "text" - text: dict[str, QuestionTextPublic] = {} + text: dict[str, UserQuestionTextPublic] = {} additional_option: str = "" -class QuestionAdmin(SQLModel): +class UserQuestionAdmin(SQLModel): id: int order: int component: str = "select" type: str = "text" options: str - text: dict[str, QuestionText] = {} + text: dict[str, UserQuestionText] = {} additional_option: str = "" -# User Question classes -class UserQuestionText(QuestionText, table=True): - question_id: int | None = Field( - default=None, foreign_key="userquestion.id", primary_key=True - ) +# child questions +class ChildQuestionTextBase(SQLModel): + question: str = "" + options_json: str = "" -class ChildQuestionText(QuestionText, table=True): - question_id: int | None = Field( +class ChildQuestionText(ChildQuestionTextBase, table=True): + child_question_id: int | None = Field( default=None, foreign_key="childquestion.id", primary_key=True ) + lang_id: str | None = fixed_length_string_field( + max_length=2, default=None, foreign_key="language.id", primary_key=True + ) + options: str = "" -class UserQuestion(Question, table=True): - text: Mapped[dict[str, UserQuestionText]] = dict_relationship(key="lang_id") - - -class UserQuestionPublic(QuestionPublic): +class ChildQuestionTextPublic(ChildQuestionTextBase): pass -class UserQuestionAdmin(QuestionAdmin): - text: Mapped[dict[str, UserQuestionText]] = dict_relationship(key="lang_id") +class ChildQuestion(SQLModel, table=True): + id: int | None = Field(default=None, primary_key=True) + order: int = 0 + component: str = "select" + type: str = "text" + options: str = "" + text: Mapped[dict[str, ChildQuestionText]] = dict_relationship(key="lang_id") + additional_option: str = "" -# Child question classes -class ChildQuestion(Question, table=True): - text: Mapped[dict[str, ChildQuestionText]] = dict_relationship(key="lang_id") +class ChildQuestionPublic(SQLModel): + id: int + component: str = "select" + type: str = "text" + text: dict[str, ChildQuestionTextPublic] = {} + additional_option: str = "" -class ChildQuestionPublic(QuestionPublic): - pass +class ChildQuestionAdmin(SQLModel): + id: int + order: int + component: str = "select" + type: str = "text" + options: str + text: dict[str, ChildQuestionText] = {} + additional_option: str = "" -class ChildQuestionAdmin(QuestionAdmin): - pass +# Answers to user questions. Internal model and 'public' model exposed to the forntend app -class Answer(SQLModel): +class UserAnswer(SQLModel, table=True): """ - Base Answer model for all internal data that holds answers to questions. + Internal model for user answers. Parameters ---------- - SQLModel: Makes this into a pydantic model for an SQL table entry. + SQLModel : Pydantic model basic sqlmodel pydantic type + + table : bool, True + Makes sure this is created as a table in the database, by default True """ user_id: int = Field(default=None, primary_key=True) @@ -112,35 +127,9 @@ class Answer(SQLModel): additional_answer: str | None -class UserAnswer(Answer, table=True): - """ - Internal model for UserAnswer with the same content as the base `Answer` type. - - Parameters - ---------- - Answer : Base Answer model for all internal data that holds answers to questions. - table : bool, optional - Makes this a SQL table - """ - - pass - - -class ChildAnswer(Answer, table=True): - """ - Internal model for child answer data which adds the child ID. - - Parameters - ---------- - AnswerPublic : Basic Model for all Answers to questions in Mondey - """ - - child_id: int = Field(default=None, primary_key=True, foreign_key="child.id") - - -class AnswerPublic(SQLModel): +class UserAnswerPublic(SQLModel): """ - Internal data model for UserAnswers + External data model for UserAnswers Parameters ---------- @@ -152,25 +141,35 @@ class AnswerPublic(SQLModel): additional_answer: str | None -class UserAnswerPublic(AnswerPublic): +class ChildAnswer(SQLModel, table=True): """ - Model for public user answer data with the same content as AnswerPublic + Internal model for user answers. Parameters ---------- - AnswerPublic : Basic Model for all Answers to questions in Mondey + SQLModel : Pydantic model basic sqlmodel pydantic type + + table : bool, True + Makes sure this is created as a table in the database, by default True """ - pass + user_id: int = Field(default=None, primary_key=True) + question_id: int = Field( + default=None, primary_key=True, foreign_key="childquestion.id" + ) + answer: str + additional_answer: str | None -class ChildAnswerPublic(AnswerPublic): +class ChildAnswerPublic(SQLModel): """ - Model for public child answer data which adds the child ID. + External data model for UserAnswers Parameters ---------- - AnswerPublic : Basic Model for all Answers to questions in Mondey + SQLModel : Pydantic model basic sqlmodel pydantic type """ - child_id: int + answer: str + question_id: int + additional_answer: str | None diff --git a/mondey_backend/src/mondey_backend/routers/admin.py b/mondey_backend/src/mondey_backend/routers/admin.py index 3cc7b177..701f4d96 100644 --- a/mondey_backend/src/mondey_backend/routers/admin.py +++ b/mondey_backend/src/mondey_backend/routers/admin.py @@ -182,7 +182,7 @@ def create_user_question(session: SessionDep): add(session, user_question) for language in session.exec(select(Language)).all(): session.add( - UserQuestionText(question_id=user_question.id, lang_id=language.id) + UserQuestionText(user_question_id=user_question.id, lang_id=language.id) ) session.commit() session.refresh(user_question) @@ -223,7 +223,9 @@ def create_child_question( add(session, child_question) for language in session.exec(select(Language)).all(): session.add( - ChildQuestionText(question_id=child_question.id, lang_id=language.id) + ChildQuestionText( + child_question_id=child_question.id, lang_id=language.id + ) ) session.commit() session.refresh(child_question) diff --git a/mondey_backend/src/mondey_backend/routers/utils.py b/mondey_backend/src/mondey_backend/routers/utils.py index 05600278..fbce0690 100644 --- a/mondey_backend/src/mondey_backend/routers/utils.py +++ b/mondey_backend/src/mondey_backend/routers/utils.py @@ -19,11 +19,12 @@ from ..models.milestones import MilestoneGroupText from ..models.milestones import MilestoneText from ..models.questions import ChildQuestionAdmin -from ..models.questions import QuestionText +from ..models.questions import ChildQuestionText from ..models.questions import UserQuestionAdmin +from ..models.questions import UserQuestionText from ..users import User -Text = MilestoneText | MilestoneGroupText | QuestionText +Text = MilestoneText | MilestoneGroupText | UserQuestionText | ChildQuestionText def write_file(file: UploadFile, filename: str): @@ -81,11 +82,15 @@ def update_milestone_group_text( def update_user_question_text(session: SessionDep, user_question: UserQuestionAdmin): - _update_text(session, QuestionText, user_question.text.values(), user_question.id) + _update_text( + session, UserQuestionText, user_question.text.values(), user_question.id + ) def update_child_question_text(session: SessionDep, child_question: ChildQuestionAdmin): - _update_text(session, QuestionText, child_question.text.values(), child_question.id) + _update_text( + session, ChildQuestionText, child_question.text.values(), child_question.id + ) def _session_has_expired(milestone_answer_session: MilestoneAnswerSession) -> bool: diff --git a/mondey_backend/tests/conftest.py b/mondey_backend/tests/conftest.py index a270c631..e9c9e77e 100644 --- a/mondey_backend/tests/conftest.py +++ b/mondey_backend/tests/conftest.py @@ -189,21 +189,21 @@ def session(): component="select", text={ "de": UserQuestionText( - question_id=1, + user_question_id=1, lang_id="de", options="[x,y,z]", question="Wo sonst?", options_json="", ), "en": UserQuestionText( - question_id=1, + user_question_id=1, lang_id="en", options="[1,2,3]", question="Where else?", options_json="", ), "fr": UserQuestionText( - question_id=1, + user_question_id=1, lang_id="fr", options="[1,2,3]", question="french words", @@ -219,21 +219,21 @@ def session(): additional_option="other", text={ "de": UserQuestionText( - question_id=2, + user_question_id=2, lang_id="de", options="[x2,y2,z2]", question="Was noch?", options_json="", ), "en": UserQuestionText( - question_id=2, + user_question_id=2, lang_id="en", options="[12,22,32]", question="What else?", options_json="", ), "fr": UserQuestionText( - question_id=2, + user_question_id=2, lang_id="fr", options="[12,22,32]", question="french words", @@ -256,19 +256,19 @@ def session(): additional_option="other", text={ "de": ChildQuestionText( - question_id=1, + child_question_id=1, lang_id="de", question="was?", options="[x,y,z]", ), "en": ChildQuestionText( - question_id=1, + child_question_id=1, lang_id="en", question="what?", options="[1,2,3]", ), "fr": ChildQuestionText( - question_id=1, + child_question_id=1, lang_id="fr", question="french...", options="[1,2,3]", @@ -282,19 +282,19 @@ def session(): additional_option="other", text={ "de": ChildQuestionText( - question_id=2, + child_question_id=2, lang_id="de", question="Wo?", options="[x2,y2,z2]", ), "en": ChildQuestionText( - question_id=2, + child_question_id=2, lang_id="en", question="Where?", options="[12,22,32]", ), "fr": ChildQuestionText( - question_id=2, + child_question_id=2, lang_id="fr", question="french...", options="[12,22,32]", @@ -346,21 +346,21 @@ def user_questions(): "type": "text", "text": { "de": { - "question_id": 1, + "user_question_id": 1, "lang_id": "de", "options": "[x,y,z]", "options_json": "", "question": "Wo sonst?", }, "en": { - "question_id": 1, + "user_question_id": 1, "lang_id": "en", "options": "[1,2,3]", "question": "Where else?", "options_json": "", }, "fr": { - "question_id": 1, + "user_question_id": 1, "lang_id": "fr", "options": "[1,2,3]", "question": "french words", @@ -377,21 +377,21 @@ def user_questions(): "type": "text", "text": { "de": { - "question_id": 2, + "user_question_id": 2, "lang_id": "de", "options": "[x2,y2,z2]", "options_json": "", "question": "Was noch?", }, "en": { - "question_id": 2, + "user_question_id": 2, "lang_id": "en", "options": "[12,22,32]", "question": "What else?", "options_json": "", }, "fr": { - "question_id": 2, + "user_question_id": 2, "lang_id": "fr", "options": "[12,22,32]", "question": "french words", @@ -414,21 +414,21 @@ def child_questions(): "type": "text", "text": { "de": { - "question_id": 1, + "child_question_id": 1, "lang_id": "de", "options": "[x,y,z]", "options_json": "", "question": "was?", }, "en": { - "question_id": 1, + "child_question_id": 1, "lang_id": "en", "options": "[1,2,3]", "question": "what?", "options_json": "", }, "fr": { - "question_id": 1, + "child_question_id": 1, "lang_id": "fr", "question": "french...", "options": "[1,2,3]", @@ -445,21 +445,21 @@ def child_questions(): "type": "text", "text": { "de": { - "question_id": 2, + "child_question_id": 2, "lang_id": "de", "options": "[x2,y2,z2]", "options_json": "", "question": "Wo?", }, "en": { - "question_id": 2, + "child_question_id": 2, "lang_id": "en", "options": "[12,22,32]", "question": "Where?", "options_json": "", }, "fr": { - "question_id": 2, + "child_question_id": 2, "lang_id": "fr", "question": "french...", "options": "[12,22,32]", diff --git a/mondey_backend/tests/routers/test_admin.py b/mondey_backend/tests/routers/test_admin.py index 9e2714c4..f3612ec3 100644 --- a/mondey_backend/tests/routers/test_admin.py +++ b/mondey_backend/tests/routers/test_admin.py @@ -274,21 +274,21 @@ def test_create_user_question_works(admin_client: TestClient): "text": { "de": { "options_json": "", - "question_id": 3, + "user_question_id": 3, "options": "", "lang_id": "de", "question": "", }, "en": { "options_json": "", - "question_id": 3, + "user_question_id": 3, "options": "", "lang_id": "en", "question": "", }, "fr": { "options_json": "", - "question_id": 3, + "user_question_id": 3, "options": "", "lang_id": "fr", "question": "", @@ -308,21 +308,21 @@ def test_update_user_question_works(admin_client: TestClient): "text": { "de": { "options_json": "", - "question_id": 1, + "user_question_id": 1, "options": "", "lang_id": "de", "question": "", }, "en": { "options_json": "", - "question_id": 1, + "user_question_id": 1, "options": "", "lang_id": "en", "question": "", }, "fr": { "options_json": "", - "question_id": 1, + "user_question_id": 1, "options": "", "lang_id": "fr", "question": "", @@ -378,21 +378,21 @@ def test_create_child_question_works(admin_client: TestClient): "text": { "de": { "options_json": "", - "question_id": 3, + "child_question_id": 3, "options": "", "lang_id": "de", "question": "", }, "en": { "options_json": "", - "question_id": 3, + "child_question_id": 3, "options": "", "lang_id": "en", "question": "", }, "fr": { "options_json": "", - "question_id": 3, + "child_question_id": 3, "options": "", "lang_id": "fr", "question": "", From 1dbd66b87c812d2e8cf37b89217bd67922861de8 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 16:10:07 +0100 Subject: [PATCH 12/87] finish user question tests --- mondey_backend/tests/routers/test_admin.py | 106 ++++++++++++++++----- 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/mondey_backend/tests/routers/test_admin.py b/mondey_backend/tests/routers/test_admin.py index f3612ec3..14fd5b48 100644 --- a/mondey_backend/tests/routers/test_admin.py +++ b/mondey_backend/tests/routers/test_admin.py @@ -3,6 +3,9 @@ import pytest from fastapi.testclient import TestClient +from sqlmodel import select + +from mondey_backend.models.questions import UserQuestion def test_post_language(admin_client: TestClient): @@ -335,25 +338,92 @@ def test_update_user_question_works(admin_client: TestClient): assert response.status_code == 200 + assert response.json() == { + "id": 1, + "component": "textarea", + "type": "other_thing", + "order": 0, + "options": "some_options", + "text": { + "de": { + "options_json": "", + "user_question_id": 1, + "options": "", + "lang_id": "de", + "question": "", + }, + "en": { + "options_json": "", + "user_question_id": 1, + "options": "", + "lang_id": "en", + "question": "", + }, + "fr": { + "options_json": "", + "user_question_id": 1, + "options": "", + "lang_id": "fr", + "question": "", + }, + }, + "additional_option": "nothing", + } + -# def test_update_user_question_id_not_there(): -# assert 3 == 5 +def test_update_user_question_id_not_there(admin_client: TestClient): + user_question_admin = { + "id": "5", + "component": "textarea", + "type": "other_thing", + "order": 0, + "options": "some_options", + "text": { + "de": { + "options_json": "", + "user_question_id": 1, + "options": "", + "lang_id": "de", + "question": "", + }, + "en": { + "options_json": "", + "user_question_id": 1, + "options": "", + "lang_id": "en", + "question": "", + }, + "fr": { + "options_json": "", + "user_question_id": 1, + "options": "", + "lang_id": "fr", + "question": "", + }, + }, + "additional_option": "nothing", + } + response = admin_client.put("/admin/user-questions", json=user_question_admin) -# def test_update_user_question_database_error(): -# assert 3 == 5 + assert response.status_code == 404 -# def test_delete_user_question_works(): -# assert 3 == 5 +def test_delete_user_question_works(session, admin_client: TestClient): + response = admin_client.delete("/admin/user-questions/1") + assert response.status_code == 200 + assert response.json() == {"ok": True} -# def test_delete_user_question_id_not_there(): -# assert 3 == 5 + user_questions = session.exec(select(UserQuestion)).all() + assert len(user_questions) == 1 + assert user_questions[0].id == 2 -# def test_delete_user_question_database_error(): -# assert 3 == 5 +def test_delete_user_question_id_not_there(admin_client: TestClient): + response = admin_client.delete("/admin/user-questions/12") + + assert response.status_code == 404 def test_get_child_question_admin_works(admin_client: TestClient, child_questions): @@ -402,14 +472,6 @@ def test_create_child_question_works(admin_client: TestClient): } -# def test_create_child_question_id_exists(): -# assert 3 == 5 - - -# def test_create_child_question_id_database_error(): -# assert 3 == 5 - - # def test_update_child_question_works(): # assert 3 == 5 @@ -418,17 +480,9 @@ def test_create_child_question_works(admin_client: TestClient): # assert 3 == 5 -# def test_update_child_question_database_error(): -# assert 3 == 5 - - # def test_delete_child_question_works(): # assert 3 == 5 # def test_delete_child_question_id_not_there(): # assert 3 == 5 - - -# def test_delete_child_question_database_error(): -# assert 3 == 5 From 344bacac8cfbcbb31f0e20932be93c228e0f774b Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 16:28:04 +0100 Subject: [PATCH 13/87] finish python test draft --- .../src/mondey_backend/routers/admin.py | 1 + mondey_backend/tests/routers/test_admin.py | 111 ++++++++++++++---- 2 files changed, 92 insertions(+), 20 deletions(-) diff --git a/mondey_backend/src/mondey_backend/routers/admin.py b/mondey_backend/src/mondey_backend/routers/admin.py index 701f4d96..9be6c41f 100644 --- a/mondey_backend/src/mondey_backend/routers/admin.py +++ b/mondey_backend/src/mondey_backend/routers/admin.py @@ -194,6 +194,7 @@ def update_user_question( user_question: UserQuestionAdmin, ): db_user_question = get(session, UserQuestion, user_question.id) + for key, value in user_question.model_dump(exclude={"text"}).items(): setattr(db_user_question, key, value) update_user_question_text(session, user_question) diff --git a/mondey_backend/tests/routers/test_admin.py b/mondey_backend/tests/routers/test_admin.py index 14fd5b48..7e4d3a2c 100644 --- a/mondey_backend/tests/routers/test_admin.py +++ b/mondey_backend/tests/routers/test_admin.py @@ -5,6 +5,7 @@ from fastapi.testclient import TestClient from sqlmodel import select +from mondey_backend.models.questions import ChildQuestion from mondey_backend.models.questions import UserQuestion @@ -257,7 +258,7 @@ def test_post_milestone_image( def test_get_user_question_admin_works(admin_client: TestClient, user_questions): - response = admin_client.get("/admin/user-questions") + response = admin_client.get("/admin/user-questions/") assert response.status_code == 200 @@ -266,7 +267,7 @@ def test_get_user_question_admin_works(admin_client: TestClient, user_questions) def test_create_user_question_works(admin_client: TestClient): - response = admin_client.post("/admin/user-questions") + response = admin_client.post("/admin/user-questions/") assert response.status_code == 200 assert response.json() == { "id": 3, @@ -303,7 +304,7 @@ def test_create_user_question_works(admin_client: TestClient): def test_update_user_question_works(admin_client: TestClient): user_question_admin = { - "id": "1", + "id": 1, "component": "textarea", "type": "other_thing", "order": 0, @@ -334,7 +335,7 @@ def test_update_user_question_works(admin_client: TestClient): "additional_option": "nothing", } - response = admin_client.put("/admin/user-questions", json=user_question_admin) + response = admin_client.put("/admin/user-questions/", json=user_question_admin) assert response.status_code == 200 @@ -373,7 +374,7 @@ def test_update_user_question_works(admin_client: TestClient): def test_update_user_question_id_not_there(admin_client: TestClient): user_question_admin = { - "id": "5", + "id": 5, "component": "textarea", "type": "other_thing", "order": 0, @@ -381,21 +382,21 @@ def test_update_user_question_id_not_there(admin_client: TestClient): "text": { "de": { "options_json": "", - "user_question_id": 1, + "user_question_id": 5, "options": "", "lang_id": "de", "question": "", }, "en": { "options_json": "", - "user_question_id": 1, + "user_question_id": 5, "options": "", "lang_id": "en", "question": "", }, "fr": { "options_json": "", - "user_question_id": 1, + "user_question_id": 5, "options": "", "lang_id": "fr", "question": "", @@ -404,7 +405,7 @@ def test_update_user_question_id_not_there(admin_client: TestClient): "additional_option": "nothing", } - response = admin_client.put("/admin/user-questions", json=user_question_admin) + response = admin_client.put("/admin/user-questions/", json=user_question_admin) assert response.status_code == 404 @@ -427,16 +428,15 @@ def test_delete_user_question_id_not_there(admin_client: TestClient): def test_get_child_question_admin_works(admin_client: TestClient, child_questions): - response = admin_client.get("/admin/child-questions") + response = admin_client.get("/admin/child-questions/") assert response.status_code == 200 - assert [element["order"] for element in response.json()] == [0, 1] assert response.json() == child_questions def test_create_child_question_works(admin_client: TestClient): - response = admin_client.post("/admin/child-questions") + response = admin_client.post("/admin/child-questions/") assert response.status_code == 200 assert response.json() == { @@ -472,17 +472,88 @@ def test_create_child_question_works(admin_client: TestClient): } -# def test_update_child_question_works(): -# assert 3 == 5 +def test_update_child_question_works(admin_client: TestClient): + child_question_admin = { + "id": 2, + "component": "textarea", + "type": "other_thing", + "order": 0, + "options": "some_options", + "text": { + "de": { + "options_json": "", + "child_question_id": 2, + "options": "", + "lang_id": "de", + "question": "", + }, + "en": { + "options_json": "", + "child_question_id": 2, + "options": "", + "lang_id": "en", + "question": "", + }, + "fr": { + "options_json": "", + "child_question_id": 2, + "options": "", + "lang_id": "fr", + "question": "", + }, + }, + "additional_option": "nothing", + } + response = admin_client.put("/admin/child-questions", json=child_question_admin) + assert response.status_code == 200 -# def test_update_child_question_id_not_there(): -# assert 3 == 5 +def test_update_child_question_id_not_there(admin_client: TestClient): + child_question_admin = { + "id": 5, + "component": "textarea", + "type": "other_thing", + "order": 0, + "options": "some_options", + "text": { + "de": { + "options_json": "", + "child_question_id": 5, + "options": "", + "lang_id": "de", + "question": "", + }, + "en": { + "options_json": "", + "child_question_id": 5, + "options": "", + "lang_id": "en", + "question": "", + }, + "fr": { + "options_json": "", + "child_question_id": 5, + "options": "", + "lang_id": "fr", + "question": "", + }, + }, + "additional_option": "nothing", + } + response = admin_client.put("/admin/child-questions/", json=child_question_admin) + assert response.status_code == 404 -# def test_delete_child_question_works(): -# assert 3 == 5 +def test_delete_child_question_works(session, admin_client: TestClient): + response = admin_client.delete("/admin/child-questions/1") + assert response.status_code == 200 + assert response.json() == {"ok": True} + + child_questions = session.exec(select(ChildQuestion)).all() + assert len(child_questions) == 1 + assert child_questions[0].id == 2 -# def test_delete_child_question_id_not_there(): -# assert 3 == 5 +def test_delete_child_question_id_not_there(admin_client: TestClient): + response = admin_client.delete("/admin/child-questions/12") + assert response.status_code == 404 From ce18e0104049ec38ea5db7cc474449963313a0f0 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 16:33:53 +0100 Subject: [PATCH 14/87] Squashed commit of the following: commit 1ed8ef3df0ca80fcf756bedf38d5110ed1071c92 Merge: 83b2e59 7679af8 Author: Harald Mack <39521902+MaHaWo@users.noreply.github.com> Date: Tue Oct 29 15:53:23 2024 +0100 Merge pull request #130 from ssciwr/fix-userquestions-in-admin Integrate admin interface into user landing page commit 7679af8b51c99197726513ba6099446d496c79f2 Author: github-actions[bot] Date: Tue Oct 29 13:31:01 2024 +0000 update openapi.json & openapi-ts client, run pnpm format commit c28089c870fff48fe22fad194330262b32663f89 Merge: 03f911a 5b737fc Author: Harald Mack Date: Tue Oct 29 14:30:15 2024 +0100 Merge branch 'fix-userquestions-in-admin' of github.com:ssciwr/mondey into fix-userquestions-in-admin commit 03f911a873877fcd991787cf74d3c3fe84737667 Author: Harald Mack Date: Tue Oct 29 14:30:11 2024 +0100 add autocomplete to formdata commit 5b737fca2a0497c5d564cbc4ce425beee1422741 Author: Harald Mack <39521902+MaHaWo@users.noreply.github.com> Date: Tue Oct 29 14:29:50 2024 +0100 Update mondey_backend/src/mondey_backend/models/questions.py Co-authored-by: Liam Keegan commit b7fe5e8f1a2e69f3456a584eb9f74e9e49652dc9 Author: Harald Mack <39521902+MaHaWo@users.noreply.github.com> Date: Tue Oct 29 14:22:25 2024 +0100 Update mondey_backend/src/mondey_backend/routers/admin.py Co-authored-by: Liam Keegan commit a5892fe4da6764b51afae394169413b11209f7c8 Author: Harald Mack <39521902+MaHaWo@users.noreply.github.com> Date: Tue Oct 29 14:22:07 2024 +0100 Update frontend/src/lib/components/Admin/EditUserQuestionModal.svelte use localization in question modal Co-authored-by: Liam Keegan commit 57dfce2dc2aed9bdc366ca47a214f4fa0774e266 Author: Harald Mack Date: Tue Oct 29 14:11:44 2024 +0100 remove debug logout commit 0a6b213c8c8778fc4fdeb90f7425547a3a4bf885 Author: Harald Mack Date: Tue Oct 29 14:09:19 2024 +0100 fix error in loop commit fb7ba48373c57ed1e56b8de1c4854e71c31ac705 Author: Harald Mack Date: Mon Oct 28 17:00:24 2024 +0100 update lock file commit e9e27d2833595e821d49aca0af073fc5bcb16e5a Author: Harald Mack Date: Mon Oct 28 16:58:27 2024 +0100 fix conflict commit c0cb20a111a72ad9cc38a8b2937428dabd2f00e2 Author: Harald Mack Date: Mon Oct 28 16:53:55 2024 +0100 generate code anew commit 1230ead6a5f22332248a066f06a20c68039948a5 Merge: 3418a85 83b2e59 Author: Harald Mack Date: Mon Oct 28 16:53:15 2024 +0100 Merge branch 'main' into fix-userquestions-in-admin commit 3418a85c6091844973ae54a5db0c0a16c5fb5e3c Author: Harald Mack Date: Mon Oct 28 16:44:10 2024 +0100 remove researchpage commit 687a5735c0218d40c5c666781cb0efeeeb710204 Author: github-actions[bot] Date: Mon Oct 28 15:34:59 2024 +0000 update openapi.json & openapi-ts client, run pnpm format commit f11d80d7d1ecbbe2207fb506b89de934581595c4 Author: Harald Mack Date: Mon Oct 28 16:28:55 2024 +0100 remove comment commit 52c8d6192e42e1794d9e5fb9c710b07625d0b2be Author: Harald Mack Date: Mon Oct 28 16:28:16 2024 +0100 remove comments commit 1d443711a40cea26c33f5b861b29dc5fed5305c9 Author: github-actions[bot] Date: Mon Oct 28 15:02:16 2024 +0000 update openapi.json & openapi-ts client, run pnpm format commit 36ddf78eb354e5b8033954ae2b10b266a4c51e2d Author: Harald Mack Date: Mon Oct 28 15:41:15 2024 +0100 adjust language label commit df5667c04d8a2c32cbb8d662618a2a9cdb016f62 Merge: 66b6e45 5fac037 Author: Harald Mack Date: Mon Oct 28 15:27:35 2024 +0100 Merge branch 'main' into fix-userquestions-in-admin commit 66b6e45ac11d3eb6ef47335b62ab5a3b2fa9bb13 Author: Harald Mack Date: Mon Oct 28 15:14:12 2024 +0100 remove langStore commit 43f3f5c0325302174246dcc3a403b60dde051a36 Author: Harald Mack Date: Mon Oct 28 15:11:18 2024 +0100 remove langstore commit 732a9c959feb1723b7bd3dd14da2da4015f3f7f6 Author: Harald Mack Date: Mon Oct 28 15:09:19 2024 +0100 add translations from main commit c125a488a323d3c9cc1fbf3b7d4a323e3ae3afb5 Author: Harald Mack Date: Mon Oct 28 15:08:43 2024 +0100 remove languages commit 2fb1c6aa7781d2837ee99802453cff2f79a49531 Author: Harald Mack Date: Mon Oct 28 15:04:02 2024 +0100 add localechooser from main commit 24ca1f5e2e7169ce6079ba614dec9c9bbdff1254 Author: Harald Mack Date: Mon Oct 28 15:02:39 2024 +0100 add master i18n commit 2c321ecd070a77b7f2e32d190219bc682b543e7d Author: Harald Mack Date: Mon Oct 28 14:40:46 2024 +0100 fix python tests commit 8295bb29e775abca9d33e80445f136f3dd1990c6 Author: Harald Mack Date: Mon Oct 28 14:34:08 2024 +0100 fix userProfile commit f3bb8157ff286b2933d9243d97a36707afa3b166 Author: Harald Mack Date: Mon Oct 28 14:13:41 2024 +0100 fix language indexing problem commit 96e22153a9b982e8c1998d34c156748231d9d71f Author: Harald Mack Date: Mon Oct 28 13:46:51 2024 +0100 fix bug in data reading, work on fixing languages commit e32011cff9079a9ca67a7698fe3e8a25f9fb5556 Author: Harald Mack Date: Mon Oct 28 07:35:03 2024 +0100 make datainput simpler commit b99aa08546dba49a2be260107eab3186915819e6 Author: Harald Mack Date: Sun Oct 27 22:02:47 2024 +0100 update to svelte 5, use runes mode for datainput commit 2a2f018ae38b7fc2ca1a9e47c14dba16a6f22814 Author: Harald Mack Date: Fri Oct 25 16:56:11 2024 +0200 work on simplifying datastructure commit b424001f7bd61afd0ca418ccd3db18aec7522d5c Author: Harald Mack Date: Fri Oct 25 16:19:20 2024 +0200 add fields commit 11965f01e0ea9093f3f5664e3a6eef824f5299d6 Author: Harald Mack Date: Fri Oct 25 16:02:58 2024 +0200 work on integrating necessary datastructure everywhere commit d16f63706664a7c567fd000c3e0c28df01c91a23 Author: Harald Mack Date: Fri Oct 25 11:43:36 2024 +0200 fix json creation for userquestion commit 3c8a66bd12e4fc1a2b56e4fcfdb1d12cfd5593d0 Author: Harald Mack Date: Fri Oct 25 11:34:26 2024 +0200 correct language indexing commit 9499dae187cf35573c94ef025ef4510ebd140d35 Author: Harald Mack Date: Thu Oct 24 21:11:16 2024 +0200 start fising lang_id issue commit 13abba34558bd6b396b3e2961446b1f75a17d291 Author: Harald Mack Date: Thu Oct 24 20:30:20 2024 +0200 fix error commit 7a744dd56fd9c37a18a3880bb07419c62d325ab2 Author: github-actions[bot] Date: Thu Oct 24 13:57:52 2024 +0000 update openapi.json & openapi-ts client, run pnpm format commit bfb39eb7c6381bdae96b988d0b07e97bbe0f56a8 Author: Harald Mack Date: Thu Oct 24 13:34:15 2024 +0200 work on making editing of questions usable commit 4025b925bf0104d66f7aa165839ae9056b2b44f7 Author: Harald Mack Date: Thu Oct 24 11:18:53 2024 +0200 add elements for logged out user, delete separate verify component commit 6722542df80dd54775872ade353f02047dc52cea Author: Harald Mack Date: Thu Oct 24 11:11:32 2024 +0200 include admin page into userlandingpage, add admin component instead of route, --- frontend/pnpm-lock.yaml | 10 +- frontend/src/lib/client/schemas.gen.ts | 49 +- frontend/src/lib/client/types.gen.ts | 10 +- .../Admin/EditMilestoneGroupModal.svelte | 12 +- .../Admin/EditMilestoneModal.svelte | 10 +- .../Admin/EditUserQuestionModal.svelte | 66 +- .../lib/components/Admin/InputPreview.svelte | 12 +- .../src/lib/components/Admin/Languages.svelte | 18 +- .../src/lib/components/Admin/Login.svelte | 50 - .../components/Admin/MilestoneGroups.svelte | 38 +- .../lib/components/Admin/Translations.svelte | 6 +- .../lib/components/Admin/UserQuestions.svelte | 23 +- .../components/AdminPage.svelte} | 17 +- .../lib/components/DataInput/RadioList.svelte | 2 +- frontend/src/lib/components/Milestone.svelte | 30 +- .../src/lib/components/UserDataInput.svelte | 127 +- .../src/lib/components/UserLandingPage.svelte | 107 +- frontend/src/lib/components/UserLogin.svelte | 6 +- .../src/lib/components/UserProfile.svelte | 24 +- .../lib/components/UserRegistration.svelte | 2 +- frontend/src/lib/i18n.ts | 2 +- frontend/src/lib/stores/componentStore.ts | 14 +- frontend/src/lib/stores/userStore.ts | 35 +- frontend/src/locales/de.json | 13 +- .../userLand/userLandingpage/+page.svelte | 130 +- mondey_backend/openapi.json | 2047 ++++++++++++++++- 26 files changed, 2427 insertions(+), 433 deletions(-) delete mode 100644 frontend/src/lib/components/Admin/Login.svelte rename frontend/src/{routes/admin/+page.svelte => lib/components/AdminPage.svelte} (79%) diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index f696a775..e215a788 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -431,8 +431,8 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 - '@eslint-community/regexpp@4.11.1': - resolution: {integrity: sha512-m4DVN9ZqskZoLU5GlWZadwDnYo3vAEydiUayB9widCl9ffWx2IvPnp6n3on5rJmziJSw9Bv+Z3ChDVdMwXCY8Q==} + '@eslint-community/regexpp@4.11.2': + resolution: {integrity: sha512-2WwyTYNVaMNUWPZTOJdkax9iqTdirrApgTbk+Qoq5EPX6myqZvG8QGFRgdKmkjKVG6/G/a565vpPauHk0+hpBA==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} '@eslint/config-array@0.18.0': @@ -2708,7 +2708,7 @@ snapshots: eslint: 9.13.0(jiti@1.21.6) eslint-visitor-keys: 3.4.3 - '@eslint-community/regexpp@4.11.1': {} + '@eslint-community/regexpp@4.11.2': {} '@eslint/config-array@0.18.0': dependencies: @@ -3011,7 +3011,7 @@ snapshots: '@typescript-eslint/eslint-plugin@8.11.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.6.3))(eslint@9.13.0(jiti@1.21.6))(typescript@5.6.3)': dependencies: - '@eslint-community/regexpp': 4.11.1 + '@eslint-community/regexpp': 4.11.2 '@typescript-eslint/parser': 8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.6.3) '@typescript-eslint/scope-manager': 8.11.0 '@typescript-eslint/type-utils': 8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.6.3) @@ -3552,7 +3552,7 @@ snapshots: eslint@9.13.0(jiti@1.21.6): dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.13.0(jiti@1.21.6)) - '@eslint-community/regexpp': 4.11.1 + '@eslint-community/regexpp': 4.11.2 '@eslint/config-array': 0.18.0 '@eslint/core': 0.7.0 '@eslint/eslintrc': 3.1.0 diff --git a/frontend/src/lib/client/schemas.gen.ts b/frontend/src/lib/client/schemas.gen.ts index 79f0b341..202fdef9 100644 --- a/frontend/src/lib/client/schemas.gen.ts +++ b/frontend/src/lib/client/schemas.gen.ts @@ -615,13 +615,20 @@ export const UserAnswerPublicSchema = { type: 'integer', title: 'Question Id' }, - non_standard: { - type: 'boolean', - title: 'Non Standard' + additional_answer: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Additional Answer' } }, type: 'object', - required: ['answer', 'question_id', 'non_standard'], + required: ['answer', 'question_id', 'additional_answer'], title: 'UserAnswerPublic', description: `External data model for UserAnswers @@ -705,9 +712,15 @@ export const UserQuestionAdminSchema = { type: 'integer', title: 'Order' }, - input: { + component: { + type: 'string', + title: 'Component', + default: 'select' + }, + type: { type: 'string', - title: 'Input' + title: 'Type', + default: 'text' }, options: { type: 'string', @@ -720,10 +733,15 @@ export const UserQuestionAdminSchema = { type: 'object', title: 'Text', default: {} + }, + additional_option: { + type: 'string', + title: 'Additional Option', + default: '' } }, type: 'object', - required: ['id', 'order', 'input', 'options'], + required: ['id', 'order', 'options'], title: 'UserQuestionAdmin' } as const; @@ -733,9 +751,15 @@ export const UserQuestionPublicSchema = { type: 'integer', title: 'Id' }, - input: { + component: { type: 'string', - title: 'Input' + title: 'Component', + default: 'select' + }, + type: { + type: 'string', + title: 'Type', + default: 'text' }, text: { additionalProperties: { @@ -744,10 +768,15 @@ export const UserQuestionPublicSchema = { type: 'object', title: 'Text', default: {} + }, + additional_option: { + type: 'string', + title: 'Additional Option', + default: '' } }, type: 'object', - required: ['id', 'input'], + required: ['id'], title: 'UserQuestionPublic' } as const; diff --git a/frontend/src/lib/client/types.gen.ts b/frontend/src/lib/client/types.gen.ts index 4850924b..8126bb60 100644 --- a/frontend/src/lib/client/types.gen.ts +++ b/frontend/src/lib/client/types.gen.ts @@ -168,7 +168,7 @@ export type MilestoneTextPublic = { export type UserAnswerPublic = { answer: string; question_id: number; - non_standard: boolean; + additional_answer: string | null; }; export type UserCreate = { @@ -183,19 +183,23 @@ export type UserCreate = { export type UserQuestionAdmin = { id: number; order: number; - input: string; + component?: string; + type?: string; options: string; text?: { [key: string]: UserQuestionText; }; + additional_option?: string; }; export type UserQuestionPublic = { id: number; - input: string; + component?: string; + type?: string; text?: { [key: string]: UserQuestionTextPublic; }; + additional_option?: string; }; export type UserQuestionText = { diff --git a/frontend/src/lib/components/Admin/EditMilestoneGroupModal.svelte b/frontend/src/lib/components/Admin/EditMilestoneGroupModal.svelte index a9a0b82a..edd3d349 100644 --- a/frontend/src/lib/components/Admin/EditMilestoneGroupModal.svelte +++ b/frontend/src/lib/components/Admin/EditMilestoneGroupModal.svelte @@ -1,14 +1,14 @@
- +
- {#if data.input === 'select'} + {#if data.component === 'select'} diff --git a/frontend/src/lib/components/Admin/Languages.svelte b/frontend/src/lib/components/Admin/Languages.svelte index 8730c3e8..61ee46e4 100644 --- a/frontend/src/lib/components/Admin/Languages.svelte +++ b/frontend/src/lib/components/Admin/Languages.svelte @@ -1,24 +1,24 @@ - - -
Admin login
-
-
-
- - -
-
- - -
- - {#if errorCode !== ''} - {$_(`login.${errorCode}`)} - {/if} -
-
-
diff --git a/frontend/src/lib/components/Admin/MilestoneGroups.svelte b/frontend/src/lib/components/Admin/MilestoneGroups.svelte index ed48f465..1f38999d 100644 --- a/frontend/src/lib/components/Admin/MilestoneGroups.svelte +++ b/frontend/src/lib/components/Admin/MilestoneGroups.svelte @@ -1,34 +1,34 @@ - +

{$_('admin.user-questions')}

@@ -81,7 +80,7 @@ {userQuestion?.text[$locale]?.question} - {userQuestion?.input} + {userQuestion?.component} {userQuestion?.text[$locale]?.options} diff --git a/frontend/src/routes/admin/+page.svelte b/frontend/src/lib/components/AdminPage.svelte similarity index 79% rename from frontend/src/routes/admin/+page.svelte rename to frontend/src/lib/components/AdminPage.svelte index a0d56a8d..c86b9693 100644 --- a/frontend/src/routes/admin/+page.svelte +++ b/frontend/src/lib/components/AdminPage.svelte @@ -3,25 +3,20 @@ -{#if !adminUser.value || !adminUser.value.is_superuser} -
- -
-{:else} +
@@ -52,4 +47,4 @@ -{/if} + diff --git a/frontend/src/lib/components/DataInput/RadioList.svelte b/frontend/src/lib/components/DataInput/RadioList.svelte index a2a5d978..d555cf55 100644 --- a/frontend/src/lib/components/DataInput/RadioList.svelte +++ b/frontend/src/lib/components/DataInput/RadioList.svelte @@ -17,7 +17,7 @@ } export let value: any; export let disabled: boolean = false; - export let required: boolean = false; + export let required: boolean = true; let windowWidth = 1920; $: smallScreen = windowWidth < 800; diff --git a/frontend/src/lib/components/Milestone.svelte b/frontend/src/lib/components/Milestone.svelte index c8b17bb1..07725210 100644 --- a/frontend/src/lib/components/Milestone.svelte +++ b/frontend/src/lib/components/Milestone.svelte @@ -1,29 +1,29 @@ @@ -171,7 +188,7 @@ >
- {#each data as element, i} + {#each questionaire as element, i} { console.log('dataiscurrent click'); - for (let element of data) { + for (let element of questionaire) { element.props.disabled = false; } // README: this forces a rerender. It is necessary because svelte does not react to nested references being changed. There must be a better solution to this? Svelte 5 runes would be one that comes to mind. - data = [...data]; + questionaire = [...questionaire]; dataIsCurrent = false; }} diff --git a/frontend/src/lib/components/UserLandingPage.svelte b/frontend/src/lib/components/UserLandingPage.svelte index 4dd25e0f..1eb78df6 100644 --- a/frontend/src/lib/components/UserLandingPage.svelte +++ b/frontend/src/lib/components/UserLandingPage.svelte @@ -1,52 +1,75 @@ -{#if isVerifed === true} -
- - -
- - Persönliche Daten -
- -
- -
- - Kinder -
- -
-
-
+{#if get(currentUser)} + {#if get(currentUser)?.is_verified === true} +
+ + +
+ + Persönliche Daten +
+ +
+ +
+ + Kinder +
+ +
+ + {#if get(currentUser)?.is_superuser} + +
+ + {$_('admin.title')} +
+ +
+ {/if} + {#if get(currentUser)?.is_researcher} + +
+ + {$_('researcher.title')} +
+ +
+ {/if} +
+
+ {:else} + + {/if} {:else} - +
+
+ {$_('login.notLoggedIn')} +
+
+ {/if} diff --git a/frontend/src/lib/components/UserLogin.svelte b/frontend/src/lib/components/UserLogin.svelte index 08dda067..05c78cd4 100644 --- a/frontend/src/lib/components/UserLogin.svelte +++ b/frontend/src/lib/components/UserLogin.svelte @@ -66,7 +66,8 @@ type: 'email', placeholder: $_('login.usernameLabel'), required: true, - id: 'username' + id: 'username', + autocomplete: 'username' } }, { @@ -77,7 +78,8 @@ type: 'password', placeholder: $_('login.passwordLabel'), required: true, - id: 'password' + id: 'password', + autocomplete: 'password' } } ]; diff --git a/frontend/src/lib/components/UserProfile.svelte b/frontend/src/lib/components/UserProfile.svelte index 05bb301c..899cad68 100644 --- a/frontend/src/lib/components/UserProfile.svelte +++ b/frontend/src/lib/components/UserProfile.svelte @@ -7,19 +7,19 @@ import { Button, Heading, Popover } from 'flowbite-svelte'; import { onDestroy } from 'svelte'; import { _ } from 'svelte-i18n'; - import { get } from 'svelte/store'; import AlertMessage from './AlertMessage.svelte'; - export let triggeredBy = ''; + let { triggeredBy = '' } = $props(); + let showAlert: boolean = $state(false); + let alertMessage: string = $state($_('login.alertMessageError')); + let userData: UserRead | null = $state(null); - let userData: UserRead | null = get(currentUser); - let showAlert: boolean = false; - let alertMessage: string = $_('login.alertMessageError'); - - const unsubscribe = currentUser.subscribe((data) => { - userData = data; + const unsubscribe = currentUser.subscribe((value) => { + userData = value; }); + onDestroy(unsubscribe); + async function logout(): Promise { const response = await authCookieLogout(); if (response.error) { @@ -27,15 +27,11 @@ showAlert = true; alertMessage += ': ' + response.error.detail; } else { - console.log('Successful logout of user ', userData.email, response.response.status); + console.log('Successful logout of user ', userData?.email, response.response.status); userData = null; goto(`/${base}`); } } - - onDestroy(unsubscribe); - - $: console.log('userData in profile: ', userData); @@ -50,7 +46,7 @@ {/if} {#if userData !== null}
-

{userData.email}

+

{userData?.email}

diff --git a/frontend/src/lib/components/UserRegistration.svelte b/frontend/src/lib/components/UserRegistration.svelte index 8a3952e6..a1c69e5e 100644 --- a/frontend/src/lib/components/UserRegistration.svelte +++ b/frontend/src/lib/components/UserRegistration.svelte @@ -4,10 +4,10 @@ import { type RegisterRegisterData } from '$lib/client/types.gen'; import AlertMessage from '$lib/components/AlertMessage.svelte'; import DataInput from '$lib/components/DataInput/DataInput.svelte'; + import UserVerify from '$lib/components/UserVerify.svelte'; import { preventDefault } from '$lib/util'; import { Button, Card, Heading, Input, Select } from 'flowbite-svelte'; import { _ } from 'svelte-i18n'; - import UserVerify from './UserVerify.svelte'; async function submitData(): Promise { const equalPW = data[1].value !== '' && data[2].value === data[1].value; diff --git a/frontend/src/lib/i18n.ts b/frontend/src/lib/i18n.ts index a50b228c..e13d4f8a 100644 --- a/frontend/src/lib/i18n.ts +++ b/frontend/src/lib/i18n.ts @@ -1,5 +1,5 @@ -import { init, addMessages } from 'svelte-i18n'; import { getLanguages } from '$lib/client'; +import { addMessages, init } from 'svelte-i18n'; import de from '../locales/de.json'; export async function getI18nJson(lang_id: string) { diff --git a/frontend/src/lib/stores/componentStore.ts b/frontend/src/lib/stores/componentStore.ts index 7ec39cd5..c2c220f3 100644 --- a/frontend/src/lib/stores/componentStore.ts +++ b/frontend/src/lib/stores/componentStore.ts @@ -1,3 +1,4 @@ +import AdminPage from '$lib/components/AdminPage.svelte'; import ChildrenGallery from '$lib/components/ChildrenGallery.svelte'; import ChildrenRegistration from '$lib/components/ChildrenRegistration.svelte'; import RadioList from '$lib/components/DataInput/RadioList.svelte'; @@ -6,11 +7,16 @@ import MilestoneGroup from '$lib/components/MilestoneGroup.svelte'; import MilestoneOverview from '$lib/components/MilestoneOverview.svelte'; import UserDataInput from '$lib/components/UserDataInput.svelte'; -import { Fileupload, Input, MultiSelect, Select, Textarea } from 'flowbite-svelte'; +import { Card, Fileupload, Input, MultiSelect, Select, Textarea } from 'flowbite-svelte'; +import type { Component } from 'svelte'; import { writable } from 'svelte/store'; +interface ComponentTable { + [key: string]: Component; +} + // put all the components here. can be an expanding list -export const componentTable = { +export const componentTable: ComponentTable = { userDataInput: UserDataInput, childrenGallery: ChildrenGallery, childrenRegistration: ChildrenRegistration, @@ -22,7 +28,9 @@ export const componentTable = { multiSelect: MultiSelect, select: Select, fileupload: Fileupload, - textarea: Textarea + textarea: Textarea, + adminPage: AdminPage, + researchPage: Card }; export const activeTabPersonal = writable('userDataInput'); export const activeTabChildren = writable('childrenGallery'); diff --git a/frontend/src/lib/stores/userStore.ts b/frontend/src/lib/stores/userStore.ts index aab5efb3..4eba40e8 100644 --- a/frontend/src/lib/stores/userStore.ts +++ b/frontend/src/lib/stores/userStore.ts @@ -1,7 +1,10 @@ +import { authCookieLogin, usersCurrentUser } from '$lib/client/services.gen'; import { type UserRead } from '$lib/client/types.gen'; import { BasicStore } from '$lib/stores/basicStore'; import { writable } from 'svelte/store'; +import { type Body_auth_cookie_login_auth_login_post } from '$lib/client/types.gen'; + interface UserData { name: string; id: string; @@ -90,4 +93,34 @@ async function hash(input: string): string { const currentUser = writable(null as null | UserRead); -export { createDummyUser, currentUser, hash, users, UserStore, type UserData, type UserList }; +async function login(loginData: Body_auth_cookie_login_auth_login_post) { + const response = await authCookieLogin({ body: loginData }); + if (response.error) { + return response.error?.detail as string; + } else { + return ''; + } +} + +async function refreshUser() { + const { data, error } = await usersCurrentUser(); + + if (error || data === undefined) { + currentUser.set(null); + + console.log('Failed to get current User'); + } else { + currentUser.set(data as UserRead); + } +} + +export { + createDummyUser, + currentUser, + hash, + login, + refreshUser, + users, + type UserData, + type UserList +}; diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 1528a8f8..882d4f3f 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -16,12 +16,16 @@ "autonext": "Automatisch weiter" }, "admin": { + "title": "Administration", "languages": "Sprachen", "milestones": "Meilensteine", "milestone-groups": "Meilensteingruppen", "translations": "Übersetzungen", "user-questions": "Benutzerfragen", "question": "Frage", + "selectOptions": "Optionen", + "actions": "Aktionen", + "selectPlaceholder": "Erstens,Zweitens,Drittens;", "add": "Hinzufügen", "edit": "Bearbeiten", "delete": "Löschen", @@ -30,11 +34,17 @@ "no-cancel": "Nein, abbrechen", "save-changes": "Änderungen speichern", "cancel": "Abbrechen", - "title": "Titel", "desc": "Beschreibung", "obs": "Beobachtungshinweise", "help": "Förderhilfen", "image": "Bild", + "images": "Bilder", + "min-age-months": "Mindestalter in Monaten", + "max-age-months": "Höchstalter in Monaten", + "editUserQuestionTitle": "Frage an Benutzer editieren" + }, + "researcher": { + "title": "Wissenschaft", "images": "Bilder" }, "registration": { @@ -62,6 +72,7 @@ "alertMessageTitle": "Fehler", "badCredentials": "Ungültige E-Mail-Adresse oder ungültiges Passwort", "badActiveUser": "Der Benutzer konnte nicht gefunden werden", + "notLoggedIn": "Bitte melden sie sich erneut an", "unauthorized": "Zugang verweigert", "usernameLabel": "Benutzerkennung", "passwordLabel": "Passwort", diff --git a/frontend/src/routes/userLand/userLandingpage/+page.svelte b/frontend/src/routes/userLand/userLandingpage/+page.svelte index c674b96b..e3b20c66 100644 --- a/frontend/src/routes/userLand/userLandingpage/+page.svelte +++ b/frontend/src/routes/userLand/userLandingpage/+page.svelte @@ -1,133 +1,5 @@ - + diff --git a/mondey_backend/openapi.json b/mondey_backend/openapi.json index 37c837b8..db0bc180 100644 --- a/mondey_backend/openapi.json +++ b/mondey_backend/openapi.json @@ -1 +1,2046 @@ -{"openapi": "3.1.0", "info": {"title": "MONDEY API", "version": "0.1.0"}, "paths": {"/languages/": {"get": {"tags": ["milestones"], "summary": "Get Languages", "operationId": "get_languages", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"type": "string"}, "type": "array", "title": "Response Get Languages Languages Get"}}}}}}}, "/milestones/": {"get": {"tags": ["milestones"], "summary": "Get Milestones", "operationId": "get_milestones", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestonePublic"}, "type": "array", "title": "Response Get Milestones Milestones Get"}}}}}}}, "/milestones/{milestone_id}": {"get": {"tags": ["milestones"], "summary": "Get Milestone", "operationId": "get_milestone", "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestonePublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/milestone-groups/": {"get": {"tags": ["milestones"], "summary": "Get Milestone Groups", "operationId": "get_milestone_groups", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestoneGroupPublic"}, "type": "array", "title": "Response Get Milestone Groups Milestone Groups Get"}}}}}}}, "/milestone-groups/{milestone_group_id}": {"get": {"tags": ["milestones"], "summary": "Get Milestone Group", "operationId": "get_milestone_group", "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/user-questions/": {"get": {"tags": ["questions"], "summary": "Get User Questions", "operationId": "get_user_questions", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserQuestionPublic"}, "type": "array", "title": "Response Get User Questions User Questions Get"}}}}}}}, "/child-questions/": {"get": {"tags": ["questions"], "summary": "Get Child Questions", "operationId": "get_child_questions", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildQuestionPublic"}, "type": "array", "title": "Response Get Child Questions Child Questions Get"}}}}}}}, "/admin/languages/": {"post": {"tags": ["admin"], "summary": "Create Language", "operationId": "create_language", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Language"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Language"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/languages/{language_id}": {"delete": {"tags": ["admin"], "summary": "Delete Language", "operationId": "delete_language", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "language_id", "in": "path", "required": true, "schema": {"type": "string", "title": "Language Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/i18n/{language_id}": {"put": {"tags": ["admin"], "summary": "Update I18N", "operationId": "update_i18n", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "language_id", "in": "path", "required": true, "schema": {"type": "string", "title": "Language Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": {"type": "object", "additionalProperties": {"type": "string"}}, "title": "I18Dict"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-groups/": {"get": {"tags": ["admin"], "summary": "Get Milestone Groups Admin", "operationId": "get_milestone_groups_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}, "type": "array", "title": "Response Get Milestone Groups Admin Admin Milestone Groups Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create Milestone Group Admin", "operationId": "create_milestone_group_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestone-groups": {"put": {"tags": ["admin"], "summary": "Update Milestone Group Admin", "operationId": "update_milestone_group_admin", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestone-groups/{milestone_group_id}": {"delete": {"tags": ["admin"], "summary": "Delete Milestone Group Admin", "operationId": "delete_milestone_group_admin", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-group-images/{milestone_group_id}": {"put": {"tags": ["admin"], "summary": "Upload Milestone Group Image", "operationId": "upload_milestone_group_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestones/{milestone_group_id}": {"post": {"tags": ["admin"], "summary": "Create Milestone", "operationId": "create_milestone", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestones/": {"put": {"tags": ["admin"], "summary": "Update Milestone", "operationId": "update_milestone", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestones/{milestone_id}": {"delete": {"tags": ["admin"], "summary": "Delete Milestone", "operationId": "delete_milestone", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-images/{milestone_id}": {"post": {"tags": ["admin"], "summary": "Upload Milestone Image", "operationId": "upload_milestone_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_milestone_image_admin_milestone_images__milestone_id__post"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneImage"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/user-questions/": {"get": {"tags": ["admin"], "summary": "Get User Questions Admin", "operationId": "get_user_questions_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserQuestionAdmin"}, "type": "array", "title": "Response Get User Questions Admin Admin User Questions Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["admin"], "summary": "Update User Question", "operationId": "update_user_question", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create User Question", "operationId": "create_user_question", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/user-questions/{user_question_id}": {"delete": {"tags": ["admin"], "summary": "Delete User Question", "operationId": "delete_user_question", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "user_question_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "User Question Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/child-questions/": {"get": {"tags": ["admin"], "summary": "Get Child Questions Admin", "operationId": "get_child_questions_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildQuestionAdmin"}, "type": "array", "title": "Response Get Child Questions Admin Admin Child Questions Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["admin"], "summary": "Update Child Question", "operationId": "update_child_question", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildQuestionAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildQuestionAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create Child Question", "operationId": "create_child_question", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildQuestionAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/child-questions/{child_question_id}": {"delete": {"tags": ["admin"], "summary": "Delete Child Question", "operationId": "delete_child_question", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_question_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Question Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/me": {"get": {"tags": ["users"], "summary": "Users:Current User", "operationId": "users:current_user", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}}, "security": [{"APIKeyCookie": []}]}, "patch": {"tags": ["users"], "summary": "Users:Patch Current User", "operationId": "users:patch_current_user", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserUpdate"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"UPDATE_USER_EMAIL_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS"}}, "UPDATE_USER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "UPDATE_USER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/{id}": {"get": {"tags": ["users"], "summary": "Users:User", "operationId": "users:user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "patch": {"tags": ["users"], "summary": "Users:Patch User", "operationId": "users:patch_user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserUpdate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "400": {"content": {"application/json": {"examples": {"UPDATE_USER_EMAIL_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS"}}, "UPDATE_USER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "UPDATE_USER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}, "schema": {"$ref": "#/components/schemas/ErrorModel"}}}, "description": "Bad Request"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "delete": {"tags": ["users"], "summary": "Users:Delete User", "operationId": "users:delete_user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "responses": {"204": {"description": "Successful Response"}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/children/": {"get": {"tags": ["users"], "summary": "Get Children", "operationId": "get_children", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildPublic"}, "type": "array", "title": "Response Get Children Users Children Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Child", "operationId": "update_child", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["users"], "summary": "Create Child", "operationId": "create_child", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildCreate"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/children/{child_id}": {"delete": {"tags": ["users"], "summary": "Delete Child", "operationId": "delete_child", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/children-images/{child_id}": {"get": {"tags": ["users"], "summary": "Get Child Image", "operationId": "get_child_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "put": {"tags": ["users"], "summary": "Upload Child Image", "operationId": "upload_child_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_child_image_users_children_images__child_id__put"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/milestone-answers/{child_id}": {"get": {"tags": ["users"], "summary": "Get Current Milestone Answer Session", "operationId": "get_current_milestone_answer_session", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerSessionPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/milestone-answers/{milestone_answer_session_id}": {"put": {"tags": ["users"], "summary": "Update Milestone Answer", "operationId": "update_milestone_answer", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_answer_session_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Answer Session Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/user-answers/": {"get": {"tags": ["users"], "summary": "Get Current User Answers", "operationId": "get_current_user_answers", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "Response Get Current User Answers Users User Answers Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Current User Answers", "operationId": "update_current_user_answers", "requestBody": {"content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "New Answers"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "Response Update Current User Answers Users User Answers Put"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/children-answers/": {"get": {"tags": ["users"], "summary": "Get Current Children Answers", "operationId": "get_current_children_answers", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildAnswerPublic"}, "type": "array", "title": "Response Get Current Children Answers Users Children Answers Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Current Children Answers", "operationId": "update_current_children_answers", "requestBody": {"content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildAnswerPublic"}, "type": "array", "title": "New Answers"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildAnswerPublic"}, "type": "array", "title": "Response Update Current Children Answers Users Children Answers Put"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/auth/login": {"post": {"tags": ["auth"], "summary": "Auth:Cookie.Login", "operationId": "auth:cookie.login", "requestBody": {"content": {"application/x-www-form-urlencoded": {"schema": {"$ref": "#/components/schemas/Body_auth_cookie_login_auth_login_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"LOGIN_BAD_CREDENTIALS": {"summary": "Bad credentials or the user is inactive.", "value": {"detail": "LOGIN_BAD_CREDENTIALS"}}, "LOGIN_USER_NOT_VERIFIED": {"summary": "The user is not verified.", "value": {"detail": "LOGIN_USER_NOT_VERIFIED"}}}}}}, "204": {"description": "No Content"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/logout": {"post": {"tags": ["auth"], "summary": "Auth:Cookie.Logout", "operationId": "auth:cookie.logout", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "401": {"description": "Missing token or inactive user."}, "204": {"description": "No Content"}}, "security": [{"APIKeyCookie": []}]}}, "/auth/register": {"post": {"tags": ["auth"], "summary": "Register:Register", "operationId": "register:register", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserCreate"}}}, "required": true}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"REGISTER_USER_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "REGISTER_USER_ALREADY_EXISTS"}}, "REGISTER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "REGISTER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/forgot-password": {"post": {"tags": ["auth"], "summary": "Reset:Forgot Password", "operationId": "reset:forgot_password", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_reset_forgot_password_auth_forgot_password_post"}}}, "required": true}, "responses": {"202": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/reset-password": {"post": {"tags": ["auth"], "summary": "Reset:Reset Password", "operationId": "reset:reset_password", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_reset_reset_password_auth_reset_password_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"RESET_PASSWORD_BAD_TOKEN": {"summary": "Bad or expired token.", "value": {"detail": "RESET_PASSWORD_BAD_TOKEN"}}, "RESET_PASSWORD_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "RESET_PASSWORD_INVALID_PASSWORD", "reason": "Password should be at least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/request-verify-token": {"post": {"tags": ["auth"], "summary": "Verify:Request-Token", "operationId": "verify:request-token", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_verify_request_token_auth_request_verify_token_post"}}}, "required": true}, "responses": {"202": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/verify": {"post": {"tags": ["auth"], "summary": "Verify:Verify", "operationId": "verify:verify", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_verify_verify_auth_verify_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"VERIFY_USER_BAD_TOKEN": {"summary": "Bad token, not existing user ornot the e-mail currently set for the user.", "value": {"detail": "VERIFY_USER_BAD_TOKEN"}}, "VERIFY_USER_ALREADY_VERIFIED": {"summary": "The user is already verified.", "value": {"detail": "VERIFY_USER_ALREADY_VERIFIED"}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/research/auth/": {"get": {"tags": ["research"], "summary": "Auth", "operationId": "auth", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}, "security": [{"APIKeyCookie": []}]}}}, "components": {"schemas": {"Body_auth_cookie_login_auth_login_post": {"properties": {"grant_type": {"anyOf": [{"type": "string", "pattern": "password"}, {"type": "null"}], "title": "Grant Type"}, "username": {"type": "string", "title": "Username"}, "password": {"type": "string", "title": "Password"}, "scope": {"type": "string", "title": "Scope", "default": ""}, "client_id": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Client Id"}, "client_secret": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Client Secret"}}, "type": "object", "required": ["username", "password"], "title": "Body_auth_cookie_login_auth_login_post"}, "Body_reset_forgot_password_auth_forgot_password_post": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}}, "type": "object", "required": ["email"], "title": "Body_reset_forgot_password_auth_forgot_password_post"}, "Body_reset_reset_password_auth_reset_password_post": {"properties": {"token": {"type": "string", "title": "Token"}, "password": {"type": "string", "title": "Password"}}, "type": "object", "required": ["token", "password"], "title": "Body_reset_reset_password_auth_reset_password_post"}, "Body_upload_child_image_users_children_images__child_id__put": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_child_image_users_children_images__child_id__put"}, "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put"}, "Body_upload_milestone_image_admin_milestone_images__milestone_id__post": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_milestone_image_admin_milestone_images__milestone_id__post"}, "Body_verify_request_token_auth_request_verify_token_post": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}}, "type": "object", "required": ["email"], "title": "Body_verify_request_token_auth_request_verify_token_post"}, "Body_verify_verify_auth_verify_post": {"properties": {"token": {"type": "string", "title": "Token"}}, "type": "object", "required": ["token"], "title": "Body_verify_verify_auth_verify_post"}, "ChildAnswerPublic": {"properties": {"answer": {"type": "string", "title": "Answer"}, "question_id": {"type": "integer", "title": "Question Id"}, "additional_answer": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Additional Answer"}, "child_id": {"type": "integer", "title": "Child Id"}}, "type": "object", "required": ["answer", "question_id", "additional_answer", "child_id"], "title": "ChildAnswerPublic", "description": "Model for public child answer data which adds the child ID.\n\nParameters\n----------\nAnswerPublic : Basic Model for all Answers to questions in Mondey"}, "ChildCreate": {"properties": {"name": {"type": "string", "title": "Name", "default": ""}, "birth_year": {"type": "integer", "title": "Birth Year"}, "birth_month": {"type": "integer", "title": "Birth Month"}}, "type": "object", "required": ["birth_year", "birth_month"], "title": "ChildCreate"}, "ChildPublic": {"properties": {"name": {"type": "string", "title": "Name", "default": ""}, "birth_year": {"type": "integer", "title": "Birth Year"}, "birth_month": {"type": "integer", "title": "Birth Month"}, "id": {"type": "integer", "title": "Id"}, "has_image": {"type": "boolean", "title": "Has Image"}}, "type": "object", "required": ["birth_year", "birth_month", "id", "has_image"], "title": "ChildPublic"}, "ChildQuestionAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "options": {"type": "string", "title": "Options"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/QuestionText"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id", "order", "options"], "title": "ChildQuestionAdmin"}, "ChildQuestionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/QuestionTextPublic"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id"], "title": "ChildQuestionPublic"}, "ErrorModel": {"properties": {"detail": {"anyOf": [{"type": "string"}, {"additionalProperties": {"type": "string"}, "type": "object"}], "title": "Detail"}}, "type": "object", "required": ["detail"], "title": "ErrorModel"}, "HTTPValidationError": {"properties": {"detail": {"items": {"$ref": "#/components/schemas/ValidationError"}, "type": "array", "title": "Detail"}}, "type": "object", "title": "HTTPValidationError"}, "Language": {"properties": {"id": {"type": "string", "maxLength": 2, "title": "Id"}}, "type": "object", "required": ["id"], "title": "Language"}, "MilestoneAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "group_id": {"type": "integer", "title": "Group Id"}, "order": {"type": "integer", "title": "Order"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneText"}, "type": "object", "title": "Text", "default": {}}, "images": {"items": {"$ref": "#/components/schemas/MilestoneImage"}, "type": "array", "title": "Images", "default": []}}, "type": "object", "required": ["id", "group_id", "order"], "title": "MilestoneAdmin"}, "MilestoneAnswerPublic": {"properties": {"milestone_id": {"type": "integer", "title": "Milestone Id"}, "answer": {"type": "integer", "title": "Answer"}}, "type": "object", "required": ["milestone_id", "answer"], "title": "MilestoneAnswerPublic"}, "MilestoneAnswerSessionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "child_id": {"type": "integer", "title": "Child Id"}, "created_at": {"type": "string", "format": "date-time", "title": "Created At"}, "answers": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}, "type": "object", "title": "Answers"}}, "type": "object", "required": ["id", "child_id", "created_at", "answers"], "title": "MilestoneAnswerSessionPublic"}, "MilestoneGroupAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneGroupText"}, "type": "object", "title": "Text", "default": {}}, "milestones": {"items": {"$ref": "#/components/schemas/MilestoneAdmin"}, "type": "array", "title": "Milestones", "default": []}}, "type": "object", "required": ["id", "order"], "title": "MilestoneGroupAdmin"}, "MilestoneGroupPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneGroupTextPublic"}, "type": "object", "title": "Text", "default": {}}, "milestones": {"items": {"$ref": "#/components/schemas/MilestonePublic"}, "type": "array", "title": "Milestones", "default": []}}, "type": "object", "required": ["id"], "title": "MilestoneGroupPublic"}, "MilestoneGroupText": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "group_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Group Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}}, "type": "object", "title": "MilestoneGroupText"}, "MilestoneGroupTextPublic": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}}, "type": "object", "title": "MilestoneGroupTextPublic"}, "MilestoneImage": {"properties": {"id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id"}, "milestone_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Milestone Id"}, "filename": {"type": "string", "title": "Filename", "default": ""}, "approved": {"type": "boolean", "title": "Approved", "default": false}}, "type": "object", "title": "MilestoneImage"}, "MilestoneImagePublic": {"properties": {"filename": {"type": "string", "title": "Filename"}, "approved": {"type": "boolean", "title": "Approved"}}, "type": "object", "required": ["filename", "approved"], "title": "MilestoneImagePublic"}, "MilestonePublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneTextPublic"}, "type": "object", "title": "Text", "default": {}}, "images": {"items": {"$ref": "#/components/schemas/MilestoneImagePublic"}, "type": "array", "title": "Images", "default": []}}, "type": "object", "required": ["id"], "title": "MilestonePublic"}, "MilestoneText": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "obs": {"type": "string", "title": "Obs", "default": ""}, "help": {"type": "string", "title": "Help", "default": ""}, "milestone_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Milestone Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}}, "type": "object", "title": "MilestoneText"}, "MilestoneTextPublic": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "obs": {"type": "string", "title": "Obs", "default": ""}, "help": {"type": "string", "title": "Help", "default": ""}}, "type": "object", "title": "MilestoneTextPublic"}, "QuestionText": {"properties": {"question": {"type": "string", "title": "Question", "default": ""}, "options_json": {"type": "string", "title": "Options Json", "default": ""}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}, "options": {"type": "string", "title": "Options", "default": ""}}, "type": "object", "title": "QuestionText"}, "QuestionTextPublic": {"properties": {"question": {"type": "string", "title": "Question", "default": ""}, "options_json": {"type": "string", "title": "Options Json", "default": ""}}, "type": "object", "title": "QuestionTextPublic"}, "UserAnswerPublic": {"properties": {"answer": {"type": "string", "title": "Answer"}, "question_id": {"type": "integer", "title": "Question Id"}, "additional_answer": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Additional Answer"}}, "type": "object", "required": ["answer", "question_id", "additional_answer"], "title": "UserAnswerPublic", "description": "Model for public user answer data with the same content as AnswerPublic\n\nParameters\n----------\nAnswerPublic : Basic Model for all Answers to questions in Mondey"}, "UserCreate": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}, "password": {"type": "string", "title": "Password"}, "is_active": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Active", "default": true}, "is_superuser": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Superuser", "default": false}, "is_verified": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Verified", "default": false}, "is_researcher": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Researcher", "default": false}}, "type": "object", "required": ["email", "password"], "title": "UserCreate"}, "UserQuestionAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "options": {"type": "string", "title": "Options"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/QuestionText"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id", "order", "options"], "title": "UserQuestionAdmin"}, "UserQuestionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/QuestionTextPublic"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id"], "title": "UserQuestionPublic"}, "UserRead": {"properties": {"id": {"type": "integer", "title": "Id"}, "email": {"type": "string", "format": "email", "title": "Email"}, "is_active": {"type": "boolean", "title": "Is Active", "default": true}, "is_superuser": {"type": "boolean", "title": "Is Superuser", "default": false}, "is_verified": {"type": "boolean", "title": "Is Verified", "default": false}, "is_researcher": {"type": "boolean", "title": "Is Researcher"}}, "type": "object", "required": ["id", "email", "is_researcher"], "title": "UserRead"}, "UserUpdate": {"properties": {"password": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Password"}, "email": {"anyOf": [{"type": "string", "format": "email"}, {"type": "null"}], "title": "Email"}, "is_active": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Active"}, "is_superuser": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Superuser"}, "is_verified": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Verified"}, "is_researcher": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Researcher"}}, "type": "object", "title": "UserUpdate"}, "ValidationError": {"properties": {"loc": {"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, "type": "array", "title": "Location"}, "msg": {"type": "string", "title": "Message"}, "type": {"type": "string", "title": "Error Type"}}, "type": "object", "required": ["loc", "msg", "type"], "title": "ValidationError"}}, "securitySchemes": {"APIKeyCookie": {"type": "apiKey", "in": "cookie", "name": "fastapiusersauth"}}}} \ No newline at end of file +{ + "openapi": "3.1.0", + "info": { "title": "MONDEY API", "version": "0.1.0" }, + "paths": { + "/languages/": { + "get": { + "tags": ["milestones"], + "summary": "Get Languages", + "operationId": "get_languages", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { "type": "string" }, + "type": "array", + "title": "Response Get Languages Languages Get" + } + } + } + } + } + } + }, + "/milestones/": { + "get": { + "tags": ["milestones"], + "summary": "Get Milestones", + "operationId": "get_milestones", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { "$ref": "#/components/schemas/MilestonePublic" }, + "type": "array", + "title": "Response Get Milestones Milestones Get" + } + } + } + } + } + } + }, + "/milestones/{milestone_id}": { + "get": { + "tags": ["milestones"], + "summary": "Get Milestone", + "operationId": "get_milestone", + "parameters": [ + { + "name": "milestone_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Milestone Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/MilestonePublic" } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/milestone-groups/": { + "get": { + "tags": ["milestones"], + "summary": "Get Milestone Groups", + "operationId": "get_milestone_groups", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/MilestoneGroupPublic" + }, + "type": "array", + "title": "Response Get Milestone Groups Milestone Groups Get" + } + } + } + } + } + } + }, + "/milestone-groups/{milestone_group_id}": { + "get": { + "tags": ["milestones"], + "summary": "Get Milestone Group", + "operationId": "get_milestone_group", + "parameters": [ + { + "name": "milestone_group_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Milestone Group Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MilestoneGroupPublic" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/user-questions/": { + "get": { + "tags": ["questions"], + "summary": "Get User Questions", + "operationId": "get_user_questions", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/UserQuestionPublic" + }, + "type": "array", + "title": "Response Get User Questions User Questions Get" + } + } + } + } + } + } + }, + "/admin/languages/": { + "post": { + "tags": ["admin"], + "summary": "Create Language", + "operationId": "create_language", + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/Language" } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/Language" } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + } + }, + "/admin/languages/{language_id}": { + "delete": { + "tags": ["admin"], + "summary": "Delete Language", + "operationId": "delete_language", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "language_id", + "in": "path", + "required": true, + "schema": { "type": "string", "title": "Language Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/admin/i18n/{language_id}": { + "put": { + "tags": ["admin"], + "summary": "Update I18N", + "operationId": "update_i18n", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "language_id", + "in": "path", + "required": true, + "schema": { "type": "string", "title": "Language Id" } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { "type": "string" } + }, + "title": "I18Dict" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/admin/milestone-groups/": { + "get": { + "tags": ["admin"], + "summary": "Get Milestone Groups Admin", + "operationId": "get_milestone_groups_admin", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/MilestoneGroupAdmin" + }, + "type": "array", + "title": "Response Get Milestone Groups Admin Admin Milestone Groups Get" + } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + }, + "post": { + "tags": ["admin"], + "summary": "Create Milestone Group Admin", + "operationId": "create_milestone_group_admin", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/MilestoneGroupAdmin" } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + } + }, + "/admin/milestone-groups": { + "put": { + "tags": ["admin"], + "summary": "Update Milestone Group Admin", + "operationId": "update_milestone_group_admin", + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/MilestoneGroupAdmin" } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/MilestoneGroupAdmin" } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + } + }, + "/admin/milestone-groups/{milestone_group_id}": { + "delete": { + "tags": ["admin"], + "summary": "Delete Milestone Group Admin", + "operationId": "delete_milestone_group_admin", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "milestone_group_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Milestone Group Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/admin/milestone-group-images/{milestone_group_id}": { + "put": { + "tags": ["admin"], + "summary": "Upload Milestone Group Image", + "operationId": "upload_milestone_group_image", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "milestone_group_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Milestone Group Id" } + } + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/admin/milestones/{milestone_group_id}": { + "post": { + "tags": ["admin"], + "summary": "Create Milestone", + "operationId": "create_milestone", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "milestone_group_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Milestone Group Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/MilestoneAdmin" } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/admin/milestones/": { + "put": { + "tags": ["admin"], + "summary": "Update Milestone", + "operationId": "update_milestone", + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/MilestoneAdmin" } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/MilestoneAdmin" } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + } + }, + "/admin/milestones/{milestone_id}": { + "delete": { + "tags": ["admin"], + "summary": "Delete Milestone", + "operationId": "delete_milestone", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "milestone_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Milestone Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/admin/milestone-images/{milestone_id}": { + "post": { + "tags": ["admin"], + "summary": "Upload Milestone Image", + "operationId": "upload_milestone_image", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "milestone_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Milestone Id" } + } + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/Body_upload_milestone_image_admin_milestone_images__milestone_id__post" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/MilestoneImage" } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/admin/user-questions/": { + "get": { + "tags": ["admin"], + "summary": "Get User Questions Admin", + "operationId": "get_user_questions_admin", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { "$ref": "#/components/schemas/UserQuestionAdmin" }, + "type": "array", + "title": "Response Get User Questions Admin Admin User Questions Get" + } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + }, + "put": { + "tags": ["admin"], + "summary": "Update User Question", + "operationId": "update_user_question", + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserQuestionAdmin" } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserQuestionAdmin" } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + }, + "post": { + "tags": ["admin"], + "summary": "Create User Question", + "operationId": "create_user_question", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserQuestionAdmin" } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + } + }, + "/admin/user-questions/{user_question_id}": { + "delete": { + "tags": ["admin"], + "summary": "Delete User Question", + "operationId": "delete_user_question", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "user_question_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "User Question Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/users/me": { + "get": { + "tags": ["users"], + "summary": "Users:Current User", + "operationId": "users:current_user", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserRead" } + } + } + }, + "401": { "description": "Missing token or inactive user." } + }, + "security": [{ "APIKeyCookie": [] }] + }, + "patch": { + "tags": ["users"], + "summary": "Users:Patch Current User", + "operationId": "users:patch_current_user", + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserUpdate" } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserRead" } + } + } + }, + "401": { "description": "Missing token or inactive user." }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorModel" }, + "examples": { + "UPDATE_USER_EMAIL_ALREADY_EXISTS": { + "summary": "A user with this email already exists.", + "value": { "detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS" } + }, + "UPDATE_USER_INVALID_PASSWORD": { + "summary": "Password validation failed.", + "value": { + "detail": { + "code": "UPDATE_USER_INVALID_PASSWORD", + "reason": "Password should beat least 3 characters" + } + } + } + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + } + }, + "/users/{id}": { + "get": { + "tags": ["users"], + "summary": "Users:User", + "operationId": "users:user", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { "type": "string", "title": "Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserRead" } + } + } + }, + "401": { "description": "Missing token or inactive user." }, + "403": { "description": "Not a superuser." }, + "404": { "description": "The user does not exist." }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + }, + "patch": { + "tags": ["users"], + "summary": "Users:Patch User", + "operationId": "users:patch_user", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { "type": "string", "title": "Id" } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserUpdate" } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserRead" } + } + } + }, + "401": { "description": "Missing token or inactive user." }, + "403": { "description": "Not a superuser." }, + "404": { "description": "The user does not exist." }, + "400": { + "content": { + "application/json": { + "examples": { + "UPDATE_USER_EMAIL_ALREADY_EXISTS": { + "summary": "A user with this email already exists.", + "value": { "detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS" } + }, + "UPDATE_USER_INVALID_PASSWORD": { + "summary": "Password validation failed.", + "value": { + "detail": { + "code": "UPDATE_USER_INVALID_PASSWORD", + "reason": "Password should beat least 3 characters" + } + } + } + }, + "schema": { "$ref": "#/components/schemas/ErrorModel" } + } + }, + "description": "Bad Request" + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + }, + "delete": { + "tags": ["users"], + "summary": "Users:Delete User", + "operationId": "users:delete_user", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { "type": "string", "title": "Id" } + } + ], + "responses": { + "204": { "description": "Successful Response" }, + "401": { "description": "Missing token or inactive user." }, + "403": { "description": "Not a superuser." }, + "404": { "description": "The user does not exist." }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/users/children/": { + "get": { + "tags": ["users"], + "summary": "Get Children", + "operationId": "get_children", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { "$ref": "#/components/schemas/ChildPublic" }, + "type": "array", + "title": "Response Get Children Users Children Get" + } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + }, + "put": { + "tags": ["users"], + "summary": "Update Child", + "operationId": "update_child", + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ChildPublic" } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ChildPublic" } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + }, + "post": { + "tags": ["users"], + "summary": "Create Child", + "operationId": "create_child", + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ChildCreate" } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ChildPublic" } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + } + }, + "/users/children/{child_id}": { + "delete": { + "tags": ["users"], + "summary": "Delete Child", + "operationId": "delete_child", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "child_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Child Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/users/children-images/{child_id}": { + "get": { + "tags": ["users"], + "summary": "Get Child Image", + "operationId": "get_child_image", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "child_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Child Id" } + } + ], + "responses": { + "200": { "description": "Successful Response" }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + }, + "put": { + "tags": ["users"], + "summary": "Upload Child Image", + "operationId": "upload_child_image", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "child_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Child Id" } + } + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/Body_upload_child_image_users_children_images__child_id__put" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/users/milestone-answers/{child_id}": { + "get": { + "tags": ["users"], + "summary": "Get Current Milestone Answer Session", + "operationId": "get_current_milestone_answer_session", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "child_id", + "in": "path", + "required": true, + "schema": { "type": "integer", "title": "Child Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MilestoneAnswerSessionPublic" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/users/milestone-answers/{milestone_answer_session_id}": { + "put": { + "tags": ["users"], + "summary": "Update Milestone Answer", + "operationId": "update_milestone_answer", + "security": [{ "APIKeyCookie": [] }], + "parameters": [ + { + "name": "milestone_answer_session_id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "title": "Milestone Answer Session Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/MilestoneAnswerPublic" } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MilestoneAnswerPublic" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/users/user-answers/": { + "get": { + "tags": ["users"], + "summary": "Get Current User Answers", + "operationId": "get_current_user_answers", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { "$ref": "#/components/schemas/UserAnswerPublic" }, + "type": "array", + "title": "Response Get Current User Answers Users User Answers Get" + } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + }, + "put": { + "tags": ["users"], + "summary": "Update Current User Answers", + "operationId": "update_current_user_answers", + "requestBody": { + "content": { + "application/json": { + "schema": { + "items": { "$ref": "#/components/schemas/UserAnswerPublic" }, + "type": "array", + "title": "New Answers" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { "$ref": "#/components/schemas/UserAnswerPublic" }, + "type": "array", + "title": "Response Update Current User Answers Users User Answers Put" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "security": [{ "APIKeyCookie": [] }] + } + }, + "/auth/login": { + "post": { + "tags": ["auth"], + "summary": "Auth:Cookie.Login", + "operationId": "auth:cookie.login", + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/Body_auth_cookie_login_auth_login_post" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorModel" }, + "examples": { + "LOGIN_BAD_CREDENTIALS": { + "summary": "Bad credentials or the user is inactive.", + "value": { "detail": "LOGIN_BAD_CREDENTIALS" } + }, + "LOGIN_USER_NOT_VERIFIED": { + "summary": "The user is not verified.", + "value": { "detail": "LOGIN_USER_NOT_VERIFIED" } + } + } + } + } + }, + "204": { "description": "No Content" }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/auth/logout": { + "post": { + "tags": ["auth"], + "summary": "Auth:Cookie.Logout", + "operationId": "auth:cookie.logout", + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "401": { "description": "Missing token or inactive user." }, + "204": { "description": "No Content" } + }, + "security": [{ "APIKeyCookie": [] }] + } + }, + "/auth/register": { + "post": { + "tags": ["auth"], + "summary": "Register:Register", + "operationId": "register:register", + "requestBody": { + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserCreate" } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserRead" } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorModel" }, + "examples": { + "REGISTER_USER_ALREADY_EXISTS": { + "summary": "A user with this email already exists.", + "value": { "detail": "REGISTER_USER_ALREADY_EXISTS" } + }, + "REGISTER_INVALID_PASSWORD": { + "summary": "Password validation failed.", + "value": { + "detail": { + "code": "REGISTER_INVALID_PASSWORD", + "reason": "Password should beat least 3 characters" + } + } + } + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/auth/forgot-password": { + "post": { + "tags": ["auth"], + "summary": "Reset:Forgot Password", + "operationId": "reset:forgot_password", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Body_reset_forgot_password_auth_forgot_password_post" + } + } + }, + "required": true + }, + "responses": { + "202": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/auth/reset-password": { + "post": { + "tags": ["auth"], + "summary": "Reset:Reset Password", + "operationId": "reset:reset_password", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Body_reset_reset_password_auth_reset_password_post" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorModel" }, + "examples": { + "RESET_PASSWORD_BAD_TOKEN": { + "summary": "Bad or expired token.", + "value": { "detail": "RESET_PASSWORD_BAD_TOKEN" } + }, + "RESET_PASSWORD_INVALID_PASSWORD": { + "summary": "Password validation failed.", + "value": { + "detail": { + "code": "RESET_PASSWORD_INVALID_PASSWORD", + "reason": "Password should be at least 3 characters" + } + } + } + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/auth/request-verify-token": { + "post": { + "tags": ["auth"], + "summary": "Verify:Request-Token", + "operationId": "verify:request-token", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Body_verify_request_token_auth_request_verify_token_post" + } + } + }, + "required": true + }, + "responses": { + "202": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/auth/verify": { + "post": { + "tags": ["auth"], + "summary": "Verify:Verify", + "operationId": "verify:verify", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Body_verify_verify_auth_verify_post" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserRead" } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorModel" }, + "examples": { + "VERIFY_USER_BAD_TOKEN": { + "summary": "Bad token, not existing user ornot the e-mail currently set for the user.", + "value": { "detail": "VERIFY_USER_BAD_TOKEN" } + }, + "VERIFY_USER_ALREADY_VERIFIED": { + "summary": "The user is already verified.", + "value": { "detail": "VERIFY_USER_ALREADY_VERIFIED" } + } + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, + "/research/auth/": { + "get": { + "tags": ["research"], + "summary": "Auth", + "operationId": "auth", + "responses": { + "200": { + "description": "Successful Response", + "content": { "application/json": { "schema": {} } } + } + }, + "security": [{ "APIKeyCookie": [] }] + } + } + }, + "components": { + "schemas": { + "Body_auth_cookie_login_auth_login_post": { + "properties": { + "grant_type": { + "anyOf": [ + { "type": "string", "pattern": "password" }, + { "type": "null" } + ], + "title": "Grant Type" + }, + "username": { "type": "string", "title": "Username" }, + "password": { "type": "string", "title": "Password" }, + "scope": { "type": "string", "title": "Scope", "default": "" }, + "client_id": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Client Id" + }, + "client_secret": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Client Secret" + } + }, + "type": "object", + "required": ["username", "password"], + "title": "Body_auth_cookie_login_auth_login_post" + }, + "Body_reset_forgot_password_auth_forgot_password_post": { + "properties": { + "email": { "type": "string", "format": "email", "title": "Email" } + }, + "type": "object", + "required": ["email"], + "title": "Body_reset_forgot_password_auth_forgot_password_post" + }, + "Body_reset_reset_password_auth_reset_password_post": { + "properties": { + "token": { "type": "string", "title": "Token" }, + "password": { "type": "string", "title": "Password" } + }, + "type": "object", + "required": ["token", "password"], + "title": "Body_reset_reset_password_auth_reset_password_post" + }, + "Body_upload_child_image_users_children_images__child_id__put": { + "properties": { + "file": { "type": "string", "format": "binary", "title": "File" } + }, + "type": "object", + "required": ["file"], + "title": "Body_upload_child_image_users_children_images__child_id__put" + }, + "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put": { + "properties": { + "file": { "type": "string", "format": "binary", "title": "File" } + }, + "type": "object", + "required": ["file"], + "title": "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put" + }, + "Body_upload_milestone_image_admin_milestone_images__milestone_id__post": { + "properties": { + "file": { "type": "string", "format": "binary", "title": "File" } + }, + "type": "object", + "required": ["file"], + "title": "Body_upload_milestone_image_admin_milestone_images__milestone_id__post" + }, + "Body_verify_request_token_auth_request_verify_token_post": { + "properties": { + "email": { "type": "string", "format": "email", "title": "Email" } + }, + "type": "object", + "required": ["email"], + "title": "Body_verify_request_token_auth_request_verify_token_post" + }, + "Body_verify_verify_auth_verify_post": { + "properties": { "token": { "type": "string", "title": "Token" } }, + "type": "object", + "required": ["token"], + "title": "Body_verify_verify_auth_verify_post" + }, + "ChildCreate": { + "properties": { + "name": { "type": "string", "title": "Name", "default": "" }, + "birth_year": { "type": "integer", "title": "Birth Year" }, + "birth_month": { "type": "integer", "title": "Birth Month" } + }, + "type": "object", + "required": ["birth_year", "birth_month"], + "title": "ChildCreate" + }, + "ChildPublic": { + "properties": { + "name": { "type": "string", "title": "Name", "default": "" }, + "birth_year": { "type": "integer", "title": "Birth Year" }, + "birth_month": { "type": "integer", "title": "Birth Month" }, + "id": { "type": "integer", "title": "Id" }, + "has_image": { "type": "boolean", "title": "Has Image" } + }, + "type": "object", + "required": ["birth_year", "birth_month", "id", "has_image"], + "title": "ChildPublic" + }, + "ErrorModel": { + "properties": { + "detail": { + "anyOf": [ + { "type": "string" }, + { "additionalProperties": { "type": "string" }, "type": "object" } + ], + "title": "Detail" + } + }, + "type": "object", + "required": ["detail"], + "title": "ErrorModel" + }, + "HTTPValidationError": { + "properties": { + "detail": { + "items": { "$ref": "#/components/schemas/ValidationError" }, + "type": "array", + "title": "Detail" + } + }, + "type": "object", + "title": "HTTPValidationError" + }, + "Language": { + "properties": { + "id": { "type": "string", "maxLength": 2, "title": "Id" } + }, + "type": "object", + "required": ["id"], + "title": "Language" + }, + "MilestoneAdmin": { + "properties": { + "id": { "type": "integer", "title": "Id" }, + "group_id": { "type": "integer", "title": "Group Id" }, + "order": { "type": "integer", "title": "Order" }, + "text": { + "additionalProperties": { + "$ref": "#/components/schemas/MilestoneText" + }, + "type": "object", + "title": "Text", + "default": {} + }, + "images": { + "items": { "$ref": "#/components/schemas/MilestoneImage" }, + "type": "array", + "title": "Images", + "default": [] + } + }, + "type": "object", + "required": ["id", "group_id", "order"], + "title": "MilestoneAdmin" + }, + "MilestoneAnswerPublic": { + "properties": { + "milestone_id": { "type": "integer", "title": "Milestone Id" }, + "answer": { "type": "integer", "title": "Answer" } + }, + "type": "object", + "required": ["milestone_id", "answer"], + "title": "MilestoneAnswerPublic" + }, + "MilestoneAnswerSessionPublic": { + "properties": { + "id": { "type": "integer", "title": "Id" }, + "child_id": { "type": "integer", "title": "Child Id" }, + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At" + }, + "answers": { + "additionalProperties": { + "$ref": "#/components/schemas/MilestoneAnswerPublic" + }, + "type": "object", + "title": "Answers" + } + }, + "type": "object", + "required": ["id", "child_id", "created_at", "answers"], + "title": "MilestoneAnswerSessionPublic" + }, + "MilestoneGroupAdmin": { + "properties": { + "id": { "type": "integer", "title": "Id" }, + "order": { "type": "integer", "title": "Order" }, + "text": { + "additionalProperties": { + "$ref": "#/components/schemas/MilestoneGroupText" + }, + "type": "object", + "title": "Text", + "default": {} + }, + "milestones": { + "items": { "$ref": "#/components/schemas/MilestoneAdmin" }, + "type": "array", + "title": "Milestones", + "default": [] + } + }, + "type": "object", + "required": ["id", "order"], + "title": "MilestoneGroupAdmin" + }, + "MilestoneGroupPublic": { + "properties": { + "id": { "type": "integer", "title": "Id" }, + "text": { + "additionalProperties": { + "$ref": "#/components/schemas/MilestoneGroupTextPublic" + }, + "type": "object", + "title": "Text", + "default": {} + }, + "milestones": { + "items": { "$ref": "#/components/schemas/MilestonePublic" }, + "type": "array", + "title": "Milestones", + "default": [] + } + }, + "type": "object", + "required": ["id"], + "title": "MilestoneGroupPublic" + }, + "MilestoneGroupText": { + "properties": { + "title": { "type": "string", "title": "Title", "default": "" }, + "desc": { "type": "string", "title": "Desc", "default": "" }, + "group_id": { + "anyOf": [{ "type": "integer" }, { "type": "null" }], + "title": "Group Id" + }, + "lang_id": { + "anyOf": [{ "type": "string", "maxLength": 2 }, { "type": "null" }], + "title": "Lang Id" + } + }, + "type": "object", + "title": "MilestoneGroupText" + }, + "MilestoneGroupTextPublic": { + "properties": { + "title": { "type": "string", "title": "Title", "default": "" }, + "desc": { "type": "string", "title": "Desc", "default": "" } + }, + "type": "object", + "title": "MilestoneGroupTextPublic" + }, + "MilestoneImage": { + "properties": { + "id": { + "anyOf": [{ "type": "integer" }, { "type": "null" }], + "title": "Id" + }, + "milestone_id": { + "anyOf": [{ "type": "integer" }, { "type": "null" }], + "title": "Milestone Id" + }, + "filename": { "type": "string", "title": "Filename", "default": "" }, + "approved": { + "type": "boolean", + "title": "Approved", + "default": false + } + }, + "type": "object", + "title": "MilestoneImage" + }, + "MilestoneImagePublic": { + "properties": { + "filename": { "type": "string", "title": "Filename" }, + "approved": { "type": "boolean", "title": "Approved" } + }, + "type": "object", + "required": ["filename", "approved"], + "title": "MilestoneImagePublic" + }, + "MilestonePublic": { + "properties": { + "id": { "type": "integer", "title": "Id" }, + "text": { + "additionalProperties": { + "$ref": "#/components/schemas/MilestoneTextPublic" + }, + "type": "object", + "title": "Text", + "default": {} + }, + "images": { + "items": { "$ref": "#/components/schemas/MilestoneImagePublic" }, + "type": "array", + "title": "Images", + "default": [] + } + }, + "type": "object", + "required": ["id"], + "title": "MilestonePublic" + }, + "MilestoneText": { + "properties": { + "title": { "type": "string", "title": "Title", "default": "" }, + "desc": { "type": "string", "title": "Desc", "default": "" }, + "obs": { "type": "string", "title": "Obs", "default": "" }, + "help": { "type": "string", "title": "Help", "default": "" }, + "milestone_id": { + "anyOf": [{ "type": "integer" }, { "type": "null" }], + "title": "Milestone Id" + }, + "lang_id": { + "anyOf": [{ "type": "string", "maxLength": 2 }, { "type": "null" }], + "title": "Lang Id" + } + }, + "type": "object", + "title": "MilestoneText" + }, + "MilestoneTextPublic": { + "properties": { + "title": { "type": "string", "title": "Title", "default": "" }, + "desc": { "type": "string", "title": "Desc", "default": "" }, + "obs": { "type": "string", "title": "Obs", "default": "" }, + "help": { "type": "string", "title": "Help", "default": "" } + }, + "type": "object", + "title": "MilestoneTextPublic" + }, + "UserAnswerPublic": { + "properties": { + "answer": { "type": "string", "title": "Answer" }, + "question_id": { "type": "integer", "title": "Question Id" }, + "additional_answer": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Additional Answer" + } + }, + "type": "object", + "required": ["answer", "question_id", "additional_answer"], + "title": "UserAnswerPublic", + "description": "External data model for UserAnswers\n\nParameters\n----------\nSQLModel : Pydantic model basic sqlmodel pydantic type" + }, + "UserCreate": { + "properties": { + "email": { "type": "string", "format": "email", "title": "Email" }, + "password": { "type": "string", "title": "Password" }, + "is_active": { + "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "title": "Is Active", + "default": true + }, + "is_superuser": { + "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "title": "Is Superuser", + "default": false + }, + "is_verified": { + "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "title": "Is Verified", + "default": false + }, + "is_researcher": { + "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "title": "Is Researcher", + "default": false + } + }, + "type": "object", + "required": ["email", "password"], + "title": "UserCreate" + }, + "UserQuestionAdmin": { + "properties": { + "id": { "type": "integer", "title": "Id" }, + "order": { "type": "integer", "title": "Order" }, + "component": { + "type": "string", + "title": "Component", + "default": "select" + }, + "type": { "type": "string", "title": "Type", "default": "text" }, + "options": { "type": "string", "title": "Options" }, + "text": { + "additionalProperties": { + "$ref": "#/components/schemas/UserQuestionText" + }, + "type": "object", + "title": "Text", + "default": {} + }, + "additional_option": { + "type": "string", + "title": "Additional Option", + "default": "" + } + }, + "type": "object", + "required": ["id", "order", "options"], + "title": "UserQuestionAdmin" + }, + "UserQuestionPublic": { + "properties": { + "id": { "type": "integer", "title": "Id" }, + "component": { + "type": "string", + "title": "Component", + "default": "select" + }, + "type": { "type": "string", "title": "Type", "default": "text" }, + "text": { + "additionalProperties": { + "$ref": "#/components/schemas/UserQuestionTextPublic" + }, + "type": "object", + "title": "Text", + "default": {} + }, + "additional_option": { + "type": "string", + "title": "Additional Option", + "default": "" + } + }, + "type": "object", + "required": ["id"], + "title": "UserQuestionPublic" + }, + "UserQuestionText": { + "properties": { + "question": { "type": "string", "title": "Question", "default": "" }, + "options_json": { + "type": "string", + "title": "Options Json", + "default": "" + }, + "user_question_id": { + "anyOf": [{ "type": "integer" }, { "type": "null" }], + "title": "User Question Id" + }, + "lang_id": { + "anyOf": [{ "type": "string", "maxLength": 2 }, { "type": "null" }], + "title": "Lang Id" + }, + "options": { "type": "string", "title": "Options", "default": "" } + }, + "type": "object", + "title": "UserQuestionText" + }, + "UserQuestionTextPublic": { + "properties": { + "question": { "type": "string", "title": "Question", "default": "" }, + "options_json": { + "type": "string", + "title": "Options Json", + "default": "" + } + }, + "type": "object", + "title": "UserQuestionTextPublic" + }, + "UserRead": { + "properties": { + "id": { "type": "integer", "title": "Id" }, + "email": { "type": "string", "format": "email", "title": "Email" }, + "is_active": { + "type": "boolean", + "title": "Is Active", + "default": true + }, + "is_superuser": { + "type": "boolean", + "title": "Is Superuser", + "default": false + }, + "is_verified": { + "type": "boolean", + "title": "Is Verified", + "default": false + }, + "is_researcher": { "type": "boolean", "title": "Is Researcher" } + }, + "type": "object", + "required": ["id", "email", "is_researcher"], + "title": "UserRead" + }, + "UserUpdate": { + "properties": { + "password": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Password" + }, + "email": { + "anyOf": [ + { "type": "string", "format": "email" }, + { "type": "null" } + ], + "title": "Email" + }, + "is_active": { + "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "title": "Is Active" + }, + "is_superuser": { + "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "title": "Is Superuser" + }, + "is_verified": { + "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "title": "Is Verified" + }, + "is_researcher": { + "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "title": "Is Researcher" + } + }, + "type": "object", + "title": "UserUpdate" + }, + "ValidationError": { + "properties": { + "loc": { + "items": { "anyOf": [{ "type": "string" }, { "type": "integer" }] }, + "type": "array", + "title": "Location" + }, + "msg": { "type": "string", "title": "Message" }, + "type": { "type": "string", "title": "Error Type" } + }, + "type": "object", + "required": ["loc", "msg", "type"], + "title": "ValidationError" + } + }, + "securitySchemes": { + "APIKeyCookie": { + "type": "apiKey", + "in": "cookie", + "name": "fastapiusersauth" + } + } + } +} From 36edc3564b6bf2b0854efe509a23a63ea8061546 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:35:40 +0000 Subject: [PATCH 15/87] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mondey_backend/src/mondey_backend/models/questions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mondey_backend/src/mondey_backend/models/questions.py b/mondey_backend/src/mondey_backend/models/questions.py index fc63e0c4..e4f23ee1 100644 --- a/mondey_backend/src/mondey_backend/models/questions.py +++ b/mondey_backend/src/mondey_backend/models/questions.py @@ -104,7 +104,6 @@ class ChildQuestionAdmin(SQLModel): additional_option: str = "" - # Answers to user questions. Internal model and 'public' model exposed to the forntend app From 1c9ded15e38500fd4290e7b627dc8971fbab1f5a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 29 Oct 2024 15:36:15 +0000 Subject: [PATCH 16/87] update openapi.json & openapi-ts client, run pnpm format --- frontend/src/lib/client/schemas.gen.ts | 172 ++ frontend/src/lib/client/services.gen.ts | 129 ++ frontend/src/lib/client/types.gen.ts | 90 + mondey_backend/openapi.json | 2047 +---------------------- 4 files changed, 392 insertions(+), 2046 deletions(-) diff --git a/frontend/src/lib/client/schemas.gen.ts b/frontend/src/lib/client/schemas.gen.ts index 202fdef9..da286bd4 100644 --- a/frontend/src/lib/client/schemas.gen.ts +++ b/frontend/src/lib/client/schemas.gen.ts @@ -149,6 +149,38 @@ export const Body_verify_verify_auth_verify_postSchema = { title: 'Body_verify_verify_auth_verify_post' } as const; +export const ChildAnswerPublicSchema = { + properties: { + answer: { + type: 'string', + title: 'Answer' + }, + question_id: { + type: 'integer', + title: 'Question Id' + }, + additional_answer: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Additional Answer' + } + }, + type: 'object', + required: ['answer', 'question_id', 'additional_answer'], + title: 'ChildAnswerPublic', + description: `External data model for UserAnswers + +Parameters +---------- +SQLModel : Pydantic model basic sqlmodel pydantic type` +} as const; + export const ChildCreateSchema = { properties: { name: { @@ -199,6 +231,146 @@ export const ChildPublicSchema = { title: 'ChildPublic' } as const; +export const ChildQuestionAdminSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + order: { + type: 'integer', + title: 'Order' + }, + component: { + type: 'string', + title: 'Component', + default: 'select' + }, + type: { + type: 'string', + title: 'Type', + default: 'text' + }, + options: { + type: 'string', + title: 'Options' + }, + text: { + additionalProperties: { + $ref: '#/components/schemas/ChildQuestionText' + }, + type: 'object', + title: 'Text', + default: {} + }, + additional_option: { + type: 'string', + title: 'Additional Option', + default: '' + } + }, + type: 'object', + required: ['id', 'order', 'options'], + title: 'ChildQuestionAdmin' +} as const; + +export const ChildQuestionPublicSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + component: { + type: 'string', + title: 'Component', + default: 'select' + }, + type: { + type: 'string', + title: 'Type', + default: 'text' + }, + text: { + additionalProperties: { + $ref: '#/components/schemas/ChildQuestionTextPublic' + }, + type: 'object', + title: 'Text', + default: {} + }, + additional_option: { + type: 'string', + title: 'Additional Option', + default: '' + } + }, + type: 'object', + required: ['id'], + title: 'ChildQuestionPublic' +} as const; + +export const ChildQuestionTextSchema = { + properties: { + question: { + type: 'string', + title: 'Question', + default: '' + }, + options_json: { + type: 'string', + title: 'Options Json', + default: '' + }, + child_question_id: { + anyOf: [ + { + type: 'integer' + }, + { + type: 'null' + } + ], + title: 'Child Question Id' + }, + lang_id: { + anyOf: [ + { + type: 'string', + maxLength: 2 + }, + { + type: 'null' + } + ], + title: 'Lang Id' + }, + options: { + type: 'string', + title: 'Options', + default: '' + } + }, + type: 'object', + title: 'ChildQuestionText' +} as const; + +export const ChildQuestionTextPublicSchema = { + properties: { + question: { + type: 'string', + title: 'Question', + default: '' + }, + options_json: { + type: 'string', + title: 'Options Json', + default: '' + } + }, + type: 'object', + title: 'ChildQuestionTextPublic' +} as const; + export const ErrorModelSchema = { properties: { detail: { diff --git a/frontend/src/lib/client/services.gen.ts b/frontend/src/lib/client/services.gen.ts index d7311ff4..d4b9e9c9 100644 --- a/frontend/src/lib/client/services.gen.ts +++ b/frontend/src/lib/client/services.gen.ts @@ -22,6 +22,8 @@ import type { GetMilestoneGroupResponse, GetUserQuestionsError, GetUserQuestionsResponse, + GetChildQuestionsError, + GetChildQuestionsResponse, CreateLanguageData, CreateLanguageError, CreateLanguageResponse, @@ -66,6 +68,16 @@ import type { DeleteUserQuestionData, DeleteUserQuestionError, DeleteUserQuestionResponse, + GetChildQuestionsAdminError, + GetChildQuestionsAdminResponse, + UpdateChildQuestionData, + UpdateChildQuestionError, + UpdateChildQuestionResponse, + CreateChildQuestionError, + CreateChildQuestionResponse, + DeleteChildQuestionData, + DeleteChildQuestionError, + DeleteChildQuestionResponse, UsersCurrentUserError, UsersCurrentUserResponse, UsersPatchCurrentUserData, @@ -108,6 +120,11 @@ import type { UpdateCurrentUserAnswersData, UpdateCurrentUserAnswersError, UpdateCurrentUserAnswersResponse, + GetCurrentChildrenAnswersError, + GetCurrentChildrenAnswersResponse, + UpdateCurrentChildrenAnswersData, + UpdateCurrentChildrenAnswersError, + UpdateCurrentChildrenAnswersResponse, AuthCookieLoginData, AuthCookieLoginError, AuthCookieLoginResponse, @@ -218,6 +235,22 @@ export const getUserQuestions = ( }); }; +/** + * Get Child Questions + */ +export const getChildQuestions = ( + options?: Options +) => { + return (options?.client ?? client).get< + GetChildQuestionsResponse, + GetChildQuestionsError, + ThrowOnError + >({ + ...options, + url: '/child-questions/' + }); +}; + /** * Create Language */ @@ -480,6 +513,70 @@ export const deleteUserQuestion = ( }); }; +/** + * Get Child Questions Admin + */ +export const getChildQuestionsAdmin = ( + options?: Options +) => { + return (options?.client ?? client).get< + GetChildQuestionsAdminResponse, + GetChildQuestionsAdminError, + ThrowOnError + >({ + ...options, + url: '/admin/child-questions/' + }); +}; + +/** + * Update Child Question + */ +export const updateChildQuestion = ( + options: Options +) => { + return (options?.client ?? client).put< + UpdateChildQuestionResponse, + UpdateChildQuestionError, + ThrowOnError + >({ + ...options, + url: '/admin/child-questions/' + }); +}; + +/** + * Create Child Question + */ +export const createChildQuestion = ( + options?: Options +) => { + return (options?.client ?? client).post< + CreateChildQuestionResponse, + CreateChildQuestionError, + ThrowOnError + >({ + ...options, + url: '/admin/child-questions/' + }); +}; + +/** + * Delete Child Question + */ +export const deleteChildQuestion = ( + options: Options +) => { + return (options?.client ?? client).delete< + DeleteChildQuestionResponse, + DeleteChildQuestionError, + ThrowOnError + >({ + ...options, + url: '/admin/child-questions/{child_question_id}' + }); +}; + /** * Users:Current User */ @@ -701,6 +798,38 @@ export const updateCurrentUserAnswers = ( }); }; +/** + * Get Current Children Answers + */ +export const getCurrentChildrenAnswers = ( + options?: Options +) => { + return (options?.client ?? client).get< + GetCurrentChildrenAnswersResponse, + GetCurrentChildrenAnswersError, + ThrowOnError + >({ + ...options, + url: '/users/children-answers/' + }); +}; + +/** + * Update Current Children Answers + */ +export const updateCurrentChildrenAnswers = ( + options: Options +) => { + return (options?.client ?? client).put< + UpdateCurrentChildrenAnswersResponse, + UpdateCurrentChildrenAnswersError, + ThrowOnError + >({ + ...options, + url: '/users/children-answers/' + }); +}; + /** * Auth:Cookie.Login */ diff --git a/frontend/src/lib/client/types.gen.ts b/frontend/src/lib/client/types.gen.ts index 8126bb60..da43bcfa 100644 --- a/frontend/src/lib/client/types.gen.ts +++ b/frontend/src/lib/client/types.gen.ts @@ -39,6 +39,19 @@ export type Body_verify_verify_auth_verify_post = { token: string; }; +/** + * External data model for UserAnswers + * + * Parameters + * ---------- + * SQLModel : Pydantic model basic sqlmodel pydantic type + */ +export type ChildAnswerPublic = { + answer: string; + question_id: number; + additional_answer: string | null; +}; + export type ChildCreate = { name?: string; birth_year: number; @@ -53,6 +66,41 @@ export type ChildPublic = { has_image: boolean; }; +export type ChildQuestionAdmin = { + id: number; + order: number; + component?: string; + type?: string; + options: string; + text?: { + [key: string]: ChildQuestionText; + }; + additional_option?: string; +}; + +export type ChildQuestionPublic = { + id: number; + component?: string; + type?: string; + text?: { + [key: string]: ChildQuestionTextPublic; + }; + additional_option?: string; +}; + +export type ChildQuestionText = { + question?: string; + options_json?: string; + child_question_id?: number | null; + lang_id?: string | null; + options?: string; +}; + +export type ChildQuestionTextPublic = { + question?: string; + options_json?: string; +}; + export type ErrorModel = { detail: | string @@ -275,6 +323,10 @@ export type GetUserQuestionsResponse = Array; export type GetUserQuestionsError = unknown; +export type GetChildQuestionsResponse = Array; + +export type GetChildQuestionsError = unknown; + export type CreateLanguageData = { body: Language; }; @@ -410,6 +462,32 @@ export type DeleteUserQuestionResponse = unknown; export type DeleteUserQuestionError = HTTPValidationError; +export type GetChildQuestionsAdminResponse = Array; + +export type GetChildQuestionsAdminError = unknown; + +export type UpdateChildQuestionData = { + body: ChildQuestionAdmin; +}; + +export type UpdateChildQuestionResponse = ChildQuestionAdmin; + +export type UpdateChildQuestionError = HTTPValidationError; + +export type CreateChildQuestionResponse = ChildQuestionAdmin; + +export type CreateChildQuestionError = unknown; + +export type DeleteChildQuestionData = { + path: { + child_question_id: number; + }; +}; + +export type DeleteChildQuestionResponse = unknown; + +export type DeleteChildQuestionError = HTTPValidationError; + export type UsersCurrentUserResponse = UserRead; export type UsersCurrentUserError = unknown; @@ -537,6 +615,18 @@ export type UpdateCurrentUserAnswersResponse = Array; export type UpdateCurrentUserAnswersError = HTTPValidationError; +export type GetCurrentChildrenAnswersResponse = Array; + +export type GetCurrentChildrenAnswersError = unknown; + +export type UpdateCurrentChildrenAnswersData = { + body: Array; +}; + +export type UpdateCurrentChildrenAnswersResponse = Array; + +export type UpdateCurrentChildrenAnswersError = HTTPValidationError; + export type AuthCookieLoginData = { body: Body_auth_cookie_login_auth_login_post; }; diff --git a/mondey_backend/openapi.json b/mondey_backend/openapi.json index db0bc180..d7fef3f2 100644 --- a/mondey_backend/openapi.json +++ b/mondey_backend/openapi.json @@ -1,2046 +1 @@ -{ - "openapi": "3.1.0", - "info": { "title": "MONDEY API", "version": "0.1.0" }, - "paths": { - "/languages/": { - "get": { - "tags": ["milestones"], - "summary": "Get Languages", - "operationId": "get_languages", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "items": { "type": "string" }, - "type": "array", - "title": "Response Get Languages Languages Get" - } - } - } - } - } - } - }, - "/milestones/": { - "get": { - "tags": ["milestones"], - "summary": "Get Milestones", - "operationId": "get_milestones", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "items": { "$ref": "#/components/schemas/MilestonePublic" }, - "type": "array", - "title": "Response Get Milestones Milestones Get" - } - } - } - } - } - } - }, - "/milestones/{milestone_id}": { - "get": { - "tags": ["milestones"], - "summary": "Get Milestone", - "operationId": "get_milestone", - "parameters": [ - { - "name": "milestone_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Milestone Id" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/MilestonePublic" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/milestone-groups/": { - "get": { - "tags": ["milestones"], - "summary": "Get Milestone Groups", - "operationId": "get_milestone_groups", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "items": { - "$ref": "#/components/schemas/MilestoneGroupPublic" - }, - "type": "array", - "title": "Response Get Milestone Groups Milestone Groups Get" - } - } - } - } - } - } - }, - "/milestone-groups/{milestone_group_id}": { - "get": { - "tags": ["milestones"], - "summary": "Get Milestone Group", - "operationId": "get_milestone_group", - "parameters": [ - { - "name": "milestone_group_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Milestone Group Id" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MilestoneGroupPublic" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/user-questions/": { - "get": { - "tags": ["questions"], - "summary": "Get User Questions", - "operationId": "get_user_questions", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "items": { - "$ref": "#/components/schemas/UserQuestionPublic" - }, - "type": "array", - "title": "Response Get User Questions User Questions Get" - } - } - } - } - } - } - }, - "/admin/languages/": { - "post": { - "tags": ["admin"], - "summary": "Create Language", - "operationId": "create_language", - "requestBody": { - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Language" } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/Language" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - } - }, - "/admin/languages/{language_id}": { - "delete": { - "tags": ["admin"], - "summary": "Delete Language", - "operationId": "delete_language", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "language_id", - "in": "path", - "required": true, - "schema": { "type": "string", "title": "Language Id" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/admin/i18n/{language_id}": { - "put": { - "tags": ["admin"], - "summary": "Update I18N", - "operationId": "update_i18n", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "language_id", - "in": "path", - "required": true, - "schema": { "type": "string", "title": "Language Id" } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { "type": "string" } - }, - "title": "I18Dict" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/admin/milestone-groups/": { - "get": { - "tags": ["admin"], - "summary": "Get Milestone Groups Admin", - "operationId": "get_milestone_groups_admin", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "items": { - "$ref": "#/components/schemas/MilestoneGroupAdmin" - }, - "type": "array", - "title": "Response Get Milestone Groups Admin Admin Milestone Groups Get" - } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - }, - "post": { - "tags": ["admin"], - "summary": "Create Milestone Group Admin", - "operationId": "create_milestone_group_admin", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/MilestoneGroupAdmin" } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - } - }, - "/admin/milestone-groups": { - "put": { - "tags": ["admin"], - "summary": "Update Milestone Group Admin", - "operationId": "update_milestone_group_admin", - "requestBody": { - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/MilestoneGroupAdmin" } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/MilestoneGroupAdmin" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - } - }, - "/admin/milestone-groups/{milestone_group_id}": { - "delete": { - "tags": ["admin"], - "summary": "Delete Milestone Group Admin", - "operationId": "delete_milestone_group_admin", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "milestone_group_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Milestone Group Id" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/admin/milestone-group-images/{milestone_group_id}": { - "put": { - "tags": ["admin"], - "summary": "Upload Milestone Group Image", - "operationId": "upload_milestone_group_image", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "milestone_group_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Milestone Group Id" } - } - ], - "requestBody": { - "required": true, - "content": { - "multipart/form-data": { - "schema": { - "$ref": "#/components/schemas/Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/admin/milestones/{milestone_group_id}": { - "post": { - "tags": ["admin"], - "summary": "Create Milestone", - "operationId": "create_milestone", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "milestone_group_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Milestone Group Id" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/MilestoneAdmin" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/admin/milestones/": { - "put": { - "tags": ["admin"], - "summary": "Update Milestone", - "operationId": "update_milestone", - "requestBody": { - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/MilestoneAdmin" } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/MilestoneAdmin" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - } - }, - "/admin/milestones/{milestone_id}": { - "delete": { - "tags": ["admin"], - "summary": "Delete Milestone", - "operationId": "delete_milestone", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "milestone_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Milestone Id" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/admin/milestone-images/{milestone_id}": { - "post": { - "tags": ["admin"], - "summary": "Upload Milestone Image", - "operationId": "upload_milestone_image", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "milestone_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Milestone Id" } - } - ], - "requestBody": { - "required": true, - "content": { - "multipart/form-data": { - "schema": { - "$ref": "#/components/schemas/Body_upload_milestone_image_admin_milestone_images__milestone_id__post" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/MilestoneImage" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/admin/user-questions/": { - "get": { - "tags": ["admin"], - "summary": "Get User Questions Admin", - "operationId": "get_user_questions_admin", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "items": { "$ref": "#/components/schemas/UserQuestionAdmin" }, - "type": "array", - "title": "Response Get User Questions Admin Admin User Questions Get" - } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - }, - "put": { - "tags": ["admin"], - "summary": "Update User Question", - "operationId": "update_user_question", - "requestBody": { - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserQuestionAdmin" } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserQuestionAdmin" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - }, - "post": { - "tags": ["admin"], - "summary": "Create User Question", - "operationId": "create_user_question", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserQuestionAdmin" } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - } - }, - "/admin/user-questions/{user_question_id}": { - "delete": { - "tags": ["admin"], - "summary": "Delete User Question", - "operationId": "delete_user_question", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "user_question_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "User Question Id" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/users/me": { - "get": { - "tags": ["users"], - "summary": "Users:Current User", - "operationId": "users:current_user", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserRead" } - } - } - }, - "401": { "description": "Missing token or inactive user." } - }, - "security": [{ "APIKeyCookie": [] }] - }, - "patch": { - "tags": ["users"], - "summary": "Users:Patch Current User", - "operationId": "users:patch_current_user", - "requestBody": { - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserUpdate" } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserRead" } - } - } - }, - "401": { "description": "Missing token or inactive user." }, - "400": { - "description": "Bad Request", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/ErrorModel" }, - "examples": { - "UPDATE_USER_EMAIL_ALREADY_EXISTS": { - "summary": "A user with this email already exists.", - "value": { "detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS" } - }, - "UPDATE_USER_INVALID_PASSWORD": { - "summary": "Password validation failed.", - "value": { - "detail": { - "code": "UPDATE_USER_INVALID_PASSWORD", - "reason": "Password should beat least 3 characters" - } - } - } - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - } - }, - "/users/{id}": { - "get": { - "tags": ["users"], - "summary": "Users:User", - "operationId": "users:user", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { "type": "string", "title": "Id" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserRead" } - } - } - }, - "401": { "description": "Missing token or inactive user." }, - "403": { "description": "Not a superuser." }, - "404": { "description": "The user does not exist." }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - }, - "patch": { - "tags": ["users"], - "summary": "Users:Patch User", - "operationId": "users:patch_user", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { "type": "string", "title": "Id" } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserUpdate" } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserRead" } - } - } - }, - "401": { "description": "Missing token or inactive user." }, - "403": { "description": "Not a superuser." }, - "404": { "description": "The user does not exist." }, - "400": { - "content": { - "application/json": { - "examples": { - "UPDATE_USER_EMAIL_ALREADY_EXISTS": { - "summary": "A user with this email already exists.", - "value": { "detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS" } - }, - "UPDATE_USER_INVALID_PASSWORD": { - "summary": "Password validation failed.", - "value": { - "detail": { - "code": "UPDATE_USER_INVALID_PASSWORD", - "reason": "Password should beat least 3 characters" - } - } - } - }, - "schema": { "$ref": "#/components/schemas/ErrorModel" } - } - }, - "description": "Bad Request" - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - }, - "delete": { - "tags": ["users"], - "summary": "Users:Delete User", - "operationId": "users:delete_user", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { "type": "string", "title": "Id" } - } - ], - "responses": { - "204": { "description": "Successful Response" }, - "401": { "description": "Missing token or inactive user." }, - "403": { "description": "Not a superuser." }, - "404": { "description": "The user does not exist." }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/users/children/": { - "get": { - "tags": ["users"], - "summary": "Get Children", - "operationId": "get_children", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "items": { "$ref": "#/components/schemas/ChildPublic" }, - "type": "array", - "title": "Response Get Children Users Children Get" - } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - }, - "put": { - "tags": ["users"], - "summary": "Update Child", - "operationId": "update_child", - "requestBody": { - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/ChildPublic" } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/ChildPublic" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - }, - "post": { - "tags": ["users"], - "summary": "Create Child", - "operationId": "create_child", - "requestBody": { - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/ChildCreate" } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/ChildPublic" } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - } - }, - "/users/children/{child_id}": { - "delete": { - "tags": ["users"], - "summary": "Delete Child", - "operationId": "delete_child", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "child_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Child Id" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/users/children-images/{child_id}": { - "get": { - "tags": ["users"], - "summary": "Get Child Image", - "operationId": "get_child_image", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "child_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Child Id" } - } - ], - "responses": { - "200": { "description": "Successful Response" }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - }, - "put": { - "tags": ["users"], - "summary": "Upload Child Image", - "operationId": "upload_child_image", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "child_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Child Id" } - } - ], - "requestBody": { - "required": true, - "content": { - "multipart/form-data": { - "schema": { - "$ref": "#/components/schemas/Body_upload_child_image_users_children_images__child_id__put" - } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/users/milestone-answers/{child_id}": { - "get": { - "tags": ["users"], - "summary": "Get Current Milestone Answer Session", - "operationId": "get_current_milestone_answer_session", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "child_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Child Id" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MilestoneAnswerSessionPublic" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/users/milestone-answers/{milestone_answer_session_id}": { - "put": { - "tags": ["users"], - "summary": "Update Milestone Answer", - "operationId": "update_milestone_answer", - "security": [{ "APIKeyCookie": [] }], - "parameters": [ - { - "name": "milestone_answer_session_id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "title": "Milestone Answer Session Id" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/MilestoneAnswerPublic" } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MilestoneAnswerPublic" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/users/user-answers/": { - "get": { - "tags": ["users"], - "summary": "Get Current User Answers", - "operationId": "get_current_user_answers", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "items": { "$ref": "#/components/schemas/UserAnswerPublic" }, - "type": "array", - "title": "Response Get Current User Answers Users User Answers Get" - } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - }, - "put": { - "tags": ["users"], - "summary": "Update Current User Answers", - "operationId": "update_current_user_answers", - "requestBody": { - "content": { - "application/json": { - "schema": { - "items": { "$ref": "#/components/schemas/UserAnswerPublic" }, - "type": "array", - "title": "New Answers" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "items": { "$ref": "#/components/schemas/UserAnswerPublic" }, - "type": "array", - "title": "Response Update Current User Answers Users User Answers Put" - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - }, - "security": [{ "APIKeyCookie": [] }] - } - }, - "/auth/login": { - "post": { - "tags": ["auth"], - "summary": "Auth:Cookie.Login", - "operationId": "auth:cookie.login", - "requestBody": { - "content": { - "application/x-www-form-urlencoded": { - "schema": { - "$ref": "#/components/schemas/Body_auth_cookie_login_auth_login_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "400": { - "description": "Bad Request", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/ErrorModel" }, - "examples": { - "LOGIN_BAD_CREDENTIALS": { - "summary": "Bad credentials or the user is inactive.", - "value": { "detail": "LOGIN_BAD_CREDENTIALS" } - }, - "LOGIN_USER_NOT_VERIFIED": { - "summary": "The user is not verified.", - "value": { "detail": "LOGIN_USER_NOT_VERIFIED" } - } - } - } - } - }, - "204": { "description": "No Content" }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/auth/logout": { - "post": { - "tags": ["auth"], - "summary": "Auth:Cookie.Logout", - "operationId": "auth:cookie.logout", - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "401": { "description": "Missing token or inactive user." }, - "204": { "description": "No Content" } - }, - "security": [{ "APIKeyCookie": [] }] - } - }, - "/auth/register": { - "post": { - "tags": ["auth"], - "summary": "Register:Register", - "operationId": "register:register", - "requestBody": { - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserCreate" } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserRead" } - } - } - }, - "400": { - "description": "Bad Request", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/ErrorModel" }, - "examples": { - "REGISTER_USER_ALREADY_EXISTS": { - "summary": "A user with this email already exists.", - "value": { "detail": "REGISTER_USER_ALREADY_EXISTS" } - }, - "REGISTER_INVALID_PASSWORD": { - "summary": "Password validation failed.", - "value": { - "detail": { - "code": "REGISTER_INVALID_PASSWORD", - "reason": "Password should beat least 3 characters" - } - } - } - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/auth/forgot-password": { - "post": { - "tags": ["auth"], - "summary": "Reset:Forgot Password", - "operationId": "reset:forgot_password", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_reset_forgot_password_auth_forgot_password_post" - } - } - }, - "required": true - }, - "responses": { - "202": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/auth/reset-password": { - "post": { - "tags": ["auth"], - "summary": "Reset:Reset Password", - "operationId": "reset:reset_password", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_reset_reset_password_auth_reset_password_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "400": { - "description": "Bad Request", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/ErrorModel" }, - "examples": { - "RESET_PASSWORD_BAD_TOKEN": { - "summary": "Bad or expired token.", - "value": { "detail": "RESET_PASSWORD_BAD_TOKEN" } - }, - "RESET_PASSWORD_INVALID_PASSWORD": { - "summary": "Password validation failed.", - "value": { - "detail": { - "code": "RESET_PASSWORD_INVALID_PASSWORD", - "reason": "Password should be at least 3 characters" - } - } - } - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/auth/request-verify-token": { - "post": { - "tags": ["auth"], - "summary": "Verify:Request-Token", - "operationId": "verify:request-token", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_verify_request_token_auth_request_verify_token_post" - } - } - }, - "required": true - }, - "responses": { - "202": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/auth/verify": { - "post": { - "tags": ["auth"], - "summary": "Verify:Verify", - "operationId": "verify:verify", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_verify_verify_auth_verify_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/UserRead" } - } - } - }, - "400": { - "description": "Bad Request", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/ErrorModel" }, - "examples": { - "VERIFY_USER_BAD_TOKEN": { - "summary": "Bad token, not existing user ornot the e-mail currently set for the user.", - "value": { "detail": "VERIFY_USER_BAD_TOKEN" } - }, - "VERIFY_USER_ALREADY_VERIFIED": { - "summary": "The user is already verified.", - "value": { "detail": "VERIFY_USER_ALREADY_VERIFIED" } - } - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/research/auth/": { - "get": { - "tags": ["research"], - "summary": "Auth", - "operationId": "auth", - "responses": { - "200": { - "description": "Successful Response", - "content": { "application/json": { "schema": {} } } - } - }, - "security": [{ "APIKeyCookie": [] }] - } - } - }, - "components": { - "schemas": { - "Body_auth_cookie_login_auth_login_post": { - "properties": { - "grant_type": { - "anyOf": [ - { "type": "string", "pattern": "password" }, - { "type": "null" } - ], - "title": "Grant Type" - }, - "username": { "type": "string", "title": "Username" }, - "password": { "type": "string", "title": "Password" }, - "scope": { "type": "string", "title": "Scope", "default": "" }, - "client_id": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Client Id" - }, - "client_secret": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Client Secret" - } - }, - "type": "object", - "required": ["username", "password"], - "title": "Body_auth_cookie_login_auth_login_post" - }, - "Body_reset_forgot_password_auth_forgot_password_post": { - "properties": { - "email": { "type": "string", "format": "email", "title": "Email" } - }, - "type": "object", - "required": ["email"], - "title": "Body_reset_forgot_password_auth_forgot_password_post" - }, - "Body_reset_reset_password_auth_reset_password_post": { - "properties": { - "token": { "type": "string", "title": "Token" }, - "password": { "type": "string", "title": "Password" } - }, - "type": "object", - "required": ["token", "password"], - "title": "Body_reset_reset_password_auth_reset_password_post" - }, - "Body_upload_child_image_users_children_images__child_id__put": { - "properties": { - "file": { "type": "string", "format": "binary", "title": "File" } - }, - "type": "object", - "required": ["file"], - "title": "Body_upload_child_image_users_children_images__child_id__put" - }, - "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put": { - "properties": { - "file": { "type": "string", "format": "binary", "title": "File" } - }, - "type": "object", - "required": ["file"], - "title": "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put" - }, - "Body_upload_milestone_image_admin_milestone_images__milestone_id__post": { - "properties": { - "file": { "type": "string", "format": "binary", "title": "File" } - }, - "type": "object", - "required": ["file"], - "title": "Body_upload_milestone_image_admin_milestone_images__milestone_id__post" - }, - "Body_verify_request_token_auth_request_verify_token_post": { - "properties": { - "email": { "type": "string", "format": "email", "title": "Email" } - }, - "type": "object", - "required": ["email"], - "title": "Body_verify_request_token_auth_request_verify_token_post" - }, - "Body_verify_verify_auth_verify_post": { - "properties": { "token": { "type": "string", "title": "Token" } }, - "type": "object", - "required": ["token"], - "title": "Body_verify_verify_auth_verify_post" - }, - "ChildCreate": { - "properties": { - "name": { "type": "string", "title": "Name", "default": "" }, - "birth_year": { "type": "integer", "title": "Birth Year" }, - "birth_month": { "type": "integer", "title": "Birth Month" } - }, - "type": "object", - "required": ["birth_year", "birth_month"], - "title": "ChildCreate" - }, - "ChildPublic": { - "properties": { - "name": { "type": "string", "title": "Name", "default": "" }, - "birth_year": { "type": "integer", "title": "Birth Year" }, - "birth_month": { "type": "integer", "title": "Birth Month" }, - "id": { "type": "integer", "title": "Id" }, - "has_image": { "type": "boolean", "title": "Has Image" } - }, - "type": "object", - "required": ["birth_year", "birth_month", "id", "has_image"], - "title": "ChildPublic" - }, - "ErrorModel": { - "properties": { - "detail": { - "anyOf": [ - { "type": "string" }, - { "additionalProperties": { "type": "string" }, "type": "object" } - ], - "title": "Detail" - } - }, - "type": "object", - "required": ["detail"], - "title": "ErrorModel" - }, - "HTTPValidationError": { - "properties": { - "detail": { - "items": { "$ref": "#/components/schemas/ValidationError" }, - "type": "array", - "title": "Detail" - } - }, - "type": "object", - "title": "HTTPValidationError" - }, - "Language": { - "properties": { - "id": { "type": "string", "maxLength": 2, "title": "Id" } - }, - "type": "object", - "required": ["id"], - "title": "Language" - }, - "MilestoneAdmin": { - "properties": { - "id": { "type": "integer", "title": "Id" }, - "group_id": { "type": "integer", "title": "Group Id" }, - "order": { "type": "integer", "title": "Order" }, - "text": { - "additionalProperties": { - "$ref": "#/components/schemas/MilestoneText" - }, - "type": "object", - "title": "Text", - "default": {} - }, - "images": { - "items": { "$ref": "#/components/schemas/MilestoneImage" }, - "type": "array", - "title": "Images", - "default": [] - } - }, - "type": "object", - "required": ["id", "group_id", "order"], - "title": "MilestoneAdmin" - }, - "MilestoneAnswerPublic": { - "properties": { - "milestone_id": { "type": "integer", "title": "Milestone Id" }, - "answer": { "type": "integer", "title": "Answer" } - }, - "type": "object", - "required": ["milestone_id", "answer"], - "title": "MilestoneAnswerPublic" - }, - "MilestoneAnswerSessionPublic": { - "properties": { - "id": { "type": "integer", "title": "Id" }, - "child_id": { "type": "integer", "title": "Child Id" }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - }, - "answers": { - "additionalProperties": { - "$ref": "#/components/schemas/MilestoneAnswerPublic" - }, - "type": "object", - "title": "Answers" - } - }, - "type": "object", - "required": ["id", "child_id", "created_at", "answers"], - "title": "MilestoneAnswerSessionPublic" - }, - "MilestoneGroupAdmin": { - "properties": { - "id": { "type": "integer", "title": "Id" }, - "order": { "type": "integer", "title": "Order" }, - "text": { - "additionalProperties": { - "$ref": "#/components/schemas/MilestoneGroupText" - }, - "type": "object", - "title": "Text", - "default": {} - }, - "milestones": { - "items": { "$ref": "#/components/schemas/MilestoneAdmin" }, - "type": "array", - "title": "Milestones", - "default": [] - } - }, - "type": "object", - "required": ["id", "order"], - "title": "MilestoneGroupAdmin" - }, - "MilestoneGroupPublic": { - "properties": { - "id": { "type": "integer", "title": "Id" }, - "text": { - "additionalProperties": { - "$ref": "#/components/schemas/MilestoneGroupTextPublic" - }, - "type": "object", - "title": "Text", - "default": {} - }, - "milestones": { - "items": { "$ref": "#/components/schemas/MilestonePublic" }, - "type": "array", - "title": "Milestones", - "default": [] - } - }, - "type": "object", - "required": ["id"], - "title": "MilestoneGroupPublic" - }, - "MilestoneGroupText": { - "properties": { - "title": { "type": "string", "title": "Title", "default": "" }, - "desc": { "type": "string", "title": "Desc", "default": "" }, - "group_id": { - "anyOf": [{ "type": "integer" }, { "type": "null" }], - "title": "Group Id" - }, - "lang_id": { - "anyOf": [{ "type": "string", "maxLength": 2 }, { "type": "null" }], - "title": "Lang Id" - } - }, - "type": "object", - "title": "MilestoneGroupText" - }, - "MilestoneGroupTextPublic": { - "properties": { - "title": { "type": "string", "title": "Title", "default": "" }, - "desc": { "type": "string", "title": "Desc", "default": "" } - }, - "type": "object", - "title": "MilestoneGroupTextPublic" - }, - "MilestoneImage": { - "properties": { - "id": { - "anyOf": [{ "type": "integer" }, { "type": "null" }], - "title": "Id" - }, - "milestone_id": { - "anyOf": [{ "type": "integer" }, { "type": "null" }], - "title": "Milestone Id" - }, - "filename": { "type": "string", "title": "Filename", "default": "" }, - "approved": { - "type": "boolean", - "title": "Approved", - "default": false - } - }, - "type": "object", - "title": "MilestoneImage" - }, - "MilestoneImagePublic": { - "properties": { - "filename": { "type": "string", "title": "Filename" }, - "approved": { "type": "boolean", "title": "Approved" } - }, - "type": "object", - "required": ["filename", "approved"], - "title": "MilestoneImagePublic" - }, - "MilestonePublic": { - "properties": { - "id": { "type": "integer", "title": "Id" }, - "text": { - "additionalProperties": { - "$ref": "#/components/schemas/MilestoneTextPublic" - }, - "type": "object", - "title": "Text", - "default": {} - }, - "images": { - "items": { "$ref": "#/components/schemas/MilestoneImagePublic" }, - "type": "array", - "title": "Images", - "default": [] - } - }, - "type": "object", - "required": ["id"], - "title": "MilestonePublic" - }, - "MilestoneText": { - "properties": { - "title": { "type": "string", "title": "Title", "default": "" }, - "desc": { "type": "string", "title": "Desc", "default": "" }, - "obs": { "type": "string", "title": "Obs", "default": "" }, - "help": { "type": "string", "title": "Help", "default": "" }, - "milestone_id": { - "anyOf": [{ "type": "integer" }, { "type": "null" }], - "title": "Milestone Id" - }, - "lang_id": { - "anyOf": [{ "type": "string", "maxLength": 2 }, { "type": "null" }], - "title": "Lang Id" - } - }, - "type": "object", - "title": "MilestoneText" - }, - "MilestoneTextPublic": { - "properties": { - "title": { "type": "string", "title": "Title", "default": "" }, - "desc": { "type": "string", "title": "Desc", "default": "" }, - "obs": { "type": "string", "title": "Obs", "default": "" }, - "help": { "type": "string", "title": "Help", "default": "" } - }, - "type": "object", - "title": "MilestoneTextPublic" - }, - "UserAnswerPublic": { - "properties": { - "answer": { "type": "string", "title": "Answer" }, - "question_id": { "type": "integer", "title": "Question Id" }, - "additional_answer": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Additional Answer" - } - }, - "type": "object", - "required": ["answer", "question_id", "additional_answer"], - "title": "UserAnswerPublic", - "description": "External data model for UserAnswers\n\nParameters\n----------\nSQLModel : Pydantic model basic sqlmodel pydantic type" - }, - "UserCreate": { - "properties": { - "email": { "type": "string", "format": "email", "title": "Email" }, - "password": { "type": "string", "title": "Password" }, - "is_active": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "title": "Is Active", - "default": true - }, - "is_superuser": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "title": "Is Superuser", - "default": false - }, - "is_verified": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "title": "Is Verified", - "default": false - }, - "is_researcher": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "title": "Is Researcher", - "default": false - } - }, - "type": "object", - "required": ["email", "password"], - "title": "UserCreate" - }, - "UserQuestionAdmin": { - "properties": { - "id": { "type": "integer", "title": "Id" }, - "order": { "type": "integer", "title": "Order" }, - "component": { - "type": "string", - "title": "Component", - "default": "select" - }, - "type": { "type": "string", "title": "Type", "default": "text" }, - "options": { "type": "string", "title": "Options" }, - "text": { - "additionalProperties": { - "$ref": "#/components/schemas/UserQuestionText" - }, - "type": "object", - "title": "Text", - "default": {} - }, - "additional_option": { - "type": "string", - "title": "Additional Option", - "default": "" - } - }, - "type": "object", - "required": ["id", "order", "options"], - "title": "UserQuestionAdmin" - }, - "UserQuestionPublic": { - "properties": { - "id": { "type": "integer", "title": "Id" }, - "component": { - "type": "string", - "title": "Component", - "default": "select" - }, - "type": { "type": "string", "title": "Type", "default": "text" }, - "text": { - "additionalProperties": { - "$ref": "#/components/schemas/UserQuestionTextPublic" - }, - "type": "object", - "title": "Text", - "default": {} - }, - "additional_option": { - "type": "string", - "title": "Additional Option", - "default": "" - } - }, - "type": "object", - "required": ["id"], - "title": "UserQuestionPublic" - }, - "UserQuestionText": { - "properties": { - "question": { "type": "string", "title": "Question", "default": "" }, - "options_json": { - "type": "string", - "title": "Options Json", - "default": "" - }, - "user_question_id": { - "anyOf": [{ "type": "integer" }, { "type": "null" }], - "title": "User Question Id" - }, - "lang_id": { - "anyOf": [{ "type": "string", "maxLength": 2 }, { "type": "null" }], - "title": "Lang Id" - }, - "options": { "type": "string", "title": "Options", "default": "" } - }, - "type": "object", - "title": "UserQuestionText" - }, - "UserQuestionTextPublic": { - "properties": { - "question": { "type": "string", "title": "Question", "default": "" }, - "options_json": { - "type": "string", - "title": "Options Json", - "default": "" - } - }, - "type": "object", - "title": "UserQuestionTextPublic" - }, - "UserRead": { - "properties": { - "id": { "type": "integer", "title": "Id" }, - "email": { "type": "string", "format": "email", "title": "Email" }, - "is_active": { - "type": "boolean", - "title": "Is Active", - "default": true - }, - "is_superuser": { - "type": "boolean", - "title": "Is Superuser", - "default": false - }, - "is_verified": { - "type": "boolean", - "title": "Is Verified", - "default": false - }, - "is_researcher": { "type": "boolean", "title": "Is Researcher" } - }, - "type": "object", - "required": ["id", "email", "is_researcher"], - "title": "UserRead" - }, - "UserUpdate": { - "properties": { - "password": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Password" - }, - "email": { - "anyOf": [ - { "type": "string", "format": "email" }, - { "type": "null" } - ], - "title": "Email" - }, - "is_active": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "title": "Is Active" - }, - "is_superuser": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "title": "Is Superuser" - }, - "is_verified": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "title": "Is Verified" - }, - "is_researcher": { - "anyOf": [{ "type": "boolean" }, { "type": "null" }], - "title": "Is Researcher" - } - }, - "type": "object", - "title": "UserUpdate" - }, - "ValidationError": { - "properties": { - "loc": { - "items": { "anyOf": [{ "type": "string" }, { "type": "integer" }] }, - "type": "array", - "title": "Location" - }, - "msg": { "type": "string", "title": "Message" }, - "type": { "type": "string", "title": "Error Type" } - }, - "type": "object", - "required": ["loc", "msg", "type"], - "title": "ValidationError" - } - }, - "securitySchemes": { - "APIKeyCookie": { - "type": "apiKey", - "in": "cookie", - "name": "fastapiusersauth" - } - } - } -} +{"openapi": "3.1.0", "info": {"title": "MONDEY API", "version": "0.1.0"}, "paths": {"/languages/": {"get": {"tags": ["milestones"], "summary": "Get Languages", "operationId": "get_languages", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"type": "string"}, "type": "array", "title": "Response Get Languages Languages Get"}}}}}}}, "/milestones/": {"get": {"tags": ["milestones"], "summary": "Get Milestones", "operationId": "get_milestones", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestonePublic"}, "type": "array", "title": "Response Get Milestones Milestones Get"}}}}}}}, "/milestones/{milestone_id}": {"get": {"tags": ["milestones"], "summary": "Get Milestone", "operationId": "get_milestone", "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestonePublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/milestone-groups/": {"get": {"tags": ["milestones"], "summary": "Get Milestone Groups", "operationId": "get_milestone_groups", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestoneGroupPublic"}, "type": "array", "title": "Response Get Milestone Groups Milestone Groups Get"}}}}}}}, "/milestone-groups/{milestone_group_id}": {"get": {"tags": ["milestones"], "summary": "Get Milestone Group", "operationId": "get_milestone_group", "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/user-questions/": {"get": {"tags": ["questions"], "summary": "Get User Questions", "operationId": "get_user_questions", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserQuestionPublic"}, "type": "array", "title": "Response Get User Questions User Questions Get"}}}}}}}, "/child-questions/": {"get": {"tags": ["questions"], "summary": "Get Child Questions", "operationId": "get_child_questions", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildQuestionPublic"}, "type": "array", "title": "Response Get Child Questions Child Questions Get"}}}}}}}, "/admin/languages/": {"post": {"tags": ["admin"], "summary": "Create Language", "operationId": "create_language", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Language"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Language"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/languages/{language_id}": {"delete": {"tags": ["admin"], "summary": "Delete Language", "operationId": "delete_language", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "language_id", "in": "path", "required": true, "schema": {"type": "string", "title": "Language Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/i18n/{language_id}": {"put": {"tags": ["admin"], "summary": "Update I18N", "operationId": "update_i18n", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "language_id", "in": "path", "required": true, "schema": {"type": "string", "title": "Language Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": {"type": "object", "additionalProperties": {"type": "string"}}, "title": "I18Dict"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-groups/": {"get": {"tags": ["admin"], "summary": "Get Milestone Groups Admin", "operationId": "get_milestone_groups_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}, "type": "array", "title": "Response Get Milestone Groups Admin Admin Milestone Groups Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create Milestone Group Admin", "operationId": "create_milestone_group_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestone-groups": {"put": {"tags": ["admin"], "summary": "Update Milestone Group Admin", "operationId": "update_milestone_group_admin", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneGroupAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestone-groups/{milestone_group_id}": {"delete": {"tags": ["admin"], "summary": "Delete Milestone Group Admin", "operationId": "delete_milestone_group_admin", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-group-images/{milestone_group_id}": {"put": {"tags": ["admin"], "summary": "Upload Milestone Group Image", "operationId": "upload_milestone_group_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestones/{milestone_group_id}": {"post": {"tags": ["admin"], "summary": "Create Milestone", "operationId": "create_milestone", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_group_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Group Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestones/": {"put": {"tags": ["admin"], "summary": "Update Milestone", "operationId": "update_milestone", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/milestones/{milestone_id}": {"delete": {"tags": ["admin"], "summary": "Delete Milestone", "operationId": "delete_milestone", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/milestone-images/{milestone_id}": {"post": {"tags": ["admin"], "summary": "Upload Milestone Image", "operationId": "upload_milestone_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_milestone_image_admin_milestone_images__milestone_id__post"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneImage"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/user-questions/": {"get": {"tags": ["admin"], "summary": "Get User Questions Admin", "operationId": "get_user_questions_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserQuestionAdmin"}, "type": "array", "title": "Response Get User Questions Admin Admin User Questions Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["admin"], "summary": "Update User Question", "operationId": "update_user_question", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create User Question", "operationId": "create_user_question", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserQuestionAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/user-questions/{user_question_id}": {"delete": {"tags": ["admin"], "summary": "Delete User Question", "operationId": "delete_user_question", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "user_question_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "User Question Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/admin/child-questions/": {"get": {"tags": ["admin"], "summary": "Get Child Questions Admin", "operationId": "get_child_questions_admin", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildQuestionAdmin"}, "type": "array", "title": "Response Get Child Questions Admin Admin Child Questions Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["admin"], "summary": "Update Child Question", "operationId": "update_child_question", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildQuestionAdmin"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildQuestionAdmin"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["admin"], "summary": "Create Child Question", "operationId": "create_child_question", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildQuestionAdmin"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/admin/child-questions/{child_question_id}": {"delete": {"tags": ["admin"], "summary": "Delete Child Question", "operationId": "delete_child_question", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_question_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Question Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/me": {"get": {"tags": ["users"], "summary": "Users:Current User", "operationId": "users:current_user", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}}, "security": [{"APIKeyCookie": []}]}, "patch": {"tags": ["users"], "summary": "Users:Patch Current User", "operationId": "users:patch_current_user", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserUpdate"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"UPDATE_USER_EMAIL_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS"}}, "UPDATE_USER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "UPDATE_USER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/{id}": {"get": {"tags": ["users"], "summary": "Users:User", "operationId": "users:user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "patch": {"tags": ["users"], "summary": "Users:Patch User", "operationId": "users:patch_user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserUpdate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "400": {"content": {"application/json": {"examples": {"UPDATE_USER_EMAIL_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "UPDATE_USER_EMAIL_ALREADY_EXISTS"}}, "UPDATE_USER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "UPDATE_USER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}, "schema": {"$ref": "#/components/schemas/ErrorModel"}}}, "description": "Bad Request"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "delete": {"tags": ["users"], "summary": "Users:Delete User", "operationId": "users:delete_user", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "title": "Id"}}], "responses": {"204": {"description": "Successful Response"}, "401": {"description": "Missing token or inactive user."}, "403": {"description": "Not a superuser."}, "404": {"description": "The user does not exist."}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/children/": {"get": {"tags": ["users"], "summary": "Get Children", "operationId": "get_children", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildPublic"}, "type": "array", "title": "Response Get Children Users Children Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Child", "operationId": "update_child", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}, "post": {"tags": ["users"], "summary": "Create Child", "operationId": "create_child", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildCreate"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChildPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/children/{child_id}": {"delete": {"tags": ["users"], "summary": "Delete Child", "operationId": "delete_child", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/children-images/{child_id}": {"get": {"tags": ["users"], "summary": "Get Child Image", "operationId": "get_child_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "put": {"tags": ["users"], "summary": "Upload Child Image", "operationId": "upload_child_image", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "requestBody": {"required": true, "content": {"multipart/form-data": {"schema": {"$ref": "#/components/schemas/Body_upload_child_image_users_children_images__child_id__put"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/milestone-answers/{child_id}": {"get": {"tags": ["users"], "summary": "Get Current Milestone Answer Session", "operationId": "get_current_milestone_answer_session", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "child_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Child Id"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerSessionPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/milestone-answers/{milestone_answer_session_id}": {"put": {"tags": ["users"], "summary": "Update Milestone Answer", "operationId": "update_milestone_answer", "security": [{"APIKeyCookie": []}], "parameters": [{"name": "milestone_answer_session_id", "in": "path", "required": true, "schema": {"type": "integer", "title": "Milestone Answer Session Id"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/users/user-answers/": {"get": {"tags": ["users"], "summary": "Get Current User Answers", "operationId": "get_current_user_answers", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "Response Get Current User Answers Users User Answers Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Current User Answers", "operationId": "update_current_user_answers", "requestBody": {"content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "New Answers"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/UserAnswerPublic"}, "type": "array", "title": "Response Update Current User Answers Users User Answers Put"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/users/children-answers/": {"get": {"tags": ["users"], "summary": "Get Current Children Answers", "operationId": "get_current_children_answers", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildAnswerPublic"}, "type": "array", "title": "Response Get Current Children Answers Users Children Answers Get"}}}}}, "security": [{"APIKeyCookie": []}]}, "put": {"tags": ["users"], "summary": "Update Current Children Answers", "operationId": "update_current_children_answers", "requestBody": {"content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildAnswerPublic"}, "type": "array", "title": "New Answers"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"items": {"$ref": "#/components/schemas/ChildAnswerPublic"}, "type": "array", "title": "Response Update Current Children Answers Users Children Answers Put"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}, "security": [{"APIKeyCookie": []}]}}, "/auth/login": {"post": {"tags": ["auth"], "summary": "Auth:Cookie.Login", "operationId": "auth:cookie.login", "requestBody": {"content": {"application/x-www-form-urlencoded": {"schema": {"$ref": "#/components/schemas/Body_auth_cookie_login_auth_login_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"LOGIN_BAD_CREDENTIALS": {"summary": "Bad credentials or the user is inactive.", "value": {"detail": "LOGIN_BAD_CREDENTIALS"}}, "LOGIN_USER_NOT_VERIFIED": {"summary": "The user is not verified.", "value": {"detail": "LOGIN_USER_NOT_VERIFIED"}}}}}}, "204": {"description": "No Content"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/logout": {"post": {"tags": ["auth"], "summary": "Auth:Cookie.Logout", "operationId": "auth:cookie.logout", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "401": {"description": "Missing token or inactive user."}, "204": {"description": "No Content"}}, "security": [{"APIKeyCookie": []}]}}, "/auth/register": {"post": {"tags": ["auth"], "summary": "Register:Register", "operationId": "register:register", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserCreate"}}}, "required": true}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"REGISTER_USER_ALREADY_EXISTS": {"summary": "A user with this email already exists.", "value": {"detail": "REGISTER_USER_ALREADY_EXISTS"}}, "REGISTER_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "REGISTER_INVALID_PASSWORD", "reason": "Password should beat least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/forgot-password": {"post": {"tags": ["auth"], "summary": "Reset:Forgot Password", "operationId": "reset:forgot_password", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_reset_forgot_password_auth_forgot_password_post"}}}, "required": true}, "responses": {"202": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/reset-password": {"post": {"tags": ["auth"], "summary": "Reset:Reset Password", "operationId": "reset:reset_password", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_reset_reset_password_auth_reset_password_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"RESET_PASSWORD_BAD_TOKEN": {"summary": "Bad or expired token.", "value": {"detail": "RESET_PASSWORD_BAD_TOKEN"}}, "RESET_PASSWORD_INVALID_PASSWORD": {"summary": "Password validation failed.", "value": {"detail": {"code": "RESET_PASSWORD_INVALID_PASSWORD", "reason": "Password should be at least 3 characters"}}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/request-verify-token": {"post": {"tags": ["auth"], "summary": "Verify:Request-Token", "operationId": "verify:request-token", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_verify_request_token_auth_request_verify_token_post"}}}, "required": true}, "responses": {"202": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/auth/verify": {"post": {"tags": ["auth"], "summary": "Verify:Verify", "operationId": "verify:verify", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Body_verify_verify_auth_verify_post"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserRead"}}}}, "400": {"description": "Bad Request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorModel"}, "examples": {"VERIFY_USER_BAD_TOKEN": {"summary": "Bad token, not existing user ornot the e-mail currently set for the user.", "value": {"detail": "VERIFY_USER_BAD_TOKEN"}}, "VERIFY_USER_ALREADY_VERIFIED": {"summary": "The user is already verified.", "value": {"detail": "VERIFY_USER_ALREADY_VERIFIED"}}}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/research/auth/": {"get": {"tags": ["research"], "summary": "Auth", "operationId": "auth", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}, "security": [{"APIKeyCookie": []}]}}}, "components": {"schemas": {"Body_auth_cookie_login_auth_login_post": {"properties": {"grant_type": {"anyOf": [{"type": "string", "pattern": "password"}, {"type": "null"}], "title": "Grant Type"}, "username": {"type": "string", "title": "Username"}, "password": {"type": "string", "title": "Password"}, "scope": {"type": "string", "title": "Scope", "default": ""}, "client_id": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Client Id"}, "client_secret": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Client Secret"}}, "type": "object", "required": ["username", "password"], "title": "Body_auth_cookie_login_auth_login_post"}, "Body_reset_forgot_password_auth_forgot_password_post": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}}, "type": "object", "required": ["email"], "title": "Body_reset_forgot_password_auth_forgot_password_post"}, "Body_reset_reset_password_auth_reset_password_post": {"properties": {"token": {"type": "string", "title": "Token"}, "password": {"type": "string", "title": "Password"}}, "type": "object", "required": ["token", "password"], "title": "Body_reset_reset_password_auth_reset_password_post"}, "Body_upload_child_image_users_children_images__child_id__put": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_child_image_users_children_images__child_id__put"}, "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_milestone_group_image_admin_milestone_group_images__milestone_group_id__put"}, "Body_upload_milestone_image_admin_milestone_images__milestone_id__post": {"properties": {"file": {"type": "string", "format": "binary", "title": "File"}}, "type": "object", "required": ["file"], "title": "Body_upload_milestone_image_admin_milestone_images__milestone_id__post"}, "Body_verify_request_token_auth_request_verify_token_post": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}}, "type": "object", "required": ["email"], "title": "Body_verify_request_token_auth_request_verify_token_post"}, "Body_verify_verify_auth_verify_post": {"properties": {"token": {"type": "string", "title": "Token"}}, "type": "object", "required": ["token"], "title": "Body_verify_verify_auth_verify_post"}, "ChildAnswerPublic": {"properties": {"answer": {"type": "string", "title": "Answer"}, "question_id": {"type": "integer", "title": "Question Id"}, "additional_answer": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Additional Answer"}}, "type": "object", "required": ["answer", "question_id", "additional_answer"], "title": "ChildAnswerPublic", "description": "External data model for UserAnswers\n\nParameters\n----------\nSQLModel : Pydantic model basic sqlmodel pydantic type"}, "ChildCreate": {"properties": {"name": {"type": "string", "title": "Name", "default": ""}, "birth_year": {"type": "integer", "title": "Birth Year"}, "birth_month": {"type": "integer", "title": "Birth Month"}}, "type": "object", "required": ["birth_year", "birth_month"], "title": "ChildCreate"}, "ChildPublic": {"properties": {"name": {"type": "string", "title": "Name", "default": ""}, "birth_year": {"type": "integer", "title": "Birth Year"}, "birth_month": {"type": "integer", "title": "Birth Month"}, "id": {"type": "integer", "title": "Id"}, "has_image": {"type": "boolean", "title": "Has Image"}}, "type": "object", "required": ["birth_year", "birth_month", "id", "has_image"], "title": "ChildPublic"}, "ChildQuestionAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "options": {"type": "string", "title": "Options"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/ChildQuestionText"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id", "order", "options"], "title": "ChildQuestionAdmin"}, "ChildQuestionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/ChildQuestionTextPublic"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id"], "title": "ChildQuestionPublic"}, "ChildQuestionText": {"properties": {"question": {"type": "string", "title": "Question", "default": ""}, "options_json": {"type": "string", "title": "Options Json", "default": ""}, "child_question_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Child Question Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}, "options": {"type": "string", "title": "Options", "default": ""}}, "type": "object", "title": "ChildQuestionText"}, "ChildQuestionTextPublic": {"properties": {"question": {"type": "string", "title": "Question", "default": ""}, "options_json": {"type": "string", "title": "Options Json", "default": ""}}, "type": "object", "title": "ChildQuestionTextPublic"}, "ErrorModel": {"properties": {"detail": {"anyOf": [{"type": "string"}, {"additionalProperties": {"type": "string"}, "type": "object"}], "title": "Detail"}}, "type": "object", "required": ["detail"], "title": "ErrorModel"}, "HTTPValidationError": {"properties": {"detail": {"items": {"$ref": "#/components/schemas/ValidationError"}, "type": "array", "title": "Detail"}}, "type": "object", "title": "HTTPValidationError"}, "Language": {"properties": {"id": {"type": "string", "maxLength": 2, "title": "Id"}}, "type": "object", "required": ["id"], "title": "Language"}, "MilestoneAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "group_id": {"type": "integer", "title": "Group Id"}, "order": {"type": "integer", "title": "Order"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneText"}, "type": "object", "title": "Text", "default": {}}, "images": {"items": {"$ref": "#/components/schemas/MilestoneImage"}, "type": "array", "title": "Images", "default": []}}, "type": "object", "required": ["id", "group_id", "order"], "title": "MilestoneAdmin"}, "MilestoneAnswerPublic": {"properties": {"milestone_id": {"type": "integer", "title": "Milestone Id"}, "answer": {"type": "integer", "title": "Answer"}}, "type": "object", "required": ["milestone_id", "answer"], "title": "MilestoneAnswerPublic"}, "MilestoneAnswerSessionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "child_id": {"type": "integer", "title": "Child Id"}, "created_at": {"type": "string", "format": "date-time", "title": "Created At"}, "answers": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneAnswerPublic"}, "type": "object", "title": "Answers"}}, "type": "object", "required": ["id", "child_id", "created_at", "answers"], "title": "MilestoneAnswerSessionPublic"}, "MilestoneGroupAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneGroupText"}, "type": "object", "title": "Text", "default": {}}, "milestones": {"items": {"$ref": "#/components/schemas/MilestoneAdmin"}, "type": "array", "title": "Milestones", "default": []}}, "type": "object", "required": ["id", "order"], "title": "MilestoneGroupAdmin"}, "MilestoneGroupPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneGroupTextPublic"}, "type": "object", "title": "Text", "default": {}}, "milestones": {"items": {"$ref": "#/components/schemas/MilestonePublic"}, "type": "array", "title": "Milestones", "default": []}}, "type": "object", "required": ["id"], "title": "MilestoneGroupPublic"}, "MilestoneGroupText": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "group_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Group Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}}, "type": "object", "title": "MilestoneGroupText"}, "MilestoneGroupTextPublic": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}}, "type": "object", "title": "MilestoneGroupTextPublic"}, "MilestoneImage": {"properties": {"id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id"}, "milestone_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Milestone Id"}, "filename": {"type": "string", "title": "Filename", "default": ""}, "approved": {"type": "boolean", "title": "Approved", "default": false}}, "type": "object", "title": "MilestoneImage"}, "MilestoneImagePublic": {"properties": {"filename": {"type": "string", "title": "Filename"}, "approved": {"type": "boolean", "title": "Approved"}}, "type": "object", "required": ["filename", "approved"], "title": "MilestoneImagePublic"}, "MilestonePublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/MilestoneTextPublic"}, "type": "object", "title": "Text", "default": {}}, "images": {"items": {"$ref": "#/components/schemas/MilestoneImagePublic"}, "type": "array", "title": "Images", "default": []}}, "type": "object", "required": ["id"], "title": "MilestonePublic"}, "MilestoneText": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "obs": {"type": "string", "title": "Obs", "default": ""}, "help": {"type": "string", "title": "Help", "default": ""}, "milestone_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Milestone Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}}, "type": "object", "title": "MilestoneText"}, "MilestoneTextPublic": {"properties": {"title": {"type": "string", "title": "Title", "default": ""}, "desc": {"type": "string", "title": "Desc", "default": ""}, "obs": {"type": "string", "title": "Obs", "default": ""}, "help": {"type": "string", "title": "Help", "default": ""}}, "type": "object", "title": "MilestoneTextPublic"}, "UserAnswerPublic": {"properties": {"answer": {"type": "string", "title": "Answer"}, "question_id": {"type": "integer", "title": "Question Id"}, "additional_answer": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Additional Answer"}}, "type": "object", "required": ["answer", "question_id", "additional_answer"], "title": "UserAnswerPublic", "description": "External data model for UserAnswers\n\nParameters\n----------\nSQLModel : Pydantic model basic sqlmodel pydantic type"}, "UserCreate": {"properties": {"email": {"type": "string", "format": "email", "title": "Email"}, "password": {"type": "string", "title": "Password"}, "is_active": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Active", "default": true}, "is_superuser": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Superuser", "default": false}, "is_verified": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Verified", "default": false}, "is_researcher": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Researcher", "default": false}}, "type": "object", "required": ["email", "password"], "title": "UserCreate"}, "UserQuestionAdmin": {"properties": {"id": {"type": "integer", "title": "Id"}, "order": {"type": "integer", "title": "Order"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "options": {"type": "string", "title": "Options"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/UserQuestionText"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id", "order", "options"], "title": "UserQuestionAdmin"}, "UserQuestionPublic": {"properties": {"id": {"type": "integer", "title": "Id"}, "component": {"type": "string", "title": "Component", "default": "select"}, "type": {"type": "string", "title": "Type", "default": "text"}, "text": {"additionalProperties": {"$ref": "#/components/schemas/UserQuestionTextPublic"}, "type": "object", "title": "Text", "default": {}}, "additional_option": {"type": "string", "title": "Additional Option", "default": ""}}, "type": "object", "required": ["id"], "title": "UserQuestionPublic"}, "UserQuestionText": {"properties": {"question": {"type": "string", "title": "Question", "default": ""}, "options_json": {"type": "string", "title": "Options Json", "default": ""}, "user_question_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "User Question Id"}, "lang_id": {"anyOf": [{"type": "string", "maxLength": 2}, {"type": "null"}], "title": "Lang Id"}, "options": {"type": "string", "title": "Options", "default": ""}}, "type": "object", "title": "UserQuestionText"}, "UserQuestionTextPublic": {"properties": {"question": {"type": "string", "title": "Question", "default": ""}, "options_json": {"type": "string", "title": "Options Json", "default": ""}}, "type": "object", "title": "UserQuestionTextPublic"}, "UserRead": {"properties": {"id": {"type": "integer", "title": "Id"}, "email": {"type": "string", "format": "email", "title": "Email"}, "is_active": {"type": "boolean", "title": "Is Active", "default": true}, "is_superuser": {"type": "boolean", "title": "Is Superuser", "default": false}, "is_verified": {"type": "boolean", "title": "Is Verified", "default": false}, "is_researcher": {"type": "boolean", "title": "Is Researcher"}}, "type": "object", "required": ["id", "email", "is_researcher"], "title": "UserRead"}, "UserUpdate": {"properties": {"password": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Password"}, "email": {"anyOf": [{"type": "string", "format": "email"}, {"type": "null"}], "title": "Email"}, "is_active": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Active"}, "is_superuser": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Superuser"}, "is_verified": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Verified"}, "is_researcher": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "title": "Is Researcher"}}, "type": "object", "title": "UserUpdate"}, "ValidationError": {"properties": {"loc": {"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, "type": "array", "title": "Location"}, "msg": {"type": "string", "title": "Message"}, "type": {"type": "string", "title": "Error Type"}}, "type": "object", "required": ["loc", "msg", "type"], "title": "ValidationError"}}, "securitySchemes": {"APIKeyCookie": {"type": "apiKey", "in": "cookie", "name": "fastapiusersauth"}}}} \ No newline at end of file From f48067a470cda90bda45c07801490b98359bf2be Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Tue, 29 Oct 2024 17:02:27 +0100 Subject: [PATCH 17/87] refactor away DataInput from user registry and login --- frontend/src/lib/components/UserLogin.svelte | 79 ++++----- .../lib/components/UserRegistration.svelte | 150 ++++++++---------- 2 files changed, 104 insertions(+), 125 deletions(-) diff --git a/frontend/src/lib/components/UserLogin.svelte b/frontend/src/lib/components/UserLogin.svelte index 05c78cd4..e56b0d07 100644 --- a/frontend/src/lib/components/UserLogin.svelte +++ b/frontend/src/lib/components/UserLogin.svelte @@ -3,16 +3,18 @@ import UserLoginUtil from '$lib/components//UserLoginUtil.svelte'; import AlertMessage from '$lib/components/AlertMessage.svelte'; - import DataInput from '$lib/components/DataInput/DataInput.svelte'; import { goto } from '$app/navigation'; import { authCookieLogin, usersCurrentUser } from '$lib/client/services.gen'; import { type AuthCookieLoginData, type UserRead } from '$lib/client/types.gen'; import { currentUser } from '$lib/stores/userStore'; import { preventDefault } from '$lib/util'; - import { Button, Card, Heading, Input } from 'flowbite-svelte'; + import { Button, Card, Heading, Input, Label } from 'flowbite-svelte'; import { _ } from 'svelte-i18n'; + // TODO: make the remember thing functional again + + // FIXME: make use of the logic of the AdminUser structure and get rid of the UserStore async function refresh(): Promise { const returned = await usersCurrentUser(); if (returned.error) { @@ -30,8 +32,8 @@ async function submitData(): Promise { const loginData: AuthCookieLoginData = { body: { - username: formData[0].value, - password: formData[1].value + username: username, + password: password } }; @@ -57,33 +59,9 @@ } // form data and variables - let formData = [ - { - component: Input, - value: '', - props: { - label: $_('login.usernameLabel'), - type: 'email', - placeholder: $_('login.usernameLabel'), - required: true, - id: 'username', - autocomplete: 'username' - } - }, - { - component: Input, - value: '', - props: { - label: $_('login.passwordLabel'), - type: 'password', - placeholder: $_('login.passwordLabel'), - required: true, - id: 'password', - autocomplete: 'password' - } - } - ]; + let username: string = ''; + let password: string = ''; let remember: boolean = false; let showAlert: boolean = false; let alertMessage: string = $_('login.badCredentials'); @@ -109,24 +87,37 @@ > - {#each formData as element} - + + +
+
+ + - {/each} +
@@ -135,7 +126,7 @@ Not registered? Create account diff --git a/frontend/src/lib/components/UserRegistration.svelte b/frontend/src/lib/components/UserRegistration.svelte index a1c69e5e..94eb851f 100644 --- a/frontend/src/lib/components/UserRegistration.svelte +++ b/frontend/src/lib/components/UserRegistration.svelte @@ -3,30 +3,27 @@ import { registerRegister } from '$lib/client/services.gen'; import { type RegisterRegisterData } from '$lib/client/types.gen'; import AlertMessage from '$lib/components/AlertMessage.svelte'; - import DataInput from '$lib/components/DataInput/DataInput.svelte'; import UserVerify from '$lib/components/UserVerify.svelte'; import { preventDefault } from '$lib/util'; - import { Button, Card, Heading, Input, Select } from 'flowbite-svelte'; + import { Button, Card, Heading, Input, Label, Select } from 'flowbite-svelte'; import { _ } from 'svelte-i18n'; + // FIXME: try and simplify this further async function submitData(): Promise { - const equalPW = data[1].value !== '' && data[2].value === data[1].value; + const equalPW = password !== '' && password === passwordconfirm; const userData: RegisterRegisterData = { body: { - email: '', - password: '', - is_active: false, + email: email, + password: password, + is_active: true, is_superuser: false, is_researcher: false } }; if (equalPW) { - userData.body.email = data[0].value; - userData.body.password = data[1].value; - userData.body.is_researcher = data[3].value === $_('registration.researcherRole'); - userData.body.is_superuser = data[3].value === $_('registration.adminRole'); - userData.body.is_active = true; + userData.body.is_researcher = role === $_('registration.researcherRole'); + userData.body.is_superuser = role === $_('registration.adminRole'); const result = await registerRegister(userData); @@ -38,69 +35,16 @@ console.log('successful transmission: ', result.response.status); success = true; } - data.forEach((element) => { - element.value = ''; - }); } else { showAlert = true; alertMessage = $_('registration.alertMessagePasswords'); } } - const data = [ - { - component: Input, - props: { - label: $_('registration.emailLabel'), - type: 'email', - placeholder: $_('registration.emailLabel'), - required: true, - id: 'email' - }, - value: '' - }, - { - component: Input, - props: { - label: $_('registration.passwordLabel'), - type: 'password', - placeholder: $_('registration.passwordLabel'), - required: true, - id: 'password' - }, - value: '' - }, - { - component: Input, - props: { - label: $_('registration.passwordConfirmLabel'), - type: 'password', - placeholder: $_('registration.passwordConfirmLabel'), - required: true, - id: 'passwordConfirm' - }, - value: '' - }, - { - component: Select, - props: { - label: $_('registration.role'), - type: 'text', - placeholder: $_('registration.selectPlaceholder'), - required: true, - id: 'role', - items: [ - $_('registration.observerRole'), - $_('registration.researcherRole'), - $_('registration.adminRole') - ].map((v) => { - return { name: String(v), value: v }; - }) - }, - value: $_('registration.observerRole') - } - ]; - + let email: string = ''; + let password: string = ''; + let passwordconfirm: string = ''; + let role: string = $_('registration.observerRole'); let showAlert: boolean = false; let success: boolean = false; let alertMessage = $_('registration.alertMessageMissing'); @@ -129,23 +73,67 @@ {#if success === false}
- {#each data as element, i} - {$_('registration.emailLabel')} +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+