Skip to content
Snippets Groups Projects
Commit 287122ff authored by Remco Tukker's avatar Remco Tukker
Browse files

handle survey metadata properly

parent 5a68a352
No related branches found
No related tags found
1 merge request!49Feature/comp 219 save button
...@@ -59,7 +59,7 @@ def open_survey(nren_name) -> Any: ...@@ -59,7 +59,7 @@ def open_survey(nren_name) -> Any:
data: Optional[dict] = None data: Optional[dict] = None
page = 0 page = 0
verification_status = {"budget": VerificationStatus.Unverified, "TODO": "remove or set all to new"} verification_status = {}
response = db.session.scalar( response = db.session.scalar(
select(SurveyResponse).where(SurveyResponse.survey_year == year).where(SurveyResponse.nren_id == nren.id) select(SurveyResponse).where(SurveyResponse.survey_year == year).where(SurveyResponse.nren_id == nren.id)
...@@ -74,10 +74,8 @@ def open_survey(nren_name) -> Any: ...@@ -74,10 +74,8 @@ def open_survey(nren_name) -> Any:
verification_status = response.answers["verification_status"] verification_status = response.answers["verification_status"]
elif previous_response: elif previous_response:
# TODO add a 'migration' hook here for updating data per year # TODO add a 'migration' hook here for updating data per year
# TODO i suppose we also need to remove the data that isnt asked anymore because
# i dont think the frontend will remove it
data = previous_response.answers["data"] data = previous_response.answers["data"]
verification_status = {"budget": VerificationStatus.Unverified, "TODO": "all other questions"} verification_status = {question_name: VerificationStatus.Unverified for question_name in data.keys()}
open_survey: dict = { open_survey: dict = {
"model": survey, "model": survey,
......
...@@ -73,11 +73,11 @@ function SurveyComponent({ nrenName }) { ...@@ -73,11 +73,11 @@ function SurveyComponent({ nrenName }) {
const survey = new Model(json['model']); const survey = new Model(json['model']);
if (json['data'] !== null) { if (json['data'] !== null) {
survey.data = json['data']; survey.data = json['data'];
} survey.clearIncorrectValues(true); // TODO test if this really removes all old values and such
}
// TODO also use data and page info survey.currentPageNo = json['page'];
survey.addNavigationItem({ survey.addNavigationItem({
id: "sv-nav-compendium-complete", id: "sv-nav-compendium-complete",
...@@ -129,7 +129,7 @@ function SurveyComponent({ nrenName }) { ...@@ -129,7 +129,7 @@ function SurveyComponent({ nrenName }) {
const saveData = { const saveData = {
data: sender.data, data: sender.data,
page: 2, page: sender.currentPageNo,
verification_status: Object.fromEntries(verificationStatus.current) verification_status: Object.fromEntries(verificationStatus.current)
} }
xhr.send(JSON.stringify(saveData)); xhr.send(JSON.stringify(saveData));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment