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

Merge pull request #668 in RMS/api-main-service from red-develop to product-dev

* commit '52aaf81d':
  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
parents 4dadba2e 52aaf81d
...@@ -12,6 +12,14 @@ from app.entities.models import ( ...@@ -12,6 +12,14 @@ from app.entities.models import (
ChangeRequestSettings ChangeRequestSettings
) )
import os
import configparser
config = configparser.ConfigParser()
config_file = os.path.join('./', 'env.ini')
config.read(config_file)
class UserManagementRetreiveSerializer(serializers.ModelSerializer): class UserManagementRetreiveSerializer(serializers.ModelSerializer):
image = serializers.SerializerMethodField() image = serializers.SerializerMethodField()
...@@ -96,16 +104,15 @@ class UserManagementRetreiveSerializer(serializers.ModelSerializer): ...@@ -96,16 +104,15 @@ class UserManagementRetreiveSerializer(serializers.ModelSerializer):
def get_image(self, user): def get_image(self, user):
request = self.context.get('request') request = self.context.get('request')
primayPic = user.user_images.first() primayPic = user.user_images.filter(is_primary=True).first()
# print(primayPic) ssl = config['SETTINGS']['SSL']
if user.user_images.count() >= 1: if primayPic:
path = request.build_absolute_uri(primayPic.image.url) 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 return path
# if primayPic:
# path = request.build_absolute_uri(primayPic.image.url)
# path = path.replace('http', 'https')
# return path
else: else:
return request.build_absolute_uri('/media/no-user.png') return request.build_absolute_uri('/media/no-user.png')
......
...@@ -64,6 +64,7 @@ REALTIMESERVER_IP = 127.0.0.1:8000 ...@@ -64,6 +64,7 @@ REALTIMESERVER_IP = 127.0.0.1:8000
[SETTINGS] [SETTINGS]
CONFIG = config.settings.local CONFIG = config.settings.local
BATCH_UPLOAD_FORMAT_FILENAME = instruction.pdf BATCH_UPLOAD_FORMAT_FILENAME = instruction.pdf
SSL = 1
[NOTIFICATION_EMAIL] [NOTIFICATION_EMAIL]
APPROVER_MESSAGE = has sent you an APPROVAL REQUEST for change request;RMS-ACTIONREQUIRED 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