Commit 4a4e7be9 authored by John Red Medrano's avatar John Red Medrano

Merge branch 'RMSv2' of http://42.61.118.105:7990/scm/rms/api-main-service into red-develop

parents a1b2a762 46651d98
This diff is collapsed.
...@@ -10,6 +10,38 @@ from app.applicationlayer.cms.utils_cr import (get_account_details, ...@@ -10,6 +10,38 @@ from app.applicationlayer.cms.utils_cr import (get_account_details,
class ChangeRequestTemplateApproversSerializer( class ChangeRequestTemplateApproversSerializer(
serializers.ModelSerializer serializers.ModelSerializer
): ):
def to_representation(self, instance):
ret = super().to_representation(instance)
try:
user = instance.user
user_details = get_account_details(user.code)
name = user_details.values_list('name', flat=True)[0]
email = user_details.values_list('email', flat=True)[0]
contact_no = user_details.values_list('contact_no', flat=True)[0]
dept_code = user_details.values_list('department', flat=True)[0]
department_details = get_dept_details(dept_code)
department = department_details.values_list('name', flat=True)[0]
comp_code = department_details.values_list('company', flat=True)[0]
company_details = get_companies_details(comp_code)
company = company_details.values_list('name', flat=True)[0]
ret['company'] = company
ret['department'] = department
ret['name'] = name
ret['email'] = email
ret['contact_no'] = contact_no
return ret
except Exception as e:
ret['company'] = "none"
ret['department'] = "none"
ret['name'] = "none"
ret['email'] = "none"
ret['contact_no'] = "none"
return ret
class Meta: class Meta:
model = models.ChangeRequestTemplateApprovers model = models.ChangeRequestTemplateApprovers
fields = '__all__' fields = '__all__'
...@@ -19,6 +51,38 @@ class ChangeRequestTemplateApproversSerializer( ...@@ -19,6 +51,38 @@ class ChangeRequestTemplateApproversSerializer(
class ChangeRequestTemplateStakeHoldersSerializer( class ChangeRequestTemplateStakeHoldersSerializer(
serializers.ModelSerializer serializers.ModelSerializer
): ):
def to_representation(self, instance):
ret = super().to_representation(instance)
try:
user = instance.user
user_details = get_account_details(user.code)
name = user_details.values_list('name', flat=True)[0]
email = user_details.values_list('email', flat=True)[0]
contact_no = user_details.values_list('contact_no', flat=True)[0]
dept_code = user_details.values_list('department', flat=True)[0]
department_details = get_dept_details(dept_code)
department = department_details.values_list('name', flat=True)[0]
comp_code = department_details.values_list('company', flat=True)[0]
company_details = get_companies_details(comp_code)
company = company_details.values_list('name', flat=True)[0]
ret['company'] = company
ret['department'] = department
ret['name'] = name
ret['email'] = email
ret['contact_no'] = contact_no
return ret
except Exception as e:
ret['company'] = "none"
ret['department'] = "none"
ret['name'] = "none"
ret['email'] = "none"
ret['contact_no'] = "none"
return ret
class Meta: class Meta:
model = models.ChangeRequestTemplateStakeHolders model = models.ChangeRequestTemplateStakeHolders
fields = '__all__' fields = '__all__'
......
...@@ -328,11 +328,6 @@ class ChangeRequestTemplatePost(APIView): ...@@ -328,11 +328,6 @@ class ChangeRequestTemplatePost(APIView):
'requested_to_user': template_header['requested_to_user'] 'requested_to_user': template_header['requested_to_user']
} }
tmp_approvers = template_header['tmp_approvers']
tmp_stakes = template_header['tmp_stakes']
tmp_attachments = template_header['tmp_attachments']
tmp_details = template_header['tmp_details']
sp1 = transaction.savepoint() # nothing will save to db sp1 = transaction.savepoint() # nothing will save to db
serializer = serializers.ChangeRequestTemplatesSerializer( serializer = serializers.ChangeRequestTemplatesSerializer(
...@@ -344,6 +339,7 @@ class ChangeRequestTemplatePost(APIView): ...@@ -344,6 +339,7 @@ class ChangeRequestTemplatePost(APIView):
tmp_id = serializer.data['template_no'] tmp_id = serializer.data['template_no']
# create template approvers # create template approvers
tmp_approvers = template_header['tmp_approvers']
for tmp_approver in tmp_approvers: for tmp_approver in tmp_approvers:
tmp_approver['template_no'] = tmp_id tmp_approver['template_no'] = tmp_id
...@@ -356,6 +352,8 @@ class ChangeRequestTemplatePost(APIView): ...@@ -356,6 +352,8 @@ class ChangeRequestTemplatePost(APIView):
serializerApprover.save() serializerApprover.save()
# create template stakes # create template stakes
if template_header['tmp_stakes']:
tmp_stakes = template_header['tmp_stakes']
for tmp_stake in tmp_stakes: for tmp_stake in tmp_stakes:
tmp_stake['template_no'] = tmp_id tmp_stake['template_no'] = tmp_id
...@@ -368,6 +366,8 @@ class ChangeRequestTemplatePost(APIView): ...@@ -368,6 +366,8 @@ class ChangeRequestTemplatePost(APIView):
serializerStake.save() serializerStake.save()
# create template attachments # create template attachments
if template_header['tmp_attachments']:
tmp_attachments = template_header['tmp_attachments']
for tmp_attachment in tmp_attachments: for tmp_attachment in tmp_attachments:
tmp_attachment['template_no'] = tmp_id tmp_attachment['template_no'] = tmp_id
...@@ -380,6 +380,8 @@ class ChangeRequestTemplatePost(APIView): ...@@ -380,6 +380,8 @@ class ChangeRequestTemplatePost(APIView):
serializerAttach.save() serializerAttach.save()
# create template details # create template details
if template_header['tmp_details']:
tmp_details = template_header['tmp_details']
for tmp_detail in tmp_details: for tmp_detail in tmp_details:
tmp_detail['template_no'] = tmp_id tmp_detail['template_no'] = tmp_id
......
...@@ -18,6 +18,14 @@ from django.db.models import Max ...@@ -18,6 +18,14 @@ from django.db.models import Max
CR_FRONT_LINK = settings.CR_FRONT_LINK CR_FRONT_LINK = settings.CR_FRONT_LINK
APPROVER_MESSAGE = settings.APPROVER_MESSAGE
REQUESTOR_MESSAGE = settings.REQUESTOR_MESSAGE
REQUESTOR_REJECT_MESSAGE = settings.REQUESTOR_REJECT_MESSAGE
VENDOR_ACKNOWLEDGE_MESSAGE = settings.VENDOR_ACKNOWLEDGE_MESSAGE
REQUESTOR_ACKNOWLEDGE_MESSAGE = settings.REQUESTOR_ACKNOWLEDGE_MESSAGE
REQUESTOR_COMPLETION_MESSAGE = settings.REQUESTOR_COMPLETION_MESSAGE
VENDOR_ACCEPTANCE_MESSAGE = settings.VENDOR_ACCEPTANCE_MESSAGE
VENDOR_REJECT_MESSAGE = settings.VENDOR_REJECT_MESSAGE
def entity_log_bulk(queryset, entity, tbl): def entity_log_bulk(queryset, entity, tbl):
...@@ -277,7 +285,7 @@ def send_mail_requestor(current_user, ...@@ -277,7 +285,7 @@ def send_mail_requestor(current_user,
current_user) current_user)
def next_approver_email(receiver, form_code, delegation, msg): def next_approver_email(form_code, next_level):
cr_link = f'{CR_FRONT_LINK}/{form_code}' cr_link = f'{CR_FRONT_LINK}/{form_code}'
template_instance = get_template_instance(form_code) template_instance = get_template_instance(form_code)
...@@ -289,12 +297,6 @@ def next_approver_email(receiver, form_code, delegation, msg): ...@@ -289,12 +297,6 @@ def next_approver_email(receiver, form_code, delegation, msg):
requested_to_priority = template_instance.requested_to_priority requested_to_priority = template_instance.requested_to_priority
cr_status = template_instance.status cr_status = template_instance.status
# next approver details --------------------------------------------------
receiver_instance = get_account_details(receiver)
receiver_name = receiver_instance.values_list('name', flat=True)[0]
receiver_email = receiver_instance.values_list('email', flat=True)[0]
receiver_code = receiver_instance.values_list('code', flat=True)[0]
# requestor details -------------------------------------------------- # requestor details --------------------------------------------------
sender_instance = get_account_details(requested_by_user) sender_instance = get_account_details(requested_by_user)
sender_email = sender_instance.values_list('email', flat=True)[0] sender_email = sender_instance.values_list('email', flat=True)[0]
...@@ -307,6 +309,27 @@ def next_approver_email(receiver, form_code, delegation, msg): ...@@ -307,6 +309,27 @@ def next_approver_email(receiver, form_code, delegation, msg):
company = get_companies_details(requested_to_company) company = get_companies_details(requested_to_company)
company_name = company.values_list('name', flat=True)[0] company_name = company.values_list('name', flat=True)[0]
# get details of next approver/s
next_approver = models.ChangeRequestFormApprovers.objects.filter(
level=str(next_level),
form_code=form_code
)
# LOOP on next approver for sending email
for n_approver in next_approver:
# NOTIF MSG FOR NEXT APPROVER
msg = APPROVER_MESSAGE.split(';')[0]
if n_approver.delegation.lower() == 'vendor/implementor':
msg = VENDOR_ACKNOWLEDGE_MESSAGE.split(';')[0]
# next approver details --------------------------------------------------
receiver_instance = get_account_details(n_approver.user.code)
receiver_name = receiver_instance.values_list('name', flat=True)[0]
receiver_email = receiver_instance.values_list('email', flat=True)[0]
receiver_code = receiver_instance.values_list('code', flat=True)[0]
# call sender email # call sender email
name = receiver_name name = receiver_name
...@@ -319,7 +342,7 @@ def next_approver_email(receiver, form_code, delegation, msg): ...@@ -319,7 +342,7 @@ def next_approver_email(receiver, form_code, delegation, msg):
url = cr_link url = cr_link
recipient = receiver_email recipient = receiver_email
delegation_type = delegation delegation_type = n_approver.delegation.lower()
admin = sender_email admin = sender_email
args = [name, cr_number, cr_name, args = [name, cr_number, cr_name,
......
...@@ -139,8 +139,10 @@ def send_broadcast_message(room_name, sender, message): ...@@ -139,8 +139,10 @@ def send_broadcast_message(room_name, sender, message):
def notification_create(form_code, message, account_no, sender_account_no): def notification_create(form_code, message, account_no, sender_account_no):
# try:
v = Notification.objects.create( try:
Notification.objects.create(
form_code=form_code, form_code=form_code,
notif_type='TASK', notif_type='TASK',
message=message, message=message,
...@@ -149,15 +151,15 @@ def notification_create(form_code, message, account_no, sender_account_no): ...@@ -149,15 +151,15 @@ def notification_create(form_code, message, account_no, sender_account_no):
account_no=account_no, account_no=account_no,
sender_account_no=sender_account_no sender_account_no=sender_account_no
) )
print(v)
# ROOM = account_no
# SENDER = sender_account_no
# send_broadcast_message( ROOM = account_no
# ROOM, SENDER = sender_account_no
# SENDER,
# 'NEW NOTIFICATIONS' send_broadcast_message(
# ) ROOM,
SENDER,
'NEW NOTIFICATIONS'
)
# message = { # message = {
# 'code': 200, # 'code': 200,
...@@ -167,11 +169,11 @@ def notification_create(form_code, message, account_no, sender_account_no): ...@@ -167,11 +169,11 @@ def notification_create(form_code, message, account_no, sender_account_no):
# return Response(message, status=status.HTTP_200_OK) # return Response(message, status=status.HTTP_200_OK)
return True return True
# except Exception as e: except Exception as e:
# message = { message = {
# 'code': 500, 'code': 500,
# 'status': 'failed', 'status': 'failed',
# 'message': 'Request was not able to process' + str(e.__class__) 'message': 'Request was not able to process' + str(e.__class__)
# } }
# return Response(message, return Response(message,
# status=status.HTTP_500_INTERNAL_SERVER_ERROR) status=status.HTTP_500_INTERNAL_SERVER_ERROR)
\ No newline at end of file \ No newline at end of file
...@@ -103,6 +103,7 @@ class CREnum(Enum): ...@@ -103,6 +103,7 @@ class CREnum(Enum):
ACCEPTED = "ACCEPTED" ACCEPTED = "ACCEPTED"
ACKNOWLEDGED = "ACKNOWLEDGED" ACKNOWLEDGED = "ACKNOWLEDGED"
REJECTED = "REJECTED" REJECTED = "REJECTED"
ACTION = "ACTION"
class CREntitiesEnum(Enum): class CREntitiesEnum(Enum):
......
...@@ -84,15 +84,6 @@ WSGI_APPLICATION = 'config.wsgi.application' ...@@ -84,15 +84,6 @@ WSGI_APPLICATION = 'config.wsgi.application'
ASGI_APPLICATION = "config.routing.application" ASGI_APPLICATION = "config.routing.application"
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('127.0.0.1', 6379)],
},
},
}
AUTH_USER_MODEL = 'entities.User' AUTH_USER_MODEL = 'entities.User'
# Password validation # Password validation
......
...@@ -9,6 +9,15 @@ config = configparser.ConfigParser() ...@@ -9,6 +9,15 @@ config = configparser.ConfigParser()
config_file = os.path.join('./', 'env.ini') config_file = os.path.join('./', 'env.ini')
config.read(config_file) config.read(config_file)
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('172.17.0.1', 6379)],
},
},
}
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': config['DEV']['DATABASE_ENGINE'], 'ENGINE': config['DEV']['DATABASE_ENGINE'],
...@@ -27,7 +36,7 @@ SESSION_TIMEOUT = config['DEV']['SESSION_TIMEOUT'] ...@@ -27,7 +36,7 @@ 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'] REALTIMESERVER_IP = config['DEV']['REALTIMESERVER_IP']
# Notification Messages # Notification Messages
APPROVER_MESSAGE = config['NOTIFICATION_EMAIL']['APPROVER_MESSAGE'] APPROVER_MESSAGE = config['NOTIFICATION_EMAIL']['APPROVER_MESSAGE']
......
...@@ -7,6 +7,15 @@ config = configparser.ConfigParser() ...@@ -7,6 +7,15 @@ config = configparser.ConfigParser()
config_file = os.path.join(BASE_DIR, 'env.ini') config_file = os.path.join(BASE_DIR, 'env.ini')
config.read(config_file) config.read(config_file)
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('127.0.0.1', 6379)],
},
},
}
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': config['LOCAL']['DATABASE_ENGINE'], 'ENGINE': config['LOCAL']['DATABASE_ENGINE'],
...@@ -25,7 +34,7 @@ SESSION_TIMEOUT = config['LOCAL']['SESSION_TIMEOUT'] ...@@ -25,7 +34,7 @@ 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['LOCAL']['REALTIMESERVER_IP']
# Notification Messages # Notification Messages
APPROVER_MESSAGE = config['NOTIFICATION_EMAIL']['APPROVER_MESSAGE'] APPROVER_MESSAGE = config['NOTIFICATION_EMAIL']['APPROVER_MESSAGE']
......
...@@ -9,6 +9,15 @@ config = configparser.ConfigParser() ...@@ -9,6 +9,15 @@ config = configparser.ConfigParser()
config_file = os.path.join('./', 'env.ini') config_file = os.path.join('./', 'env.ini')
config.read(config_file) config.read(config_file)
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('172.17.0.1', 6379)],
},
},
}
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': config['PRODUCTION']['DATABASE_ENGINE'], 'ENGINE': config['PRODUCTION']['DATABASE_ENGINE'],
...@@ -27,7 +36,7 @@ SESSION_TIMEOUT = config['PRODUCTION']['SESSION_TIMEOUT'] ...@@ -27,7 +36,7 @@ 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'] REALTIMESERVER_IP = config['PRODUCTION']['REALTIMESERVER_IP']
# Notification Messages # Notification Messages
APPROVER_MESSAGE = config['NOTIFICATION_EMAIL']['APPROVER_MESSAGE'] APPROVER_MESSAGE = config['NOTIFICATION_EMAIL']['APPROVER_MESSAGE']
......
...@@ -9,6 +9,15 @@ config = configparser.ConfigParser() ...@@ -9,6 +9,15 @@ config = configparser.ConfigParser()
config_file = os.path.join('./', 'env.ini') config_file = os.path.join('./', 'env.ini')
config.read(config_file) config.read(config_file)
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('172.17.0.1', 6379)],
},
},
}
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': config['UAT']['DATABASE_ENGINE'], 'ENGINE': config['UAT']['DATABASE_ENGINE'],
...@@ -27,7 +36,7 @@ SESSION_TIMEOUT = config['UAT']['SESSION_TIMEOUT'] ...@@ -27,7 +36,7 @@ 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'] REALTIMESERVER_IP = config['UAT']['REALTIMESERVER_IP']
# Notification Messages # Notification Messages
......
...@@ -11,6 +11,7 @@ AUTH_ACCESSS_TOKEN_TIMEOUT = ...@@ -11,6 +11,7 @@ AUTH_ACCESSS_TOKEN_TIMEOUT =
USER_DEFAULT_PASSWORD = USER_DEFAULT_PASSWORD =
CATCH_EMAIL = gladys@tirsolutions.com CATCH_EMAIL = gladys@tirsolutions.com
CR_LINK = http://staging.rms.oneberrysystem.com/cms/change-request/form/view CR_LINK = http://staging.rms.oneberrysystem.com/cms/change-request/form/view
REALTIMESERVER_IP = 127.0.0.1:8000
[UAT] [UAT]
DATABASE_ENGINE = django.db.backends.mysql DATABASE_ENGINE = django.db.backends.mysql
...@@ -25,6 +26,7 @@ AUTH_ACCESSS_TOKEN_TIMEOUT = ...@@ -25,6 +26,7 @@ AUTH_ACCESSS_TOKEN_TIMEOUT =
USER_DEFAULT_PASSWORD = USER_DEFAULT_PASSWORD =
CATCH_EMAIL = gladys@tirsolutions.com CATCH_EMAIL = gladys@tirsolutions.com
CR_LINK = http://staging.rms.oneberrysystem.com/cms/change-request/form/view CR_LINK = http://staging.rms.oneberrysystem.com/cms/change-request/form/view
REALTIMESERVER_IP = 127.0.0.1:8000
[DEV] [DEV]
DATABASE_ENGINE = django.db.backends.mysql DATABASE_ENGINE = django.db.backends.mysql
...@@ -39,6 +41,7 @@ AUTH_ACCESSS_TOKEN_TIMEOUT = ...@@ -39,6 +41,7 @@ AUTH_ACCESSS_TOKEN_TIMEOUT =
USER_DEFAULT_PASSWORD = USER_DEFAULT_PASSWORD =
CATCH_EMAIL = gladys@tirsolutions.com CATCH_EMAIL = gladys@tirsolutions.com
CR_LINK = http://devweb.rms.oneberrysystem.com/cms/change-request/form/view CR_LINK = http://devweb.rms.oneberrysystem.com/cms/change-request/form/view
REALTIMESERVER_IP = 127.0.0.1:8000
[LOCAL] [LOCAL]
DATABASE_ENGINE = django.db.backends.mysql DATABASE_ENGINE = django.db.backends.mysql
...@@ -53,8 +56,6 @@ AUTH_ACCESSS_TOKEN_TIMEOUT = 3600 ...@@ -53,8 +56,6 @@ AUTH_ACCESSS_TOKEN_TIMEOUT = 3600
USER_DEFAULT_PASSWORD = password USER_DEFAULT_PASSWORD = password
CATCH_EMAIL = gladys@tirsolutions.com CATCH_EMAIL = gladys@tirsolutions.com
CR_LINK = http://localhost:8000/cms/change-request/form/view CR_LINK = http://localhost:8000/cms/change-request/form/view
[NOTIFICATION]
REALTIMESERVER_IP = 127.0.0.1:8000 REALTIMESERVER_IP = 127.0.0.1:8000
[SETTINGS] [SETTINGS]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment