Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
red-ci-cd
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
red-group-test
red-ci-cd
Commits
fea7c857
Commit
fea7c857
authored
May 17, 2019
by
John Red Medrano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added group and modules key at application endpoint
parent
bc2ee4c3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
33 deletions
+58
-33
api/serializers.py
api/serializers.py
+36
-18
api/urls.py
api/urls.py
+3
-3
api/viewsets/applications.py
api/viewsets/applications.py
+18
-12
config/settings/local.py
config/settings/local.py
+1
-0
No files found.
api/serializers.py
View file @
fea7c857
import
requests
from
rest_framework
import
serializers
from
.models
import
APIService
,
APIEndpoint
,
Application
from
api.utils
import
BadRequestException
,
number_generator
from
rest_framework.exceptions
import
ValidationError
from
django.utils.crypto
import
get_random_string
from
django.conf
import
settings
ACCOUNT_GROUP
=
settings
.
ACCOUNT_GROUP
class
ApplicationSerializer
(
serializers
.
ModelSerializer
):
groups
=
serializers
.
ListField
(
read_only
=
True
)
modules
=
serializers
.
ListField
(
read_only
=
True
)
def
to_representation
(
self
,
data
):
ids
=
data
.
id
req
=
requests
.
get
(
f
'{ACCOUNT_GROUP}/{ids}/'
)
groups
=
req
.
json
()[
'groups'
]
modules
=
req
.
json
()[
'modules'
]
setattr
(
data
,
'groups'
,
groups
)
setattr
(
data
,
'modules'
,
modules
)
return
super
()
.
to_representation
(
data
)
class
Meta
:
model
=
Application
fields
=
(
'id'
,
'application_no'
,
'name'
,
'theme'
,
'created_at'
,
'updated_at'
,
'deleted_at'
)
read_only_fields
=
(
'id'
,
'application_no'
,
'created_at'
,
'updated_at'
,
'deleted_at'
)
fields
=
(
'id'
,
'application_no'
,
'name'
,
'theme'
,
'groups'
,
'modules'
)
read_only_fields
=
(
'id'
,
'application_no'
,
'created_at'
,
'updated_at'
,
'deleted_at'
)
def
is_valid
(
self
,
raise_exception
=
False
):
...
...
api/urls.py
View file @
fea7c857
...
...
@@ -8,9 +8,9 @@ from api.views import (
)
router
=
DefaultRouter
()
router
.
register
(
r'ap
i-ap
plications'
,
ApplicationViewSet
)
router
.
register
(
r'
api-
services'
,
APIServiceViewSet
)
router
.
register
(
r'
api-
endpoint'
,
APIEndpointViewSet
)
router
.
register
(
r'applications'
,
ApplicationViewSet
)
router
.
register
(
r'services'
,
APIServiceViewSet
)
router
.
register
(
r'endpoint'
,
APIEndpointViewSet
)
urlpatterns
=
[
path
(
''
,
include
(
router
.
urls
)),
...
...
api/viewsets/applications.py
View file @
fea7c857
import
requests
from
django.db.models
import
F
from
django.db.models
import
OuterRef
,
Subquery
from
django.conf
import
settings
from
rest_framework
import
viewsets
,
status
from
rest_framework.decorators
import
action
from
rest_framework.response
import
Response
...
...
@@ -7,6 +11,9 @@ from api.utils import (CustomPagination, BadRequestException,
status_message_response
)
ACCOUNT_GROUP
=
settings
.
ACCOUNT_GROUP
class
ApplicationViewSet
(
viewsets
.
ModelViewSet
):
http_method_names
=
[
'get'
,
'post'
,
'put'
,
'patch'
,
'delete'
,
'head'
,
'options'
,
'trace'
...
...
@@ -46,7 +53,6 @@ class ApplicationViewSet(viewsets.ModelViewSet):
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
queryset
=
Application
.
objects
.
filter
(
deleted_at__exact
=
None
)
if
not
queryset
.
exists
():
message
=
status_message_response
(
200
,
'success'
,
'No records found'
,
[]
...
...
config/settings/local.py
View file @
fea7c857
...
...
@@ -33,3 +33,4 @@ AUTHENTICATOR_IP = config['SERVICE']['AUTHENTICATOR_IP']
AUTHENTICATOR_PATH
=
'/api/v1/authenticator'
VALIDATE_TOKEN_URL
=
f
'http://{AUTHENTICATOR_IP}{AUTHENTICATOR_PATH}/validate-token/'
ACCOUNT_GROUP
=
f
'http://{AUTHENTICATOR_IP}{AUTHENTICATOR_PATH}/account-dependent'
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