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
7105270d
Commit
7105270d
authored
Oct 25, 2019
by
Gladys Forte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asset group
parent
606a1444
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
173 additions
and
2 deletions
+173
-2
app/applicationlayer/ams/asset_group/serializers.py
app/applicationlayer/ams/asset_group/serializers.py
+11
-0
app/applicationlayer/ams/asset_group/table_filters.py
app/applicationlayer/ams/asset_group/table_filters.py
+9
-0
app/applicationlayer/ams/asset_group/views.py
app/applicationlayer/ams/asset_group/views.py
+80
-0
app/applicationlayer/ams/urls_ams.py
app/applicationlayer/ams/urls_ams.py
+14
-0
app/entities/enums.py
app/entities/enums.py
+2
-1
app/entities/migrations/0027_assetgroup.py
app/entities/migrations/0027_assetgroup.py
+26
-0
app/entities/models.py
app/entities/models.py
+30
-1
config/urls.py
config/urls.py
+1
-0
No files found.
app/applicationlayer/ams/asset_group/serializers.py
View file @
7105270d
from
app.entities
import
models
from
rest_framework
import
serializers
from
app.applicationlayer.utils
import
model_to_dict
class
AssetGroupSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
models
.
AssetGroup
fields
=
'__all__'
read_only_fields
=
[
'created'
,
'code'
]
\ No newline at end of file
app/applicationlayer/ams/asset_group/table_filters.py
View file @
7105270d
from
django_filters
import
rest_framework
as
filters
from
app.entities.models
import
AssetGroup
class
AssetGroupFilter
(
filters
.
FilterSet
):
class
Meta
:
model
=
AssetGroup
fields
=
'__all__'
\ No newline at end of file
app/applicationlayer/ams/asset_group/views.py
View file @
7105270d
from
app.entities
import
models
from
rest_framework
import
viewsets
,
status
from
rest_framework.response
import
Response
from
django_filters
import
rest_framework
as
filters
from
django_filters.rest_framework
import
DjangoFilterBackend
from
rest_framework.filters
import
SearchFilter
,
OrderingFilter
from
app.applicationlayer.ams.asset_group.table_filters
import
AssetGroupFilter
from
app.applicationlayer.ams.asset_group
import
serializers
from
app.applicationlayer.utils
import
(
CustomPagination
,
status_message_response
)
from
app.helper
import
decorators
from
django.db
import
transaction
class
AssetGroupViewset
(
viewsets
.
ModelViewSet
):
queryset
=
models
.
AssetGroup
.
objects
.
all
()
serializer_class
=
serializers
.
AssetGroupSerializer
pagination_class
=
CustomPagination
lookup_field
=
"code"
filter_backends
=
(
DjangoFilterBackend
,
SearchFilter
,
OrderingFilter
)
ordering_fields
=
'__all__'
search_fields
=
(
'code'
,
'name'
,
'asset_group'
)
@
transaction
.
atomic
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
serializer
=
self
.
get_serializer
(
data
=
request
.
data
)
serializer
.
is_valid
(
raise_exception
=
True
)
self
.
perform_create
(
serializer
)
message
=
status_message_response
(
201
,
'success'
,
'New Asset Group created'
,
serializer
.
data
)
return
Response
(
message
)
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
queryset
=
self
.
filter_queryset
(
self
.
get_queryset
())
page
=
self
.
paginate_queryset
(
queryset
)
if
page
is
not
None
:
serializer
=
self
.
get_serializer
(
page
,
many
=
True
)
message
=
status_message_response
(
200
,
'success'
,
'List of Asset Groups found!'
,
serializer
.
data
)
return
self
.
get_paginated_response
(
message
)
serializer
=
self
.
get_serializer
(
self
.
queryset
,
many
=
True
)
return
Response
(
serializer
.
data
,
status
=
status
.
HTTP_200_OK
)
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
instance
=
self
.
get_object
()
serializer
=
self
.
get_serializer
(
instance
)
return
Response
(
serializer
.
data
)
@
transaction
.
atomic
def
destroy
(
self
,
request
,
*
args
,
**
kwargs
):
instance
=
self
.
get_object
()
self
.
perform_destroy
(
instance
)
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
\ No newline at end of file
app/applicationlayer/ams/urls_ams.py
View file @
7105270d
from
django.urls
import
path
,
include
from
rest_framework
import
routers
from
django.conf.urls
import
url
from
rest_framework.urlpatterns
import
format_suffix_patterns
from
app.applicationlayer.ams.asset_group
import
views
as
assetgroup
router
=
routers
.
DefaultRouter
()
router
.
register
(
r'asset-group'
,
assetgroup
.
AssetGroupViewset
)
urlpatterns
=
[
path
(
''
,
include
(
router
.
urls
)),
]
\ No newline at end of file
app/entities/enums.py
View file @
7105270d
...
@@ -41,7 +41,8 @@ class GenerateCode(Enum):
...
@@ -41,7 +41,8 @@ class GenerateCode(Enum):
FORM_ATTACH
=
'FRMATCH'
FORM_ATTACH
=
'FRMATCH'
FORM_DETAIL
=
'FRMDETAIL'
FORM_DETAIL
=
'FRMDETAIL'
ASSET_GROUP
=
'AMSGRP'
'''
'''
*********
*********
LOG ENUMS
LOG ENUMS
...
...
app/entities/migrations/0027_assetgroup.py
0 → 100644
View file @
7105270d
# Generated by Django 2.2 on 2019-10-24 18:34
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'entities'
,
'0026_auto_20191022_1726'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'AssetGroup'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'code'
,
models
.
CharField
(
max_length
=
255
,
unique
=
True
)),
(
'name'
,
models
.
CharField
(
max_length
=
255
,
unique
=
True
)),
(
'asset_group'
,
models
.
CharField
(
max_length
=
255
,
unique
=
True
)),
(
'created'
,
models
.
DateTimeField
(
blank
=
True
,
null
=
True
)),
],
options
=
{
'db_table'
:
'asset_groups'
,
},
),
]
app/entities/models.py
View file @
7105270d
...
@@ -1098,4 +1098,33 @@ class OverdueTrigger(models.Model):
...
@@ -1098,4 +1098,33 @@ class OverdueTrigger(models.Model):
**********************
**********************
*** AMS TABLES ***
*** AMS TABLES ***
**********************
**********************
"""
"""
\ No newline at end of file
class
AssetGroup
(
models
.
Model
):
code
=
models
.
CharField
(
unique
=
True
,
max_length
=
255
)
name
=
models
.
CharField
(
unique
=
True
,
max_length
=
255
)
asset_group
=
models
.
CharField
(
unique
=
True
,
max_length
=
255
)
created
=
models
.
DateTimeField
(
blank
=
True
,
null
=
True
)
class
Meta
:
db_table
=
'asset_groups'
def
__str__
(
self
):
return
f
'{self.code}'
def
save
(
self
,
*
args
,
**
kwargs
):
super
(
AssetGroup
,
self
)
.
save
(
*
args
,
**
kwargs
)
code
=
number_generator
(
enums
.
GenerateCode
.
ASSET_GROUP
.
value
,
self
.
id
)
if
self
.
code
==
''
:
self
.
code
=
code
self
.
created
=
datetime
.
now
()
self
.
save
()
\ No newline at end of file
config/urls.py
View file @
7105270d
...
@@ -37,6 +37,7 @@ urlpatterns = [
...
@@ -37,6 +37,7 @@ urlpatterns = [
re_path
(
r'^media/(?P<path>.*)$'
,
serve
,{
'document_root'
:
settings
.
MEDIA_ROOT
}),
re_path
(
r'^media/(?P<path>.*)$'
,
serve
,{
'document_root'
:
settings
.
MEDIA_ROOT
}),
re_path
(
r'^static/(?P<path>.*)$'
,
serve
,{
'document_root'
:
settings
.
STATIC_ROOT
}),
re_path
(
r'^static/(?P<path>.*)$'
,
serve
,{
'document_root'
:
settings
.
STATIC_ROOT
}),
path
(
'api/v1/asset-management/'
,
include
(
'app.applicationlayer.ams.urls_ams'
)),
]
]
if
settings
.
DEBUG
:
if
settings
.
DEBUG
:
...
...
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