Skip to content

Commit

Permalink
Merge pull request #1540 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
Dev dev
  • Loading branch information
Aashish Vinu authored Nov 7, 2023
2 parents 0325174 + 962959e commit 9c1aff9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions api/dashboard/profile/profile_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from django.db.models import F, Sum, Q
from rest_framework import serializers
from rest_framework.serializers import ModelSerializer
from decouple import config as decouple_config

from db.organization import UserOrganizationLink
from db.task import InterestGroup, KarmaActivityLog, Level, TaskList, Wallet, UserIgLink, UserLvlLink
Expand Down Expand Up @@ -60,14 +59,16 @@ class Meta:
"interest_groups",
"is_public",
)

def get_profile_pic(self,obj):
fs = FileSystemStorage()
path = f'user/profile/{obj.id}.png'
if fs.exists(path):
profile_pic = f"{decouple_config('FR_DOMAIN_NAME')}{fs.url(path)}"
profile_pic = f"{self.context.get('request').build_absolute_uri('/')}{fs.url(path)[1:]}"
else:
profile_pic = obj.profile_pic
return profile_pic

def get_roles(self, obj):
return list({link.role.title for link in obj.user_role_link_user.all()})

Expand Down
3 changes: 2 additions & 1 deletion api/dashboard/profile/profile_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def get(self, request, muid=None):

serializer = profile_serializer.UserProfileSerializer(
user,
many=False
many=False,
context={'request':request}
)

return CustomResponse(
Expand Down
3 changes: 1 addition & 2 deletions api/dashboard/user/dash_user_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from utils.utils import CommonUtils, DateTimeUtils, DiscordWebhooks, send_template_mail
from . import dash_user_serializer
from django.core.files.storage import FileSystemStorage
from decouple import config as decouple_config

class UserInfoAPI(APIView):
authentication_classes = [CustomizePermission]
Expand Down Expand Up @@ -420,7 +419,7 @@ def post(self, request):
fs.delete(filename)
filename = fs.save(filename, pic)
file_url = fs.url(filename)
uploaded_file_url = f"{decouple_config('FR_DOMAIN_NAME')}{file_url}"
uploaded_file_url = f"{request.build_absolute_uri('/')}{file_url[1:]}"

return CustomResponse(
response={
Expand Down
9 changes: 5 additions & 4 deletions mulearnbackend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
"""

from django.conf import settings
from django.conf.urls.static import static
# from django.conf.urls.static import static
# from django.contrib import admin
from django.urls import path, include
from django.urls import path, include, re_path
from django.views.static import serve

urlpatterns = [
# path('admin/', admin.site.urls),
path('api/v1/', include('api.urls')),

re_path(r'^muback-media/(?P<path>.*)$',serve,{'document_root':settings.MEDIA_ROOT})
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

0 comments on commit 9c1aff9

Please sign in to comment.