Commit 1d87ce56 authored by John Red Medrano's avatar John Red Medrano

add dynamic solution on serving profile picture base on env.ini on settings...

add dynamic solution on serving profile picture base on env.ini on settings section ssl variable if ssl = 1 mean the system hosted with ssl 0 is not
parent 7c6c653c
......@@ -12,6 +12,14 @@ from app.entities.models import (
ChangeRequestSettings
)
import os
import configparser
config = configparser.ConfigParser()
config_file = os.path.join('./', 'env.ini')
config.read(config_file)
class UserManagementRetreiveSerializer(serializers.ModelSerializer):
image = serializers.SerializerMethodField()
......@@ -96,16 +104,15 @@ class UserManagementRetreiveSerializer(serializers.ModelSerializer):
def get_image(self, user):
request = self.context.get('request')
primayPic = user.user_images.first()
# print(primayPic)
if user.user_images.count() >= 1:
primayPic = user.user_images.filter(is_primary=True).first()
ssl = config['SETTINGS']['SSL']
if primayPic:
path = request.build_absolute_uri(primayPic.image.url)
path = path.replace('https', 'http')
if ssl == 1:
path = path.replace('http', 'https')
else:
path = path.replace('https', 'http')
return path
# if primayPic:
# path = request.build_absolute_uri(primayPic.image.url)
# path = path.replace('http', 'https')
# return path
else:
return request.build_absolute_uri('/media/no-user.png')
......
......@@ -64,6 +64,7 @@ REALTIMESERVER_IP = 127.0.0.1:8000
[SETTINGS]
CONFIG = config.settings.local
BATCH_UPLOAD_FORMAT_FILENAME = instruction.pdf
SSL = 1
[NOTIFICATION_EMAIL]
APPROVER_MESSAGE = has sent you an APPROVAL REQUEST for change request;RMS-ACTIONREQUIRED
......
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