Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Rex Dri
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
32
Issues
32
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rex Dri
Rex Dri
Commits
1bae06b2
Commit
1bae06b2
authored
Mar 03, 2019
by
Florent Chehab
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Standardized serverModerationStatus in the backend
not perfect but will do the trick for now
parent
5b3e318f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
6 deletions
+42
-6
backend/backend_app/admin.py
backend/backend_app/admin.py
+2
-0
backend/backend_app/other_viewsets.py
backend/backend_app/other_viewsets.py
+22
-0
backend/backend_app/permissions/__list_user_post_permission.py
...nd/backend_app/permissions/__list_user_post_permission.py
+4
-0
backend/backend_app/urls.py
backend/backend_app/urls.py
+7
-6
backend/backend_app/utils/__get_model_config.py
backend/backend_app/utils/__get_model_config.py
+2
-0
shared/api_config.yml
shared/api_config.yml
+5
-0
No files found.
backend/backend_app/admin.py
View file @
1bae06b2
...
...
@@ -15,6 +15,8 @@ CLASSIC_MODELS = []
# Go through the API configuraion
for
entry
in
api_config
:
if
"is_api_view"
in
entry
and
entry
[
"is_api_view"
]:
continue
if
"model"
in
entry
and
entry
[
"model"
]:
model_obj
=
DotMap
(
entry
)
if
(
not
model_obj
.
requires_testing
)
and
(
not
model_obj
.
ignore_in_admin
):
...
...
backend/backend_app/
view
s.py
→
backend/backend_app/
other_viewset
s.py
View file @
1bae06b2
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
backend_app.utils
import
get_viewset_permissions
from
django.conf
import
settings
from
django.http
import
HttpResponse
import
json
from
shared
import
OBJ_MODERATION_PERMISSIONS
def
app_moderation_status
(
request
):
return
HttpResponse
(
json
.
dumps
(
class
AppModerationStatusViewSet
(
APIView
):
"""
"""
permission_classes
=
get_viewset_permissions
(
"AppModerationStatusViewSet"
)
def
get
(
self
,
request
):
return
Response
(
{
"activated"
:
settings
.
MODERATION_ACTIVATED
,
"moderator_level"
:
OBJ_MODERATION_PERMISSIONS
[
"moderator"
],
}
)
)
backend/backend_app/permissions/__list_user_post_permission.py
View file @
1bae06b2
...
...
@@ -10,6 +10,8 @@ ALL_VIEWSETS = {}
for
model
in
api_config
:
model
=
DotMap
(
model
)
if
"is_api_view"
in
model
and
model
.
is_api_view
:
continue
if
not
model
.
requires_testing
:
if
model
.
viewset
!=
"UserDataViewSet"
:
module
=
importlib
.
import_module
(
...
...
@@ -20,6 +22,8 @@ for model in api_config:
if
settings
.
TESTING
:
for
model
in
api_config
:
model
=
DotMap
(
model
)
if
"is_api_view"
in
model
and
model
.
is_api_view
:
continue
if
model
.
requires_testing
:
if
model
.
viewset
!=
"UserDataViewSet"
:
module
=
importlib
.
import_module
(
...
...
backend/backend_app/urls.py
View file @
1bae06b2
from
django.conf
import
settings
from
django.conf.urls
import
include
,
url
from
django.urls
import
path
from
rest_framework
import
routers
from
rest_framework.documentation
import
include_docs_urls
from
backend_app.permissions
import
DEFAULT_VIEWSET_PERMISSIONS
from
shared
import
get_api_config
from
.
import
views
from
dotmap
import
DotMap
from
.other_viewsets
import
AppModerationStatusViewSet
import
importlib
...
...
@@ -23,6 +22,8 @@ api_config = get_api_config()
for
entry
in
api_config
:
model_obj
=
DotMap
(
entry
)
if
"is_api_view"
in
model_obj
and
model_obj
.
is_api_view
:
continue
if
(
not
model_obj
.
requires_testing
)
or
(
settings
.
TESTING
and
model_obj
.
requires_testing
):
...
...
@@ -45,10 +46,10 @@ for entry in api_config:
router
.
register
(
str_url
,
Viewset
)
# Add all the endpoints for the base api
urlpatterns
+=
[
url
(
r"^api/"
,
include
(
router
.
urls
))]
# Add some custom APIs
urlpatterns
.
append
(
path
(
"api/serverModerationStatus/"
,
views
.
app_moderation_status
))
urlpatterns
+=
[
url
(
r"^api/"
,
include
(
router
.
urls
)),
url
(
r"^api/serverModerationStatus/"
,
AppModerationStatusViewSet
.
as_view
()),
]
#######
# Models and Viewset checks
...
...
backend/backend_app/utils/__get_model_config.py
View file @
1bae06b2
...
...
@@ -5,6 +5,8 @@ def get_model_config(model):
api_config
=
get_api_config
()
for
obj
in
api_config
:
if
"is_api_view"
in
obj
and
obj
[
"is_api_view"
]:
continue
if
obj
[
"model"
]
==
model
:
tmp
=
{
"moderation_level"
:
obj
[
"moderation_level"
],
...
...
shared/api_config.yml
View file @
1bae06b2
...
...
@@ -36,6 +36,11 @@
# - IsOwner : (or )
#
-
viewset
:
AppModerationStatusViewSet
api_end_point
:
serverModerationStatus
read_only
:
true
is_api_view
:
true
-
model
:
Country
viewset
:
CountryViewSet
import_location
:
country
...
...
Florent Chehab
@chehabfl
mentioned in issue
#18 (closed)
·
Mar 10, 2019
mentioned in issue
#18 (closed)
mentioned in issue #18
Toggle commit list
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