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

Merge branch 'feature/locking_bugfixes' into 'develop'

Feature/locking bugfixes

See merge request !63
parents 9f5b9a45 5aac197c
No related branches found
No related tags found
1 merge request!63Feature/locking bugfixes
......@@ -2940,8 +2940,6 @@
"title": "Services"
}
],
"sendResultOnPageNext": true,
"showQuestionNumbers": "onPage",
"showTOC": true,
"checkErrorsMode": "onValueChanged"
}
\ No newline at end of file
This diff is collapsed.
......@@ -30,6 +30,7 @@ SURVEY_RESPONSE_SCHEMA = {
'verification_status': {'type': 'object'},
'mode': {'type': 'string'},
'status': {'type': 'string'},
'edit_allowed': {'type': 'boolean'},
},
'required': ['model', 'locked_by', 'data', 'page', 'verification_status', 'mode', 'status'],
'additionalProperties': False
......@@ -111,7 +112,8 @@ def try_survey(year) -> Any:
"page": 0,
"verification_status": {},
"mode": SurveyMode.Edit,
"status": RESPONSE_NOT_STARTED
"status": RESPONSE_NOT_STARTED,
"edit_allowed": True
}
......@@ -152,7 +154,8 @@ def inspect_survey(year) -> Any:
"page": 0,
"verification_status": {},
"mode": SurveyMode.Edit,
"status": RESPONSE_NOT_STARTED
"status": RESPONSE_NOT_STARTED,
"edit_allowed": True
}
......@@ -219,7 +222,8 @@ def load_survey(year, nren_name) -> Any:
"page": page,
"verification_status": verification_status,
"mode": SurveyMode.Display,
"status": response.status.value if response else RESPONSE_NOT_STARTED
"status": response.status.value if response else RESPONSE_NOT_STARTED,
"edit_allowed": current_user.is_admin or survey.status == SurveyStatus.open
}
......@@ -248,6 +252,9 @@ def lock_survey(year, nren_name) -> Any:
if not check_access_nren(current_user, nren):
return {'message': 'You do not have permissions to access this survey.'}, 403
if survey.status != SurveyStatus.open and not current_user.is_admin:
return {'message': 'Survey is closed'}, 400
response = db.session.scalar(
select(SurveyResponse).where(SurveyResponse.survey_year == year)
.where(SurveyResponse.nren_id == nren.id)
......
This diff is collapsed.
......@@ -58,14 +58,16 @@ function SurveyContainerComponent({ loadFrom }) {
survey.setVariable('surveyyear', year);
survey.setVariable('previousyear', parseInt(year!) - 1);
survey.showNavigationButtons = false;
survey.data = json['data'];
survey.clearIncorrectValues(true); // TODO test if this really removes all old values and such
survey.currentPageNo = json['page'];
survey.showNavigationButtons = false;
survey.showTOC = false;
survey.mode = json['mode'];
survey.lockedBy = json['locked_by'];
survey.status = json['status'];
survey.editAllowed = json['edit_allowed'];
setSurveyModel(survey);
}
......
......@@ -46,14 +46,20 @@ function SurveyNavigationComponent({ surveyModel, surveyActions, year, nren, chi
);
};
const saveAndStopEdit = 'Save and stop editing';
const save = 'Save progress';
const startEditing = 'Start editing';
const completeSurvey = 'Complete Survey';
const renderExternalNavigation = () => {
return (
<div className="survey-edit-buttons-block">
{!editing && !lockedBy && renderButton('Start editing', 'startEdit')}
{!editing && !lockedBy && surveyModel.editAllowed && renderButton(startEditing, 'startEdit')}
{!editing && lockedBy && lockedBy == loggedInUser.name && renderButton('Discard any unsaved changes and release your lock', 'releaseLock')}
{editing && (pageNo === surveyModel.visiblePages.length - 1) && renderButton('Complete Survey', 'complete')}
{editing && (pageNo === surveyModel.visiblePages.length - 1) && renderButton(completeSurvey, 'complete')}
{editing && renderButton(saveAndStopEdit, 'saveAndStopEdit')}
{editing && renderButton('Save progress', 'save')}
{editing && renderButton(save, 'save')}
{/* {(pageNo !== surveyModel.visiblePages.length - 1) && renderButton('Next Page', incrementPageNo)} */}
{/* {renderButton('Validate Page', 'validatePage')} */}
{/* {pageNo !== 0 && renderButton('Previous Page', decrementPageNo)} */}
......@@ -61,18 +67,19 @@ function SurveyNavigationComponent({ surveyModel, surveyActions, year, nren, chi
);
};
const saveAndStopEdit = 'Save and stop editing';
const _year = parseInt(year);
return (
<Container>
<Row className="survey-content">
<h2><span className="survey-title">{year} Compendium Survey </span><span className="survey-title-nren"> {nren} </span><span> - {responseStatus}</span></h2>
<p style={{marginTop: '1rem'}}>
To get started, check that nobody else from your NREN is currently working on the survey, then click “start editing” to end read-only mode.
<br />Where available, the survey questions are pre-filled with answers from the previous year. The survey asks about the past year, i.e. the {year} survey asks about data from {_year - 1} (or {_year - 1}/{year} if your NRENs financial year does not match the calendar year). You can edit the prefilled answer to provide new information, or press the “no change from previous year” button.
<br />As long as the survey remains open, any Compendium administrator from your NREN can add answers or amend existing ones, i.e. different parts of your NREN can contribute to the survey if needed.
<br />When you reach the last section of the survey (Services), you will find a “Complete Survey“ button which saves all answers in the survey and lets the Compendium team know that you wish to submit your responses. If you accidentally complete the survey before you have completed it, please contact us and we will re-open the survey for you.
To get started, click “{startEditing}” to end read-only mode. This is only possible when nobody else from your NREN is currently working on the survey.
<br />Where available, the survey questions are pre-filled with answers from the previous year. The survey asks about the past year, i.e. the {year} survey asks about data from {_year - 1} (or {_year - 1}/{year} if your NRENs financial year does not match the calendar year).
You can edit the prefilled answer to provide new information, or press the “no change from previous year” button.
<br />Press the “{save}“ or “{saveAndStopEdit}“ button to save all answers in the survey. When you reach the last section of the survey (Services), you will find a “{completeSurvey}“ button which saves all answers in the survey and lets the Compendium team know that your answers are ready to be published.
<br />As long as the survey remains open, any Compendium administrator from your NREN can add answers or amend existing ones, even after using the “{completeSurvey}“ button. Different people from your NREN can contribute to the survey if needed.
<br />Some fields require specific data, such as numerical data, valid http-addresses, and in some questions, the answer has to add up to 100%. If an answer does not fulfil the set criteria, the question will turn pink and an error message will appear. Fields can be left blank if you prefer not to answer a question.
<br />If you notice any errors after the survey was closed, please contact us for correcting those.
</p>
<p>Thank you for taking the time to fill in the {year} Compendium Survey. Any questions or requests can be sent to <a href={`mailto:Partner-Relations@geant.org`}><span>Partner-Relations@geant.org</span></a></p>
{editing && <><br /><b>Remember to click “{saveAndStopEdit}” before leaving the page.</b></>}
......@@ -83,7 +90,8 @@ function SurveyNavigationComponent({ surveyModel, surveyActions, year, nren, chi
<Row className="survey-content">
{!editing && (
<div className="survey-edit-explainer">
{!lockedBy && <span>The survey is in read-only mode; click the “Start editing“ button to start editing the answers.</span>}
{!lockedBy && surveyModel.editAllowed && <span>The survey is in read-only mode; click the “Start editing“ button to start editing the answers.</span>}
{!lockedBy && !surveyModel.editAllowed && <span>The survey is in read-only mode and can not be edited by you.</span>}
{lockedBy && lockedBy != loggedInUser.name && 'The survey is in READONLY mode and currently being edited by: ' + lockedBy + '. To start editing the survey, ask them to complete their edits.'}
{lockedBy && lockedBy == loggedInUser.name && 'The survey is in READONLY mode because you started editing in another tab, browser or device. To start editing the survey, either complete those edits or click the "Discard any unsaved changes" button.'}
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment