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
d6c43522
Commit
d6c43522
authored
Sep 03, 2019
by
Gladys Forte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notification v2
parent
fe520cc9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
61 deletions
+80
-61
app/applicationlayer/management/notification/utils_notif.py
app/applicationlayer/management/notification/utils_notif.py
+23
-1
app/applicationlayer/management/notification/views.py
app/applicationlayer/management/notification/views.py
+54
-59
config/settings/dev.py
config/settings/dev.py
+1
-0
config/settings/local.py
config/settings/local.py
+0
-1
config/settings/production.py
config/settings/production.py
+1
-0
config/settings/uat.py
config/settings/uat.py
+1
-0
No files found.
app/applicationlayer/management/notification/utils_notif.py
View file @
d6c43522
from
django.conf
import
settings
from
django.conf
import
settings
from
websocket
import
create_connection
from
websocket
import
create_connection
import
json
import
json
from
rest_framework.pagination
import
PageNumberPagination
from
rest_framework.response
import
Response
REALTIMESERVER_IP
=
settings
.
REALTIMESERVER_IP
REALTIMESERVER_IP
=
settings
.
REALTIMESERVER_IP
...
@@ -13,4 +15,24 @@ def send_broadcast_message(room_name, sender, message):
...
@@ -13,4 +15,24 @@ def send_broadcast_message(room_name, sender, message):
'message'
:
message
'message'
:
message
}
}
ws
.
send
(
json
.
dumps
(
data
))
ws
.
send
(
json
.
dumps
(
data
))
ws
.
close
()
ws
.
close
()
\ No newline at end of file
class
CustomPagination
(
PageNumberPagination
):
page_size
=
10
max_page_size
=
50
page_query_param
=
'page'
page_size_query_param
=
'page_size'
def
get_paginated_response
(
self
,
data
):
return
Response
({
'page_number'
:
self
.
page
.
number
,
'size_per_page'
:
self
.
page
.
paginator
.
per_page
,
'total_pages'
:
self
.
page
.
paginator
.
num_pages
,
'total'
:
self
.
page
.
paginator
.
count
,
'totalunseen'
:
data
[
'unseen'
],
'code'
:
data
[
'code'
],
'status'
:
data
[
'status'
],
'message'
:
data
[
'message'
],
'results'
:
data
[
'results'
]
})
\ No newline at end of file
app/applicationlayer/management/notification/views.py
View file @
d6c43522
...
@@ -14,9 +14,9 @@ from rest_framework import status
...
@@ -14,9 +14,9 @@ from rest_framework import status
from
django.conf
import
settings
from
django.conf
import
settings
from
app.applicationlayer.management.notification.utils_notif
import
(
from
app.applicationlayer.management.notification.utils_notif
import
(
send_broadcast_message
)
send_broadcast_message
,
from
app.applicationlayer.utils
import
(
status_message_response
,
CustomPagination
)
CustomPagination
)
from
app.applicationlayer.utils
import
(
status_message_response
)
from
rest_framework.exceptions
import
ValidationError
from
rest_framework.exceptions
import
ValidationError
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
rest_framework.decorators
import
action
from
rest_framework.decorators
import
action
...
@@ -32,59 +32,59 @@ class NotificationsViewset(meviewsets.ModelViewSet):
...
@@ -32,59 +32,59 @@ class NotificationsViewset(meviewsets.ModelViewSet):
pagination_class
=
CustomPagination
pagination_class
=
CustomPagination
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
# try:
try
:
req
=
self
.
request
req
=
self
.
request
account_no
=
req
.
query_params
.
get
(
'account_no'
)
account_no
=
req
.
query_params
.
get
(
'account_no'
)
app
=
req
.
query_params
.
get
(
'app_code'
)
app
=
req
.
query_params
.
get
(
'app'
)
if
account_no
:
if
account_no
:
queryset
=
models
.
Notification
.
objects
.
filter
(
account_no
=
account_no
)
.
order_by
(
'-created'
)
queryset
=
self
.
filter_queryset
(
queryset
)
unseen
=
models
.
Notification
.
objects
.
filter
(
account_no
=
account_no
,
is_read
=
False
)
.
count
()
if
app
:
queryset
=
models
.
Notification
.
objects
.
filter
(
queryset
=
models
.
Notification
.
objects
.
filter
(
account_no
=
account_no
,
app
=
app
)
.
order_by
(
'-created'
)
account_no
=
account_no
)
.
order_by
(
'-created'
)
queryset
=
self
.
filter_queryset
(
queryset
)
queryset
=
self
.
filter_queryset
(
queryset
)
unseen
=
models
.
Notification
.
objects
.
filter
(
unseen
=
models
.
Notification
.
objects
.
filter
(
account_no
=
account_no
,
app
=
app
,
is_read
=
False
)
.
count
()
account_no
=
account_no
,
is_read
=
False
)
.
count
()
else
:
if
app
:
queryset
=
models
.
Notification
.
objects
.
all
()
.
order_by
(
'-created'
)
queryset
=
self
.
filter_queryset
(
queryset
)
queryset
=
models
.
Notification
.
objects
.
filter
(
unseen
=
models
.
Notification
.
objects
.
filter
(
account_no
=
account_no
,
app
=
app
)
.
order_by
(
'-created'
)
is_read
=
False
)
.
count
()
queryset
=
self
.
filter_queryset
(
queryset
)
unseen
=
models
.
Notification
.
objects
.
filter
(
if
not
queryset
:
account_no
=
account_no
,
app
=
app
,
is_read
=
False
)
.
count
()
else
:
queryset
=
models
.
Notification
.
objects
.
all
()
.
order_by
(
'-created'
)
queryset
=
self
.
filter_queryset
(
queryset
)
unseen
=
models
.
Notification
.
objects
.
filter
(
is_read
=
False
)
.
count
()
if
not
queryset
:
message
=
status_message_response
(
200
,
'success'
,
'No records found'
,
[]
)
return
Response
(
message
)
serializer
=
self
.
get_serializer
(
queryset
,
many
=
True
)
page
=
self
.
paginate_queryset
(
queryset
)
if
page
is
not
None
:
serializer
=
self
.
get_serializer
(
page
,
many
=
True
)
message
=
{
'unseen'
:
unseen
,
'code'
:
200
,
'status'
:
'success'
,
'message'
:
'List of Notifications found'
,
'results'
:
serializer
.
data
}
return
self
.
get_paginated_response
(
message
)
except
Exception
as
e
:
message
=
status_message_response
(
message
=
status_message_response
(
200
,
'success'
,
'No records found'
,
[]
500
,
'failed'
,
)
'Request was not able to process'
+
str
(
e
),
[])
return
Response
(
message
,
return
Response
(
message
)
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
serializer
=
self
.
get_serializer
(
queryset
,
many
=
True
)
page
=
self
.
paginate_queryset
(
queryset
)
if
page
is
not
None
:
serializer
=
self
.
get_serializer
(
page
,
many
=
True
)
message
=
{
'unseen'
:
unseen
,
'code'
:
200
,
'status'
:
'success'
,
'message'
:
'List of Notifications found'
,
'results'
:
serializer
.
data
}
return
self
.
get_paginated_response
(
message
)
# return Response(serializer.data)
# 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)
@
action
(
methods
=
[
"PATCH"
],
detail
=
True
)
@
action
(
methods
=
[
"PATCH"
],
detail
=
True
)
...
@@ -96,8 +96,7 @@ class NotificationsViewset(meviewsets.ModelViewSet):
...
@@ -96,8 +96,7 @@ class NotificationsViewset(meviewsets.ModelViewSet):
models
.
Notification
.
objects
.
filter
(
account_no
=
account_no
,
models
.
Notification
.
objects
.
filter
(
account_no
=
account_no
,
id__in
=
request
.
data
[
'ids'
])
.
update
(
id__in
=
request
.
data
[
'ids'
])
.
update
(
is_read
=
True
,
is_read
=
True
,
modified
=
datetime
.
now
(),
modified
=
datetime
.
now
())
modifiedby
=
account_no
)
message
=
status_message_response
(
message
=
status_message_response
(
200
,
'success'
,
200
,
'success'
,
...
@@ -124,8 +123,7 @@ class NotificationsViewset(meviewsets.ModelViewSet):
...
@@ -124,8 +123,7 @@ class NotificationsViewset(meviewsets.ModelViewSet):
models
.
Notification
.
objects
.
filter
(
account_no
=
account_no
)
.
update
(
models
.
Notification
.
objects
.
filter
(
account_no
=
account_no
)
.
update
(
is_read
=
True
,
is_read
=
True
,
modified
=
datetime
.
now
(),
modified
=
datetime
.
now
())
modifiedby
=
account_no
)
message
=
status_message_response
(
message
=
status_message_response
(
200
,
'success'
,
200
,
'success'
,
...
@@ -147,9 +145,7 @@ class NotificationsViewset(meviewsets.ModelViewSet):
...
@@ -147,9 +145,7 @@ class NotificationsViewset(meviewsets.ModelViewSet):
serializer
=
serializers
.
NotificationSerializer
(
data
=
request
.
data
)
serializer
=
serializers
.
NotificationSerializer
(
data
=
request
.
data
)
try
:
try
:
if
serializer
.
is_valid
():
if
serializer
.
is_valid
():
x
=
serializer
.
save
()
serializer
.
save
()
x
.
created
=
datetime
.
now
()
x
.
save
()
message
=
{
message
=
{
'code'
:
201
,
'code'
:
201
,
...
@@ -159,7 +155,6 @@ class NotificationsViewset(meviewsets.ModelViewSet):
...
@@ -159,7 +155,6 @@ class NotificationsViewset(meviewsets.ModelViewSet):
}
}
ROOM
=
serializer
.
data
[
'account_no'
]
ROOM
=
serializer
.
data
[
'account_no'
]
SENDER
=
serializer
.
data
[
'sender_account_no'
]
SENDER
=
serializer
.
data
[
'sender_account_no'
]
send_broadcast_message
(
send_broadcast_message
(
...
...
config/settings/dev.py
View file @
d6c43522
...
@@ -27,3 +27,4 @@ SESSION_TIMEOUT = config['DEV']['SESSION_TIMEOUT']
...
@@ -27,3 +27,4 @@ SESSION_TIMEOUT = config['DEV']['SESSION_TIMEOUT']
FRONT_END_URL
=
config
[
'DEV'
][
'FRONT_END_URL'
]
FRONT_END_URL
=
config
[
'DEV'
][
'FRONT_END_URL'
]
AUTH_ACCESSS_TOKEN_TIMEOUT
=
config
[
'DEV'
][
'AUTH_ACCESSS_TOKEN_TIMEOUT'
]
AUTH_ACCESSS_TOKEN_TIMEOUT
=
config
[
'DEV'
][
'AUTH_ACCESSS_TOKEN_TIMEOUT'
]
USER_DEFAULT_PASSWORD
=
config
[
'DEV'
][
'USER_DEFAULT_PASSWORD'
]
USER_DEFAULT_PASSWORD
=
config
[
'DEV'
][
'USER_DEFAULT_PASSWORD'
]
REALTIMESERVER_IP
=
config
[
'NOTIFICATION'
][
'REALTIMESERVER_IP'
]
\ No newline at end of file
config/settings/local.py
View file @
d6c43522
...
@@ -25,5 +25,4 @@ SESSION_TIMEOUT = config['LOCAL']['SESSION_TIMEOUT']
...
@@ -25,5 +25,4 @@ SESSION_TIMEOUT = config['LOCAL']['SESSION_TIMEOUT']
FRONT_END_URL
=
config
[
'LOCAL'
][
'FRONT_END_URL'
]
FRONT_END_URL
=
config
[
'LOCAL'
][
'FRONT_END_URL'
]
AUTH_ACCESSS_TOKEN_TIMEOUT
=
config
[
'LOCAL'
][
'AUTH_ACCESSS_TOKEN_TIMEOUT'
]
AUTH_ACCESSS_TOKEN_TIMEOUT
=
config
[
'LOCAL'
][
'AUTH_ACCESSS_TOKEN_TIMEOUT'
]
USER_DEFAULT_PASSWORD
=
config
[
'LOCAL'
][
'USER_DEFAULT_PASSWORD'
]
USER_DEFAULT_PASSWORD
=
config
[
'LOCAL'
][
'USER_DEFAULT_PASSWORD'
]
REALTIMESERVER_IP
=
config
[
'NOTIFICATION'
][
'REALTIMESERVER_IP'
]
REALTIMESERVER_IP
=
config
[
'NOTIFICATION'
][
'REALTIMESERVER_IP'
]
\ No newline at end of file
config/settings/production.py
View file @
d6c43522
...
@@ -27,3 +27,4 @@ SESSION_TIMEOUT = config['PRODUCTION']['SESSION_TIMEOUT']
...
@@ -27,3 +27,4 @@ SESSION_TIMEOUT = config['PRODUCTION']['SESSION_TIMEOUT']
FRONT_END_URL
=
config
[
'PRODUCTION'
][
'FRONT_END_URL'
]
FRONT_END_URL
=
config
[
'PRODUCTION'
][
'FRONT_END_URL'
]
AUTH_ACCESSS_TOKEN_TIMEOUT
=
config
[
'PRODUCTION'
][
'AUTH_ACCESSS_TOKEN_TIMEOUT'
]
AUTH_ACCESSS_TOKEN_TIMEOUT
=
config
[
'PRODUCTION'
][
'AUTH_ACCESSS_TOKEN_TIMEOUT'
]
USER_DEFAULT_PASSWORD
=
config
[
'PRODUCTION'
][
'USER_DEFAULT_PASSWORD'
]
USER_DEFAULT_PASSWORD
=
config
[
'PRODUCTION'
][
'USER_DEFAULT_PASSWORD'
]
REALTIMESERVER_IP
=
config
[
'NOTIFICATION'
][
'REALTIMESERVER_IP'
]
\ No newline at end of file
config/settings/uat.py
View file @
d6c43522
...
@@ -27,3 +27,4 @@ SESSION_TIMEOUT = config['UAT']['SESSION_TIMEOUT']
...
@@ -27,3 +27,4 @@ SESSION_TIMEOUT = config['UAT']['SESSION_TIMEOUT']
FRONT_END_URL
=
config
[
'UAT'
][
'FRONT_END_URL'
]
FRONT_END_URL
=
config
[
'UAT'
][
'FRONT_END_URL'
]
AUTH_ACCESSS_TOKEN_TIMEOUT
=
config
[
'UAT'
][
'AUTH_ACCESSS_TOKEN_TIMEOUT'
]
AUTH_ACCESSS_TOKEN_TIMEOUT
=
config
[
'UAT'
][
'AUTH_ACCESSS_TOKEN_TIMEOUT'
]
USER_DEFAULT_PASSWORD
=
config
[
'UAT'
][
'USER_DEFAULT_PASSWORD'
]
USER_DEFAULT_PASSWORD
=
config
[
'UAT'
][
'USER_DEFAULT_PASSWORD'
]
REALTIMESERVER_IP
=
config
[
'NOTIFICATION'
][
'REALTIMESERVER_IP'
]
\ No newline at end of file
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