Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Kontr 2.0
Portal API Backend
Commits
9f7d2473
Verified
Commit
9f7d2473
authored
Apr 27, 2019
by
Peter Stanko
Browse files
Checked extraction of the faculty id
parent
f457bd64
Pipeline
#31645
failed with stage
in 1 minute and 18 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
portal/rest/error_handlers.py
View file @
9f7d2473
...
...
@@ -86,3 +86,5 @@ def handle_portal_api_error(ex: PortalAPIError):
@
rest_api
.
errorhandler
(
Exception
)
def
handle_default_exception
(
ex
:
Exception
):
log
.
critical
(
f
"[ERROR] Fatal error:
{
ex
}
"
)
return
send_response
({
'message'
:
ex
}),
500
portal/rest/projects.py
View file @
9f7d2473
...
...
@@ -162,11 +162,26 @@ class ProjectTestFilesRefresh(CustomResource):
@
projects_namespace
.
param
(
'pid'
,
'Project id'
)
@
projects_namespace
.
response
(
404
,
'Course not found'
)
@
projects_namespace
.
response
(
404
,
'Project not found'
)
class
Project
TestFilesRefr
es
h
(
CustomResource
):
class
Project
WriteISMUNINot
es
(
CustomResource
):
@
jwt_required
@
access_log
@
projects_namespace
.
response
(
20
4
,
'Project
test_files update
d'
)
@
projects_namespace
.
response
(
20
0
,
'Project
is muni notepad rea
d'
)
def
get
(
self
,
cid
:
str
,
pid
:
str
):
course
=
self
.
find
.
course
(
cid
)
project
=
self
.
find
.
project
(
course
,
pid
)
user_id
=
self
.
get_query_param
(
'user_id'
,
required
=
True
)
user
=
self
.
find
.
user
(
user_id
)
# authorization
self
.
permissions
(
course
=
course
).
require
.
read_submission
()
log
.
debug
(
f
"[REST] Get is muni notes for "
f
"
{
project
.
log_name
}
by
{
self
.
client
.
log_name
}
"
)
result
=
self
.
facades
.
submissions
.
is_read_notepad
(
project
=
project
,
user
=
user
)
return
result
@
jwt_required
@
access_log
@
projects_namespace
.
response
(
200
,
'Project test_files updated'
)
def
post
(
self
,
cid
:
str
,
pid
:
str
):
course
=
self
.
find
.
course
(
cid
)
project
=
self
.
find
.
project
(
course
,
pid
)
user_id
=
self
.
get_query_param
(
'user_id'
,
required
=
True
)
...
...
portal/rest/submissions.py
View file @
9f7d2473
...
...
@@ -318,7 +318,7 @@ class SubmissionISNotes(CustomResource):
# @submissions_namespace.response(200, 'Submissions review', model=review_schema)
def
get
(
self
,
sid
:
str
):
submission
=
self
.
find
.
submission
(
sid
)
self
.
permissions
(
submission
=
submission
).
require
.
evaluate
_submission
s
()
self
.
permissions
(
submission
=
submission
).
require
.
read
_submission
()
log
.
debug
(
f
"[REST] Get IS MUNI Notepad for project
{
submission
.
project
.
name
}
"
f
" by
{
self
.
client
.
log_name
}
:
{
submission
.
log_name
}
"
)
return
self
.
facades
.
submissions
.
is_read_notepad
(
submission
=
submission
)
...
...
portal/tools/is_api_adapter.py
View file @
9f7d2473
...
...
@@ -5,6 +5,8 @@ import is_api
import
is_api.entities
from
flask
import
Flask
from
portal.service
import
errors
if
TYPE_CHECKING
:
from
portal.database
import
Course
,
Project
,
User
...
...
@@ -16,9 +18,14 @@ class IsApiWrapper:
project
:
'Project'
=
None
):
self
.
_course
=
course
or
project
.
course
self
.
_project
=
project
faculty_id
=
course
.
faculty_id
or
int
(
faculty_id
)
fac_id
=
course
.
faculty_id
try
:
if
fac_id
is
None
and
faculty_id
is
not
None
:
fac_id
=
int
(
faculty_id
)
except
Exception
as
ex
:
raise
errors
.
PortalServiceError
(
f
"Unable to extract faculty_id:
{
ex
}
"
)
self
.
_api
=
is_api
.
IsApiClient
(
domain
=
domain
,
faculty_id
=
fac
ulty
_id
,
faculty_id
=
fac_id
,
token
=
course
.
notes_access_token
,
course_code
=
course
.
codename
)
self
.
_course_info
=
None
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment