Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
feudal
feudalBackend
Commits
70836be3
Commit
70836be3
authored
Dec 08, 2017
by
Lukas Burgey
Browse files
Add view for the services of a client
parent
924ba8d3
Changes
3
Hide whitespace changes
Inline
Side-by-side
django_backend/backend/clientapi/serializers.py
View file @
70836be3
...
@@ -32,3 +32,9 @@ class DeploymentsSerializer(serializers.Serializer):
...
@@ -32,3 +32,9 @@ class DeploymentsSerializer(serializers.Serializer):
child
=
DeploymentSerializer
()
child
=
DeploymentSerializer
()
)
)
)
)
class
ServiceSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
models
.
Service
fields
=
[
'name'
]
django_backend/backend/clientapi/urls.py
View file @
70836be3
from
django.conf.urls
import
include
,
url
from
django.conf.urls
import
url
from
rest_framework
import
routers
# from django.conf.urls import include
# from rest_framework import routers
from
.
import
views
from
.
import
views
router
=
routers
.
DefaultRouter
(
trailing_slash
=
False
)
#
router = routers.DefaultRouter(trailing_slash=False)
# router.register(
# router.register(
# r'deployments', views.ClientViewSet, base_name='deployments')
# r'deployments', views.ClientViewSet, base_name='deployments')
urlpatterns
=
[
urlpatterns
=
[
url
(
r
'^'
,
include
(
router
.
urls
)),
#
url(r'^', include(router.urls)),
url
(
r
'^deployments'
,
views
.
DeploymentsView
.
as_view
()),
url
(
r
'^deployments'
,
views
.
DeploymentsView
.
as_view
()),
url
(
r
'^services'
,
views
.
ServiceView
.
as_view
()),
]
]
django_backend/backend/clientapi/views.py
View file @
70836be3
...
@@ -4,9 +4,13 @@ from rest_framework.authentication import TokenAuthentication
...
@@ -4,9 +4,13 @@ from rest_framework.authentication import TokenAuthentication
from
.
import
serializers
,
models
from
.
import
serializers
,
models
# authentication class for the client api
authentication_classes
=
(
TokenAuthentication
,
)
# has an optional url parameter called 'all' which can be set to 'true'
class
DeploymentsView
(
generics
.
RetrieveAPIView
):
class
DeploymentsView
(
generics
.
RetrieveAPIView
):
authentication_classes
=
(
TokenA
uthentication
,)
authentication_classes
=
a
uthentication
_classes
serializer_class
=
serializers
.
DeploymentsSerializer
serializer_class
=
serializers
.
DeploymentsSerializer
def
get_object
(
self
):
def
get_object
(
self
):
...
@@ -19,3 +23,11 @@ class DeploymentsView(generics.RetrieveAPIView):
...
@@ -19,3 +23,11 @@ class DeploymentsView(generics.RetrieveAPIView):
d
=
models
.
Deployments
()
d
=
models
.
Deployments
()
d
.
services
=
self
.
request
.
user
.
site
.
clientapi_get_deployments
(
all
=
all
)
d
.
services
=
self
.
request
.
user
.
site
.
clientapi_get_deployments
(
all
=
all
)
return
d
return
d
class
ServiceView
(
generics
.
ListAPIView
):
authentication_classes
=
authentication_classes
serializer_class
=
serializers
.
ServiceSerializer
def
get_queryset
(
self
):
return
self
.
request
.
user
.
site
.
services
.
all
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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