Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compendium-v2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
compendium-v2
Commits
43071ac8
Commit
43071ac8
authored
2 years ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
Add admin_required and login_required
parent
a8e3c050
No related branches found
No related tags found
1 merge request
!54
Feature/refactor survey frontend
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compendium_v2/routes/survey.py
+11
-7
11 additions, 7 deletions
compendium_v2/routes/survey.py
with
11 additions
and
7 deletions
compendium_v2/routes/survey.py
+
11
−
7
View file @
43071ac8
...
@@ -3,6 +3,7 @@ from enum import Enum
...
@@ -3,6 +3,7 @@ from enum import Enum
from
typing
import
Any
,
TypedDict
,
List
,
Dict
from
typing
import
Any
,
TypedDict
,
List
,
Dict
from
flask
import
Blueprint
,
jsonify
,
request
from
flask
import
Blueprint
,
jsonify
,
request
from
flask_login
import
login_required
from
sqlalchemy
import
select
from
sqlalchemy
import
select
from
sqlalchemy.orm
import
joinedload
,
load_only
from
sqlalchemy.orm
import
joinedload
,
load_only
...
@@ -10,6 +11,7 @@ from compendium_v2.db import db
...
@@ -10,6 +11,7 @@ from compendium_v2.db import db
from
compendium_v2.db.model
import
NREN
from
compendium_v2.db.model
import
NREN
from
compendium_v2.db.survey_model
import
Survey
,
SurveyResponse
,
SurveyStatus
,
ResponseStatus
from
compendium_v2.db.survey_model
import
Survey
,
SurveyResponse
,
SurveyStatus
,
ResponseStatus
from
compendium_v2.routes
import
common
from
compendium_v2.routes
import
common
from
compendium_v2.auth.session_management
import
admin_required
routes
=
Blueprint
(
'
survey
'
,
__name__
)
routes
=
Blueprint
(
'
survey
'
,
__name__
)
...
@@ -66,9 +68,9 @@ class VerificationStatus(str, Enum):
...
@@ -66,9 +68,9 @@ class VerificationStatus(str, Enum):
Edited
=
"
edited
"
# a question for which last years answer was edited
Edited
=
"
edited
"
# a question for which last years answer was edited
# TODO admin only
@routes.route
(
'
/list
'
,
methods
=
[
'
GET
'
])
@routes.route
(
'
/list
'
,
methods
=
[
'
GET
'
])
@common.require_accepts_json
@common.require_accepts_json
@admin_required
def
list_surveys
()
->
Any
:
def
list_surveys
()
->
Any
:
"""
"""
retrieve a list of surveys and responses, including their status
retrieve a list of surveys and responses, including their status
...
@@ -119,9 +121,9 @@ def list_surveys() -> Any:
...
@@ -119,9 +121,9 @@ def list_surveys() -> Any:
return
jsonify
(
entries
)
return
jsonify
(
entries
)
# TODO admin only
@routes.route
(
'
/new
'
,
methods
=
[
'
POST
'
])
@routes.route
(
'
/new
'
,
methods
=
[
'
POST
'
])
@common.require_accepts_json
@common.require_accepts_json
@admin_required
def
start_new_survey
()
->
Any
:
def
start_new_survey
()
->
Any
:
"""
"""
endpoint to initiate a new survey
endpoint to initiate a new survey
...
@@ -148,9 +150,9 @@ def start_new_survey() -> Any:
...
@@ -148,9 +150,9 @@ def start_new_survey() -> Any:
return
{
'
success
'
:
True
}
return
{
'
success
'
:
True
}
# TODO admin only
@routes.route
(
'
/open/<int:year>
'
,
methods
=
[
'
POST
'
])
@routes.route
(
'
/open/<int:year>
'
,
methods
=
[
'
POST
'
])
@common.require_accepts_json
@common.require_accepts_json
@admin_required
def
open_survey
(
year
)
->
Any
:
def
open_survey
(
year
)
->
Any
:
"""
"""
endpoint to open a survey to the nrens
endpoint to open a survey to the nrens
...
@@ -174,9 +176,9 @@ def open_survey(year) -> Any:
...
@@ -174,9 +176,9 @@ def open_survey(year) -> Any:
return
{
'
success
'
:
True
}
return
{
'
success
'
:
True
}
# TODO admin only
@routes.route
(
'
/close/<int:year>
'
,
methods
=
[
'
POST
'
])
@routes.route
(
'
/close/<int:year>
'
,
methods
=
[
'
POST
'
])
@common.require_accepts_json
@common.require_accepts_json
@admin_required
def
close_survey
(
year
)
->
Any
:
def
close_survey
(
year
)
->
Any
:
"""
"""
endpoint to close a survey to the nrens
endpoint to close a survey to the nrens
...
@@ -196,9 +198,9 @@ def close_survey(year) -> Any:
...
@@ -196,9 +198,9 @@ def close_survey(year) -> Any:
return
{
'
success
'
:
True
}
return
{
'
success
'
:
True
}
# TODO admin only
@routes.route
(
'
/publish/<int:year>
'
,
methods
=
[
'
POST
'
])
@routes.route
(
'
/publish/<int:year>
'
,
methods
=
[
'
POST
'
])
@common.require_accepts_json
@common.require_accepts_json
@admin_required
def
publish_survey
(
year
)
->
Any
:
def
publish_survey
(
year
)
->
Any
:
"""
"""
endpoint to publish a survey to the compendium website
endpoint to publish a survey to the compendium website
...
@@ -223,9 +225,9 @@ def publish_survey(year) -> Any:
...
@@ -223,9 +225,9 @@ def publish_survey(year) -> Any:
return
{
'
success
'
:
True
}
return
{
'
success
'
:
True
}
# TODO admin only
@routes.route
(
'
/try/<int:year>
'
,
methods
=
[
'
GET
'
])
@routes.route
(
'
/try/<int:year>
'
,
methods
=
[
'
GET
'
])
@common.require_accepts_json
@common.require_accepts_json
@admin_required
def
try_survey
(
year
)
->
Any
:
def
try_survey
(
year
)
->
Any
:
"""
"""
Get a survey without any associated nren for trying out the survey.
Get a survey without any associated nren for trying out the survey.
...
@@ -249,9 +251,9 @@ def try_survey(year) -> Any:
...
@@ -249,9 +251,9 @@ def try_survey(year) -> Any:
})
})
# TODO admin only
@routes.route
(
'
/inspect/<int:year>
'
,
methods
=
[
'
GET
'
])
@routes.route
(
'
/inspect/<int:year>
'
,
methods
=
[
'
GET
'
])
@common.require_accepts_json
@common.require_accepts_json
@admin_required
def
inspect_survey
(
year
)
->
Any
:
def
inspect_survey
(
year
)
->
Any
:
"""
"""
Get a survey without any associated nren for inspecting all questions.
Get a survey without any associated nren for inspecting all questions.
...
@@ -289,6 +291,7 @@ def inspect_survey(year) -> Any:
...
@@ -289,6 +291,7 @@ def inspect_survey(year) -> Any:
@routes.route
(
'
/load/<int:year>/<string:nren_name>
'
,
methods
=
[
'
GET
'
])
@routes.route
(
'
/load/<int:year>/<string:nren_name>
'
,
methods
=
[
'
GET
'
])
@common.require_accepts_json
@common.require_accepts_json
@login_required
def
load_survey
(
year
,
nren_name
)
->
Any
:
def
load_survey
(
year
,
nren_name
)
->
Any
:
"""
"""
Get a survey for an nren.
Get a survey for an nren.
...
@@ -343,6 +346,7 @@ def load_survey(year, nren_name) -> Any:
...
@@ -343,6 +346,7 @@ def load_survey(year, nren_name) -> Any:
@routes.route
(
'
/save/<int:year>/<string:nren_name>
'
,
methods
=
[
'
POST
'
])
@routes.route
(
'
/save/<int:year>/<string:nren_name>
'
,
methods
=
[
'
POST
'
])
@common.require_accepts_json
@common.require_accepts_json
@login_required
def
save_survey
(
year
,
nren_name
)
->
Any
:
def
save_survey
(
year
,
nren_name
)
->
Any
:
"""
"""
endpoint to save a survey response
endpoint to save a survey response
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment