|
|
|
@ -42,6 +42,10 @@ class Researchers(viewsets.ModelViewSet):
@@ -42,6 +42,10 @@ class Researchers(viewsets.ModelViewSet):
|
|
|
|
|
def update(self, request, *args, **kwargs): |
|
|
|
|
# Set a 'fake' pk value so we can use the normal serializer update |
|
|
|
|
request.parser_context['kwargs']['pk'] = request.user.researcher.id |
|
|
|
|
if request.data.get('avatar') and (request.data['avatar'].startswith('/media/') or request.data['avatar'].startswith('http://') or request.data['avatar'].startswith('https://')): |
|
|
|
|
# Do not change the existing avatar image. |
|
|
|
|
del(request.data['avatar']) |
|
|
|
|
|
|
|
|
|
super().update(request, *args, **kwargs) |
|
|
|
|
# Reload the data from DB |
|
|
|
|
researcher = get_object_or_404(Researcher, pk=request.user.researcher.id) |
|
|
|
|