Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
18599add
Commit
18599add
authored
3 years ago
by
Ramesh Kumar
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into
TMSS-841
parents
57b881ef
88d217ed
No related branches found
No related tags found
3 merge requests
!634
WIP: COBALT commissioning delta
,
!510
Resolves TMSS-841
,
!481
Draft: SW-971 SW-973 SW-975: Various fixes to build LOFAR correctly.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/backend/src/tmss/tmssapp/viewsets/lofar_viewset.py
+19
-2
19 additions, 2 deletions
SAS/TMSS/backend/src/tmss/tmssapp/viewsets/lofar_viewset.py
SAS/TMSS/backend/src/tmss/tmssapp/viewsets/permissions.py
+2
-2
2 additions, 2 deletions
SAS/TMSS/backend/src/tmss/tmssapp/viewsets/permissions.py
with
21 additions
and
4 deletions
SAS/TMSS/backend/src/tmss/tmssapp/viewsets/lofar_viewset.py
+
19
−
2
View file @
18599add
...
...
@@ -55,9 +55,23 @@ class LOFARViewSet(viewsets.ModelViewSet):
filter_fields
=
'
__all__
'
ordering_fields
=
'
__all__
'
def
_get_permitted_methods
(
self
,
request
):
# Django returns an "Allow" header that reflects what methods the model supports in principle, but not what
# the current user is actually has permission to perform. We use the "Access-Control-Allow-Methods" header
# to disclose read/write permission to the frontend, so that it can render its views accordingly.
allowed_methods
=
[]
for
method
in
[
'
GET
'
,
'
POST
'
,
'
PUT
'
,
'
PATCH
'
,
'
DELETE
'
]:
request
.
method
=
method
if
TMSSPermissions
().
has_permission
(
request
=
request
,
view
=
self
):
allowed_methods
.
append
(
method
)
return
allowed_methods
@swagger_auto_schema
(
responses
=
{
403
:
'
forbidden
'
})
def
list
(
self
,
request
,
**
kwargs
):
return
super
(
LOFARViewSet
,
self
).
list
(
request
,
**
kwargs
)
response
=
super
(
LOFARViewSet
,
self
).
list
(
request
,
**
kwargs
)
if
"
Access-Control-Allow-Methods
"
not
in
response
:
response
[
"
Access-Control-Allow-Methods
"
]
=
"
,
"
.
join
(
self
.
_get_permitted_methods
(
request
))
return
response
@swagger_auto_schema
(
responses
=
{
400
:
'
invalid specification
'
,
403
:
'
forbidden
'
})
def
create
(
self
,
request
,
**
kwargs
):
...
...
@@ -65,7 +79,10 @@ class LOFARViewSet(viewsets.ModelViewSet):
@swagger_auto_schema
(
responses
=
{
403
:
'
forbidden
'
,
404
:
'
not found
'
})
def
retrieve
(
self
,
request
,
pk
=
None
,
**
kwargs
):
return
super
(
LOFARViewSet
,
self
).
retrieve
(
request
,
pk
,
**
kwargs
)
response
=
super
(
LOFARViewSet
,
self
).
retrieve
(
request
,
pk
,
**
kwargs
)
if
"
Access-Control-Allow-Methods
"
not
in
response
:
response
[
"
Access-Control-Allow-Methods
"
]
=
"
,
"
.
join
(
self
.
_get_permitted_methods
(
request
))
return
response
@swagger_auto_schema
(
responses
=
{
400
:
'
invalid specification
'
,
403
:
'
forbidden
'
,
404
:
'
not found
'
})
def
update
(
self
,
request
,
pk
=
None
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
SAS/TMSS/backend/src/tmss/tmssapp/viewsets/permissions.py
+
2
−
2
View file @
18599add
...
...
@@ -34,8 +34,8 @@ def get_project_roles_for_user(user):
try
:
return
tuple
(
user
.
project_roles
)
except
AttributeError
:
# the user is a non-TMSSUser, for example anonyous/not-logged-in
except
(
AttributeError
,
TypeError
)
:
# the user is a non-TMSSUser, for example anonyous/not-logged-in
, or project_roles are None
# return empty project roles
return
tuple
()
...
...
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