Skip to content
GitLab
Explore
Sign in
Register
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
087333d9
Commit
087333d9
authored
4 years ago
by
Mario Raciti
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-521
: Refactoring and code clean up
parent
a875b0e5
No related branches found
No related tags found
1 merge request
!327
Resolve TMSS-521
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/src/tmss/tmssapp/views.py
+4
-23
4 additions, 23 deletions
SAS/TMSS/src/tmss/tmssapp/views.py
SAS/TMSS/src/tmss/urls.py
+2
-3
2 additions, 3 deletions
SAS/TMSS/src/tmss/urls.py
with
6 additions
and
26 deletions
SAS/TMSS/src/tmss/tmssapp/views.py
+
4
−
23
View file @
087333d9
...
...
@@ -8,6 +8,7 @@ from lofar.common.datetimeutils import formatDatetime
from
lofar.sas.tmss.tmss.tmssapp.adapters.parset
import
convert_to_parset
from
drf_yasg.utils
import
swagger_auto_schema
from
drf_yasg.openapi
import
Parameter
from
rest_framework.authtoken.models
import
Token
from
rest_framework.permissions
import
AllowAny
from
rest_framework.decorators
import
authentication_classes
,
permission_classes
from
django.apps
import
apps
...
...
@@ -44,32 +45,12 @@ def index(request):
#return render(request, "../../../frontend/frontend_poc/build/index.html")
from
django.contrib.auth
import
authenticate
,
login
from
django.contrib.auth.views
import
LoginView
as
LiW
class
LoginView
(
LiW
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
username
=
request
.
POST
[
'
username
'
]
password
=
request
.
POST
[
'
password
'
]
user
=
authenticate
(
request
,
username
=
username
,
password
=
password
)
if
user
is
not
None
:
# TODO: Keep this view or not? We provide a proof of auth to frontend with DRF TokenAuthentication: POST /token-auth/
auth
=
login
(
request
,
user
)
return
HttpResponse
(
'
Success!
'
,
content_type
=
'
text/plain
'
)
else
:
return
HttpResponse
(
'
Invalid credentials!
'
,
content_type
=
'
text/plain
'
)
from
django.contrib.auth
import
logout
from
rest_framework.authtoken.models
import
Token
# TODO: Deal with CSRF
def
token_deauth
(
request
,
*
args
,
**
kwargs
):
@api_view
([
'
DELETE
'
])
def
revoke_token_deauth
(
request
,
*
args
,
**
kwargs
):
token
=
request
.
META
[
'
HTTP_AUTHORIZATION
'
].
split
(
"
"
)[
1
]
# FIXME: request.user is None, need to find out a way to link token with user (Token.objects.filter(key=token, user=requests.user)
invalidate_token
=
Token
.
objects
.
filter
(
key
=
token
)
invalidate_token
.
delete
()
# logout(request)
return
HttpResponse
(
'
Success logout!
'
,
content_type
=
'
text/plain
'
)
return
HttpResponse
(
status
=
204
)
def
task_specify_observation
(
request
,
pk
=
None
):
...
...
This diff is collapsed.
Click to expand it.
SAS/TMSS/src/tmss/urls.py
+
2
−
3
View file @
087333d9
...
...
@@ -57,10 +57,9 @@ swagger_schema_view = get_schema_view(
# use re_path(r'<...>/?') to make trailing slash optional (double entries confuse Swagger)
urlpatterns
=
[
path
(
'
admin/
'
,
admin
.
site
.
urls
),
path
(
'
login/
'
,
views
.
LoginView
.
as_view
(),
name
=
'
login
'
),
path
(
'
logout/
'
,
LogoutView
.
as_view
(),
name
=
'
logout
'
),
path
(
'
token-auth/
'
,
obtain_auth_token
,
name
=
'
token-auth
'
),
path
(
'
token-deauth/
'
,
views
.
token_deauth
,
name
=
'
token-deauth
'
),
path
(
'
token-auth/
'
,
obtain_auth_token
,
name
=
'
obtain-
token-auth
'
),
path
(
'
token-deauth/
'
,
views
.
revoke_
token_deauth
,
name
=
'
revoke-
token-deauth
'
),
path
(
'
docs/
'
,
include_docs_urls
(
title
=
'
TMSS API
'
)),
re_path
(
r
'
^swagger(?P<format>\.json|\.yaml)$
'
,
swagger_schema_view
.
without_ui
(
cache_timeout
=
0
),
name
=
'
schema-json
'
),
path
(
'
swagger/
'
,
swagger_schema_view
.
with_ui
(
'
swagger
'
,
cache_timeout
=
0
),
name
=
'
schema-swagger-ui
'
),
...
...
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