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
74c0fa76
Unverified
Commit
74c0fa76
authored
Sep 22, 2018
by
Peter Stanko
Browse files
fixes in find course
parent
59f2ce4b
Pipeline
#13271
failed with stage
in 27 minutes and 20 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
portal/rest/client.py
View file @
74c0fa76
...
...
@@ -23,6 +23,20 @@ class ClientController(CustomResource):
return
schema
.
dump
(
client
)[
0
],
200
@
clients_namespace
.
route
(
'/<string:cid>'
)
@
clients_namespace
.
param
(
'cid'
,
"Client's id"
)
@
clients_namespace
.
response
(
404
,
'Client not found'
)
class
ClientController
(
CustomResource
):
@
jwt_required
# @clients_namespace.response(200, 'Client detail', model=clients_schema)
def
get
(
self
,
cid
:
str
):
self
.
permissions
.
require
.
sysadmin_or_self
(
cid
)
client
=
self
.
rest
.
find
.
client
(
cid
)
schema
=
SCHEMAS
.
user
()
if
client
.
type
==
ClientType
.
USER
else
SCHEMAS
.
worker
()
return
schema
.
dump
(
client
)[
0
],
200
@
clients_namespace
.
route
(
'/<string:cid>/secrets'
)
@
clients_namespace
.
param
(
'wid'
,
"Client's id"
)
@
clients_namespace
.
response
(
404
,
'Client not found'
)
...
...
portal/service/find.py
View file @
74c0fa76
...
...
@@ -32,6 +32,8 @@ class FindService:
Returns: An entity instance or null if none is found
"""
instance
=
None
if
identifier
is
not
None
and
query
is
not
None
:
instance
=
query
.
first
()
if
not
instance
:
...
...
@@ -94,7 +96,7 @@ class FindService:
Returns(Course): Course entity instance
"""
query
=
self
.
_get_course
(
Course
.
query
,
identifier
)
query
=
Course
.
query
.
filter
((
Course
.
id
==
identifier
)
|
(
Course
.
codename
==
identifier
)
)
return
self
.
resource
(
resource
=
'course'
,
...
...
@@ -218,6 +220,8 @@ class FindService:
)
def
_get_course
(
self
,
query
,
course
:
Union
[
Course
,
str
]):
if
course
is
None
:
return
None
if
isinstance
(
course
,
str
):
query
=
query
.
filter
((
Course
.
id
==
course
)
|
(
Course
.
codename
==
course
))
else
:
...
...
tests/rest/test_submission.py
View file @
74c0fa76
...
...
@@ -54,13 +54,14 @@ def test_list_all_avail_for_user(rest_service, client):
def
test_list_all_avail_for_course
(
rest_service
,
client
):
course
=
rest_service
.
find
.
course
(
'testcourse1'
)
db_subm
=
Submission
.
query
.
filter
(
Project
.
course
==
course
).
all
()
db_subm
=
Submission
.
query
.
filter
(
Submission
.
course
==
course
.
id
).
all
()
response
=
utils
.
make_request
(
client
,
f
'/submissions?course=testcourse1'
,
method
=
'get'
)
assert
response
.
status_code
==
200
assert
response
.
mimetype
==
'application/json'
resp_submissions
=
utils
.
extract_data
(
response
)
assert
len
(
resp_submissions
)
==
len
(
db_subm
)
num_of_submissions
=
len
(
resp_submissions
)
assert
num_of_submissions
==
len
(
db_subm
)
def
test_list_all_avail_for_project
(
rest_service
,
client
):
...
...
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