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
ea76b5af
Commit
ea76b5af
authored
Jan 13, 2020
by
John Red Medrano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added endpoint rms dashboard
parent
c94802f4
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
541 additions
and
1239 deletions
+541
-1239
app/applicationlayer/master/dashboard/views.py
app/applicationlayer/master/dashboard/views.py
+121
-0
app/applicationlayer/master/urls.py
app/applicationlayer/master/urls.py
+3
-0
requirements/RMSv2.postman_collection.json
requirements/RMSv2.postman_collection.json
+416
-1239
requirements/export docker image.txt
requirements/export docker image.txt
+1
-0
No files found.
app/applicationlayer/master/dashboard/views.py
0 → 100644
View file @
ea76b5af
from
rest_framework.views
import
APIView
from
rest_framework
import
viewsets
from
rest_framework.response
import
Response
from
app.entities
import
enums
from
app.applicationlayer.utils
import
main_threading
from
app.helper.email_service
import
sender
from
rest_framework.permissions
import
AllowAny
from
app.entities.models
import
(
User
,
Company
,
Department
)
from
app.applicationlayer.master.dashboard.serializer
import
(
RMSDashBoardSerializer
)
from
app.applicationlayer.utils
import
CustomPagination
from
app.entities
import
enums
from
django.db.models
import
Count
class
RMSDashBoardViewSet
(
APIView
):
def
get
(
self
,
request
,
format
=
None
):
# try:
enums_company
=
enums
.
UserTypeEnum
.
COMPANY_USER_ADMIN
.
value
enums_department
=
enums
.
UserTypeEnum
.
DEPARTMENT_USER_ADMIN
.
value
user_type
=
request
.
user
.
user_type
user_company
=
request
.
user
.
department
.
company
.
code
user_department
=
request
.
user
.
department
.
code
department_count
=
''
company_count
=
''
user_count
=
''
arr_company
=
[]
recently_company
=
{}
recently_users
=
User
.
objects
.
all
()
.
values
(
'name'
,
'department__company__name'
,
'department__name'
,
'date_joined'
)
.
order_by
(
'-date_joined'
)[
0
:
9
]
if
user_type
==
enums_department
:
company_count
=
1
department_count
=
1
user_count
=
User
.
objects
.
filter
(
department
=
str
(
user_department
)
)
.
count
()
recently_company
[
'company_name'
]
=
request
.
user
.
department
.
company
.
name
recently_company
[
'no_department'
]
=
Department
.
objects
.
filter
(
code
=
str
(
user_department
)
)
.
count
()
recently_company
[
'no_users'
]
=
user_count
recently_company
[
'date_added'
]
=
request
.
user
.
department
.
company
.
created
arr_company
.
append
(
recently_company
)
elif
user_type
==
enums_company
:
company_count
=
1
user_count
=
User
.
objects
.
filter
(
department__company
=
str
(
user_company
)
)
.
count
()
department_count
=
Department
.
objects
.
filter
(
company
=
str
(
user_company
)
)
.
count
()
recently_company
[
'company_name'
]
=
request
.
user
.
department
.
company
.
name
recently_company
[
'no_department'
]
=
department_count
recently_company
[
'no_users'
]
=
User
.
objects
.
filter
(
department__company__code
=
str
(
user_company
)
)
.
count
()
recently_company
[
'date_added'
]
=
request
.
user
.
department
.
company
.
created
arr_company
.
append
(
recently_company
)
else
:
company_count
=
Company
.
objects
.
all
()
.
count
()
companies
=
Company
.
objects
.
all
()[
0
:
10
]
department_count
=
Department
.
objects
.
all
()
.
count
()
user_count
=
User
.
objects
.
all
()
.
count
()
for
data
in
companies
:
recently_company
[
'name'
]
=
data
.
name
recently_company
[
'no_department'
]
=
Department
.
objects
.
filter
(
company
=
str
(
data
.
code
)
)
.
count
()
recently_company
[
'no_users'
]
=
User
.
objects
.
filter
(
department__company__code
=
str
(
data
.
code
)
)
.
count
()
recently_company
[
'date_added'
]
=
data
.
created
arr_company
.
append
(
recently_company
)
recently_company
=
{}
data
=
{
"company_count"
:
company_count
,
"department_count"
:
department_count
,
"user_count"
:
user_count
,
"recently_company"
:
arr_company
,
"recently_users"
:
recently_users
}
return
Response
(
data
)
# except Exception as e:
# return Response(
# {'message': "query params department_code and company_code are both expected"},
# status=status.HTTP_400_BAD_REQUEST
# )
\ No newline at end of file
app/applicationlayer/master/urls.py
View file @
ea76b5af
...
...
@@ -6,14 +6,17 @@ from app.applicationlayer.master.company.views import AdminCompanyViewSet
from
app.applicationlayer.master.department.views
import
AdminDepartmentViewSet
from
app.applicationlayer.master.user_type.views
import
UserTypeViewSet
from
app.applicationlayer.master.attachment.views
import
MasterAttachmentViewSet
from
app.applicationlayer.master.dashboard.views
import
RMSDashBoardViewSet
router
=
routers
.
DefaultRouter
()
router
.
register
(
r'users'
,
AdminAccountViewSet
)
router
.
register
(
r'companies'
,
AdminCompanyViewSet
)
router
.
register
(
r'departments'
,
AdminDepartmentViewSet
)
router
.
register
(
r'attachments'
,
MasterAttachmentViewSet
)
# router.register(r'dashboard', RMSDashBoardViewSet)
urlpatterns
=
[
path
(
''
,
include
(
router
.
urls
)),
url
(
r'^user-types/$'
,
UserTypeViewSet
.
as_view
(),
name
=
"user-types"
),
url
(
r'^dashbaord/$'
,
RMSDashBoardViewSet
.
as_view
(),
name
=
"dashbaord"
),
]
\ No newline at end of file
requirements/RMSv2.postman_collection.json
View file @
ea76b5af
This diff is collapsed.
Click to expand it.
requirements/export docker image.txt
View file @
ea76b5af
...
...
@@ -19,3 +19,4 @@ docker run -d --restart=always -p 3001:3000 sit_rms_webv2 npm start
Clear Cache REDIS
config set stop-writes-on-bgsave-error no
docker run -p 6379:6379 -d redis:2.8
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