Commit 44cff872 authored by Gladys Forte's avatar Gladys Forte

archived

parent a0d5c1bb
......@@ -157,16 +157,18 @@ class ForgotPassword(APIView):
url = f"{settings.FRONT_END_URL}/forgot-password/reset"\
f"?token={TOKEN}"
args = [str(PASSCODE), str(url), user, str(existingUser.email)]
args = [str(PASSCODE), str(url), user, str(existingUser.email),
str(existingUser.username)]
# t1 = threading.Thread(target=sender.forgot_password, args=(args,))
# t1.start()
main_threading(args, sender.forgot_password)
args = [str(PASSCODE), str(url), user, str(existingUser.email)]
# args = [str(PASSCODE), str(url), user, str(existingUser.email),
# str(existingUser.username)]
# t2 = threading.Thread(target=sender.forgot_password, args=(args,))
# t2.start()
main_threading(args, sender.forgot_password)
# main_threading(args, sender.forgot_password)
return Response(data={"detail": "Forgot Password Sent"},
status=status.HTTP_200_OK)
......
......@@ -362,6 +362,12 @@ class ChangeRequestFormsViewset(viewsets.ModelViewSet):
def destroy(self, request, *args, **kwargs):
try:
form_code = self.kwargs['form_code']
current_status = models.ChangeRequestFormHeader.objects.get(
form_code=form_code
)
if current_status.status.lower() == 'draft':
existing_transaction = models.ChangeRequestHistory.objects.filter(
form_code=form_code
)
......@@ -431,6 +437,20 @@ class ChangeRequestFormsViewset(viewsets.ModelViewSet):
{"message": "Change request cannot be deleted due to previous transaction/s"},
status=status.HTTP_400_BAD_REQUEST)
elif current_status.status.lower() == 'cancelled':
models.ChangeRequestFormHeader.objects.filter(
form_code=form_code
).update(status='Archived')
return Response(
{"message": "Change Request successfully archived!"},
status=status.HTTP_200_OK)
else:
return Response(
{"message": "Cannot archive this change request due to ongoing transaction"},
status=status.HTTP_400_BAD_REQUEST)
except Exception as e:
return Response(e,
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
......@@ -722,7 +742,6 @@ class ChangeRequestFormsViewset(viewsets.ModelViewSet):
notification_msg, action,
remarks, level
)
else:
# EMAIL CODE FOR REQUESTOR
requestor_notification_msg = REQUESTOR_REJECT_MESSAGE.split(';')[0]
......
......@@ -55,12 +55,13 @@ def forgot_password(args):
url = args[1]
recipient = args[2]
admin = args[3]
name = args[4]
F = open(os.path.join(settings.EMAIL_TEMPLATES_ROOT, 'RMS-PASSWORD.html'), 'r')
FC = F.read()
FC = FC.replace('{name}', recipient)
FC = FC.replace('{name}', name)
FC = FC.replace('{code}', reset_code)
FC = FC.replace('{url}', url)
......@@ -515,9 +516,9 @@ def routing_table_actions(args):
elif args[12].lower() == 'rejected':
subject = 'Resource Management System - Change Request Rejected'
if args[13].lower() == 'requestor':
email_template = 'RMS-CRREJECTED.html'
elif args[13].lower() == 'vendor/implementor':
email_template = 'RMS-CRREJECTED-VENDOR.html'
else:
email_template = 'RMS-CRREJECTED.html'
F = open(os.path.join(settings.EMAIL_TEMPLATES_ROOT, email_template), 'r')
......@@ -534,7 +535,7 @@ def routing_table_actions(args):
FC = FC.replace('{priority_level}', priority_level)
FC = FC.replace('{url}', url)
if args[11].lower() == 'rejected':
if args[12].lower() == 'rejected':
FC = FC.replace('{remarks}', remarks)
try:
......
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