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
90cca332
Commit
90cca332
authored
Mar 18, 2020
by
Gladys Forte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{devbugfix} report serializer fix, asset_type restore, archived
parent
78f4c9a5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
10 deletions
+76
-10
app/applicationlayer/ams/asset_type/views.py
app/applicationlayer/ams/asset_type/views.py
+50
-3
app/applicationlayer/ams/report/serializers.py
app/applicationlayer/ams/report/serializers.py
+2
-2
app/applicationlayer/ams/report/views.py
app/applicationlayer/ams/report/views.py
+0
-1
app/applicationlayer/ams/report_type/serializers.py
app/applicationlayer/ams/report_type/serializers.py
+1
-1
app/applicationlayer/ams/report_type/views.py
app/applicationlayer/ams/report_type/views.py
+2
-3
app/entities/enums.py
app/entities/enums.py
+3
-0
app/entities/migrations/0009_auto_20200318_1724.py
app/entities/migrations/0009_auto_20200318_1724.py
+18
-0
No files found.
app/applicationlayer/ams/asset_type/views.py
View file @
90cca332
...
@@ -12,6 +12,9 @@ from app.applicationlayer.utils import (
...
@@ -12,6 +12,9 @@ from app.applicationlayer.utils import (
from
app.helper
import
decorators
from
app.helper
import
decorators
from
django.db
import
transaction
from
django.db
import
transaction
from
rest_framework.decorators
import
action
from
rest_framework.decorators
import
action
from
app.applicationlayer.utils
import
model_to_dict
from
app.applicationlayer.utils
import
log_save
from
app.entities
import
enums
class
AssetTypeViewset
(
viewsets
.
ModelViewSet
):
class
AssetTypeViewset
(
viewsets
.
ModelViewSet
):
...
@@ -31,6 +34,15 @@ class AssetTypeViewset(viewsets.ModelViewSet):
...
@@ -31,6 +34,15 @@ class AssetTypeViewset(viewsets.ModelViewSet):
serializer
=
self
.
get_serializer
(
data
=
request
.
data
)
serializer
=
self
.
get_serializer
(
data
=
request
.
data
)
# serializer.is_valid(raise_exception=True)
# serializer.is_valid(raise_exception=True)
# if requestor == poc:
# message = {
# 'code': 400,
# 'status': 'failed',
# 'message': 'Cannot assign same user on point of contact and requestor',
# }
# return Response(message, status=status.HTTP_400_BAD_REQUEST)
if
serializer
.
is_valid
(
raise_exception
=
True
):
if
serializer
.
is_valid
(
raise_exception
=
True
):
serializer
.
save
(
created_by
=
self
.
request
.
user
)
serializer
.
save
(
created_by
=
self
.
request
.
user
)
self
.
perform_create
(
serializer
)
self
.
perform_create
(
serializer
)
...
@@ -86,9 +98,19 @@ class AssetTypeViewset(viewsets.ModelViewSet):
...
@@ -86,9 +98,19 @@ class AssetTypeViewset(viewsets.ModelViewSet):
@
transaction
.
atomic
@
transaction
.
atomic
def
destroy
(
self
,
request
,
*
args
,
**
kwargs
):
def
destroy
(
self
,
request
,
*
args
,
**
kwargs
):
instance
=
self
.
get_object
()
instance
=
self
.
get_object
()
self
.
perform_destroy
(
instance
)
instance
.
is_active
=
False
instance
.
save
()
# new_instance = model_to_dict(instance)
# log_save(
# enums.LogEnum.DELETED.value,
# enums.LogEntitiesEnum.,
# new_instance['id'],
# new_instance,
# ''
# )
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
...
@@ -120,4 +142,29 @@ class AssetTypeViewset(viewsets.ModelViewSet):
...
@@ -120,4 +142,29 @@ class AssetTypeViewset(viewsets.ModelViewSet):
return
Response
(
return
Response
(
serializer
.
data
,
serializer
.
data
,
status
=
status
.
HTTP_200_OK
status
=
status
.
HTTP_200_OK
)
)
\ No newline at end of file
#restore archived asset_type
def
partial_update
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
kwargs
[
'partial'
]
=
True
code
=
self
.
kwargs
[
'code'
]
instance
=
models
.
AMSAssetType
.
objects
.
filter
(
code
=
code
)
instance
.
update
(
is_active
=
True
)
message
=
status_message_response
(
200
,
'success'
,
'Archived Asset Type restored'
,
''
)
return
Response
(
message
,
status
=
status
.
HTTP_200_OK
)
except
Exception
as
e
:
message
=
status_message_response
(
500
,
'failed'
,
'Request was not able to process'
+
str
(
e
),
[]
)
return
Response
(
message
,
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
\ No newline at end of file
app/applicationlayer/ams/report/serializers.py
View file @
90cca332
...
@@ -7,13 +7,13 @@ class AMSReportSerializer(serializers.ModelSerializer):
...
@@ -7,13 +7,13 @@ class AMSReportSerializer(serializers.ModelSerializer):
def
to_representation
(
self
,
instance
):
def
to_representation
(
self
,
instance
):
ret
=
super
()
.
to_representation
(
instance
)
ret
=
super
()
.
to_representation
(
instance
)
ret
[
'
add
ed_by'
]
=
instance
.
created_by
.
name
ret
[
'
creat
ed_by'
]
=
instance
.
created_by
.
name
ret
[
'report_type'
]
=
instance
.
report_type
.
name
ret
[
'report_type'
]
=
instance
.
report_type
.
name
ret
[
'unique_identifier'
]
=
instance
.
asset_stock
.
unique_identifier
ret
[
'unique_identifier'
]
=
instance
.
asset_stock
.
unique_identifier
ret
[
'asset'
]
=
instance
.
asset_stock
.
asset
.
name
ret
[
'asset'
]
=
instance
.
asset_stock
.
asset
.
name
ret
[
'asset_type'
]
=
instance
.
asset_stock
.
asset
.
asset_type
.
name
ret
[
'asset_type'
]
=
instance
.
asset_stock
.
asset
.
asset_type
.
name
del
ret
[
'asset_stock'
]
del
ret
[
'asset_stock'
]
del
ret
[
'created_by'
]
return
ret
return
ret
class
Meta
:
class
Meta
:
...
...
app/applicationlayer/ams/report/views.py
View file @
90cca332
...
@@ -172,7 +172,6 @@ class AMSReportViewset(viewsets.ModelViewSet):
...
@@ -172,7 +172,6 @@ class AMSReportViewset(viewsets.ModelViewSet):
instance
.
save
()
instance
.
save
()
new_instance
=
model_to_dict
(
instance
)
new_instance
=
model_to_dict
(
instance
)
log_save
(
log_save
(
enums
.
LogEnum
.
UPDATE
.
value
,
enums
.
LogEnum
.
UPDATE
.
value
,
enums
.
LogEntitiesEnum
.
AMSReport
.
value
,
enums
.
LogEntitiesEnum
.
AMSReport
.
value
,
...
...
app/applicationlayer/ams/report_type/serializers.py
View file @
90cca332
...
@@ -7,7 +7,7 @@ class AMSReportTypeSerializer(serializers.ModelSerializer):
...
@@ -7,7 +7,7 @@ class AMSReportTypeSerializer(serializers.ModelSerializer):
def
to_representation
(
self
,
instance
):
def
to_representation
(
self
,
instance
):
ret
=
super
()
.
to_representation
(
instance
)
ret
=
super
()
.
to_representation
(
instance
)
ret
[
'
add
ed_by'
]
=
instance
.
created_by
.
name
ret
[
'
creat
ed_by'
]
=
instance
.
created_by
.
name
return
ret
return
ret
class
Meta
:
class
Meta
:
...
...
app/applicationlayer/ams/report_type/views.py
View file @
90cca332
...
@@ -81,11 +81,10 @@ class AMSReportTypeViewset(viewsets.ModelViewSet):
...
@@ -81,11 +81,10 @@ class AMSReportTypeViewset(viewsets.ModelViewSet):
status
=
status
.
HTTP_400_BAD_REQUEST
status
=
status
.
HTTP_400_BAD_REQUEST
)
)
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
queryset
=
self
.
filter_queryset
(
self
.
get_queryset
()
)
.
filter
(
is_active
=
True
)
queryset
=
self
.
filter_queryset
(
self
.
queryset
)
.
filter
(
is_active
=
True
)
page
=
self
.
paginate_queryset
(
queryset
)
page
=
self
.
paginate_queryset
(
queryset
)
if
page
is
not
None
:
if
page
is
not
None
:
...
...
app/entities/enums.py
View file @
90cca332
...
@@ -81,6 +81,9 @@ class LogEntitiesEnum(Enum):
...
@@ -81,6 +81,9 @@ class LogEntitiesEnum(Enum):
AMSAsset
=
'AMSAsset'
AMSAsset
=
'AMSAsset'
AMSAssetStock
=
'AMSAssetStock'
AMSAssetStock
=
'AMSAssetStock'
AMSAssetStockSupport
=
'AMSAssetStockSupport'
AMSAssetStockSupport
=
'AMSAssetStockSupport'
AMSAssetType
=
'AMSAssetType'
AMSAssetGroup
=
'AMSAssetGroup'
'''
'''
*********
*********
...
...
app/entities/migrations/0009_auto_20200318_1724.py
0 → 100644
View file @
90cca332
# Generated by Django 2.2 on 2020-03-18 17:24
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'entities'
,
'0008_auto_20200318_1545'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'entitylog'
,
name
=
'entity'
,
field
=
models
.
CharField
(
choices
=
[(
'USER'
,
'USER'
),
(
'APPLICATION'
,
'APPLICATION'
),
(
'COMPANY'
,
'COMPANY'
),
(
'DEPARTMENT'
,
'DEPARTMENT'
),
(
'MODULE'
,
'MODULE'
),
(
'DELEGATION'
,
'DELEGATION'
),
(
'ChangeRequestTemplateHeader'
,
'ChangeRequestTemplateHeader'
),
(
'ChangeRequestTemplateApprovers'
,
'ChangeRequestTemplateApprovers'
),
(
'ChangeRequestTemplateStakeHolders'
,
'ChangeRequestTemplateStakeHolders'
),
(
'ChangeRequestTemplateAttachments'
,
'ChangeRequestTemplateAttachments'
),
(
'ChangeRequestTemplateDetails'
,
'ChangeRequestTemplateDetails'
),
(
'ChangeRequestFormHeader'
,
'ChangeRequestFormHeader'
),
(
'ChangeRequestFormApprovers'
,
'ChangeRequestFormApprovers'
),
(
'ChangeRequestFormStakeHolders'
,
'ChangeRequestFormStakeHolders'
),
(
'ChangeRequestFormAttachments'
,
'ChangeRequestFormAttachments'
),
(
'ChangeRequestFormDetails'
,
'ChangeRequestFormDetails'
),
(
'ChangeRequestSettings'
,
'ChangeRequestSettings'
),
(
'AMSReportType'
,
'AMSReportType'
),
(
'AMSReport'
,
'AMSReport'
),
(
'AMSAsset'
,
'AMSAsset'
),
(
'AMSAssetStock'
,
'AMSAssetStock'
),
(
'AMSAssetStockSupport'
,
'AMSAssetStockSupport'
),
(
'AMSAssetType'
,
'AMSAssetType'
),
(
'AMSAssetGroup'
,
'AMSAssetGroup'
)],
default
=
'Add'
,
max_length
=
50
),
),
]
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