Commit a17449c4 authored by John Red Medrano's avatar John Red Medrano

Merge pull request #191 in RMS/api-main-service from red-develop to RMSv2

* commit '4388b4dd':
  fixing
parents fccbb801 4388b4dd
from app.entities import models
from rest_framework import serializers
from django.db.models import Q
from django.conf import settings
from django.forms.models import model_to_dict
from drf_writable_nested import WritableNestedModelSerializer
from app.applicationlayer.cms.utils_cr import (get_account_details,
......@@ -15,10 +16,10 @@ from app.applicationlayer.cms.template.stakeholder.serializers import ChangeRequ
class ChangeRequestTemplateAttachmentsSerializer(
serializers.ModelSerializer
):
file_upload = serializers.URLField(allow_blank=True)
file_upload = serializers.HyperlinkedRelatedField(queryset=models.MasterAttachment.objects.all(), view_name='MasterAttachment.id')
def to_representation(self, instance):
try:
# try:
ret = super().to_representation(instance)
user_object = {
"id": instance.uploaded_by.id,
......@@ -29,16 +30,26 @@ class ChangeRequestTemplateAttachmentsSerializer(
"contact_no": instance.uploaded_by.contact_no
}
ret['uploaded_by'] = user_object
ret['file_upload'] = instance.file_upload.url.url
return ret
except Exception as e:
ret['uploaded_by'] = "none"
# ret['file_upload'] = settings.MEDIA_URL
return ret
# except Exception as e:
# ret['uploaded_by'] = "none"
# return ret
class Meta:
model = models.ChangeRequestTemplateAttachments
fields = '__all__'
fields = (
"id",
"attachment_type",
"attachment_name",
"file_name",
"description",
"created",
"code",
"uploaded_by",
"file_upload",
"template_no"
)
read_only_fields = ['created', 'code']
......
......@@ -35,10 +35,10 @@ urlpatterns = [
url(r'^chat/(?P<room_name>[^/]+)/$', notifview.room, name='room'),
re_path(r'^media/(?P<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}),
re_path(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}),
# re_path(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
\ No newline at end of file
# urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
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