Commit 53b74b25 authored by Gladys Forte's avatar Gladys Forte

serializers template

parent ac939fac
......@@ -7,7 +7,6 @@ from app.applicationlayer.cms.utils_cr import (get_account_details,
get_dept_details,
get_companies_details)
from app.applicationlayer.cms.template.approver.serializers import ChangeRequestTemplateApproversSerializer
from app.applicationlayer.cms.template.stakeholder.serializers import ChangeRequestTemplateStakeHoldersSerializer
......@@ -46,14 +45,13 @@ class ChangeRequestTemplatesSerializer(
ret = super().to_representation(instance)
try:
ret['company'] = model_to_dict(instance.user.department.company)
ret['department'] = model_to_dict(instance.user.department)
ret['point_of_contact'] = model_to_dict(instance.requested_to_user)
ret['created_by'] = instance.created_by_user.code
ret['company'] = instance.requested_to_company.name
ret['department'] = instance.requested_to_department.name
ret['point_of_contact'] = instance.requested_to_user.name
ret['created_by'] = instance.created_by_user.name
return ret
except Exception as e:
ret['company'] = "none"
ret['department'] = "none"
ret['point_of_contact'] = "none"
......
......@@ -219,7 +219,7 @@ class ChangeRequestTemplatesViewset(meviewsets.ModelViewSet):
@transaction.atomic
def partial_update(self, request, *args, **kwargs):
partial = kwargs.pop('partial', False)
partial = kwargs.pop('partial', True)
instance = self.get_object()
template_no = kwargs['template_no']
......@@ -257,7 +257,6 @@ class ChangeRequestTemplatesViewset(meviewsets.ModelViewSet):
template_no
)
if body_data['tmp_stakes']:
tmp_add_edit_delete(
body_data['tmp_stakes'],
models.ChangeRequestTemplateStakeHolders,
......@@ -268,7 +267,6 @@ class ChangeRequestTemplatesViewset(meviewsets.ModelViewSet):
template_no
)
if body_data['tmp_attachments']:
tmp_add_edit_delete(
body_data['tmp_attachments'],
models.ChangeRequestTemplateAttachments,
......@@ -279,7 +277,6 @@ class ChangeRequestTemplatesViewset(meviewsets.ModelViewSet):
template_no
)
if body_data['tmp_details']:
tmp_add_edit_delete(
body_data['tmp_details'],
models.ChangeRequestTemplateDetails,
......@@ -304,7 +301,7 @@ class ChangeRequestTemplatesViewset(meviewsets.ModelViewSet):
"Unable to edit due to existing transaction",
status=status.HTTP_400_BAD_REQUEST
)
#try
class ChangeRequestTemplatePost(APIView):
......
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