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
3b947b48
Commit
3b947b48
authored
Oct 08, 2019
by
John Red Medrano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code refactor on class rms at decorators
parent
63a74211
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
36 deletions
+24
-36
app/applicationlayer/management/application/views.py
app/applicationlayer/management/application/views.py
+3
-0
app/applicationlayer/management/company/views.py
app/applicationlayer/management/company/views.py
+1
-0
app/applicationlayer/management/module/views.py
app/applicationlayer/management/module/views.py
+2
-1
app/helper/decorators.py
app/helper/decorators.py
+18
-35
No files found.
app/applicationlayer/management/application/views.py
View file @
3b947b48
...
...
@@ -25,6 +25,8 @@ class ApplicationViewSet(viewsets.ModelViewSet):
ordering_fields
=
'__all__'
search_fields
=
(
'name'
,
'code'
)
@
decorators
.
rms
.
application_crate
@
transaction
.
atomic
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
@@ -79,6 +81,7 @@ class ApplicationViewSet(viewsets.ModelViewSet):
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
@
decorators
.
rms
.
application_crate
@
transaction
.
atomic
def
update
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
app/applicationlayer/management/company/views.py
View file @
3b947b48
...
...
@@ -79,6 +79,7 @@ class CompanyViewSet(viewsets.ModelViewSet):
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
@
decorators
.
rms
.
company_crate
@
transaction
.
atomic
def
update
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
app/applicationlayer/management/module/views.py
View file @
3b947b48
...
...
@@ -33,6 +33,7 @@ class ModuleViewSet(viewsets.ModelViewSet):
'code'
,
'component'
,
'sort_id'
)
@
decorators
.
rms
.
module_crate
@
transaction
.
atomic
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
@@ -84,7 +85,7 @@ class ModuleViewSet(viewsets.ModelViewSet):
serializer
=
self
.
get_serializer
(
queryset
,
many
=
True
)
return
Response
(
serializer
.
data
)
@
decorators
.
rms
.
application_crate
@
transaction
.
atomic
def
update
(
self
,
request
,
*
args
,
**
kwargs
):
partial
=
kwargs
.
pop
(
'partial'
,
False
)
...
...
app/helper/decorators.py
View file @
3b947b48
...
...
@@ -51,22 +51,11 @@ class rms:
def
user_type
(
self
):
return
rms
.
user
(
self
)
.
user_type
# @staticmethod
# def user_delete(function):
# @wraps(function)
# def wrapper(self, request, *args, **kwargs):
# return function(self, request, *args, **kwargs)
# return wrapper
@
staticmethod
def
admin_permission
(
function
):
@
wraps
(
function
)
def
wrapper
(
self
,
request
,
*
args
,
**
kwargs
):
if
rms
.
user_type
(
self
)
==
rms
.
enums_user
:
raise
ParseError
(
access_error
)
return
function
(
self
,
request
,
*
args
,
**
kwargs
)
return
wrapper
def
superuser_create
(
self
):
if
rms
.
user_type
(
self
)
!=
rms
.
enums_super
:
raise
ParseError
(
rms
.
access_error
)
else
:
return
True
@
staticmethod
def
user_create
(
function
):
...
...
@@ -102,7 +91,8 @@ class rms:
rms
.
access_error
)
elif
rms
.
user_type
(
self
)
==
rms
.
enums_department
:
if
request
.
user
.
department
.
code
!=
rms
.
user
(
self
)
.
department
.
code
:
instance
=
self
.
get_object
()
if
rms
.
user
(
self
)
.
department
.
code
!=
instance
.
department
.
code
:
raise
ParseError
(
rms
.
department_error
)
...
...
@@ -122,10 +112,7 @@ class rms:
def
company_crate
(
function
):
@
wraps
(
function
)
def
wrapper
(
self
,
request
,
*
args
,
**
kwargs
):
if
rms
.
user_type
(
self
)
!=
rms
.
enums_super
:
raise
ParseError
(
rms
.
access_error
)
rms
.
superuser_create
(
self
)
return
function
(
self
,
request
,
*
args
,
**
kwargs
)
return
wrapper
...
...
@@ -133,16 +120,7 @@ class rms:
def
department_crate
(
function
):
@
wraps
(
function
)
def
wrapper
(
self
,
request
,
*
args
,
**
kwargs
):
# if rms.user_type(self) == rms.enums_super:
# pass
# elif rms.user_type(self) != rms.enums_super or rms.user_type(self) != rms.enums_company:
# raise ParseError(
# rms.access_error
# )
if
rms
.
user_type
(
self
)
!=
rms
.
enums_super
:
raise
ParseError
(
rms
.
access_error
)
rms
.
superuser_create
(
self
)
return
function
(
self
,
request
,
*
args
,
**
kwargs
)
return
wrapper
...
...
@@ -150,10 +128,15 @@ class rms:
def
application_crate
(
function
):
@
wraps
(
function
)
def
wrapper
(
self
,
request
,
*
args
,
**
kwargs
):
if
rms
.
user_type
(
self
)
!=
rms
.
enums_super
:
raise
ParseError
(
rms
.
access_error
)
rms
.
superuser_create
(
self
)
return
function
(
self
,
request
,
*
args
,
**
kwargs
)
return
wrapper
@
staticmethod
def
module_crate
(
function
):
@
wraps
(
function
)
def
wrapper
(
self
,
request
,
*
args
,
**
kwargs
):
rms
.
superuser_create
(
self
)
return
function
(
self
,
request
,
*
args
,
**
kwargs
)
return
wrapper
...
...
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