def delete(self, request, *args, **kwargs): file_id = kwargs.get('file_id', None) if file_id is not None: file_list = file_id.split(",") for id in file_list: AccountService.delete_tempfile(id) return response.Response(status=status.HTTP_204_NO_CONTENT)
def update_user_info(request): message = True try: AccountService.update_user_info(request) except Exception as ex: SimpleLogger.error(ex) message = str(ex) print(message) return HttpResponse(message)
def avatar_file(request, mongo_file_id): try: contents = AccountService.get_avatar_file(request, mongo_file_id) result = HttpResponse(contents, content_type='image/jpeg') except Exception as ex: SimpleLogger.error(str(ex)) return result
def member_avatar(self): result = "/static/global/images/fruit-avatar/Fruit-1.png" try: if self.member.extend_info: result = AccountService.get_avatar_url(self.member) except Exception as ex: SimpleLogger.exception(ex) return result
def get_avatar(self, obj): result = "/static/global/images/fruit-avatar/Fruit-1.png" try: user = UserService.get_user(int(obj.PMMember)) if user.extend_info: result = AccountService.get_avatar_url(user) except Exception as ex: SimpleLogger.exception(ex) return result
def creator_avatar(self, issue): result = "/static/global/images/fruit-avatar/Fruit-1.png" try: creator = User.objects.get(id=issue.Creator) if creator.extend_info: result = AccountService.get_avatar_url(creator) except Exception as ex: SimpleLogger.exception(ex) return result
def user_avatar(self): result = "/static/global/images/fruit-avatar/Fruit-1.png" try: action_user = User.objects.get(id=self.action_log.User) if action_user.extend_info: result = AccountService.get_avatar_url(action_user) except Exception as ex: SimpleLogger.exception(ex) return result
def start_by_avatar(self): result = "/static/global/images/caton/caton1.jpeg" try: ci_task_history = CITaskHistory.objects.get_history_by_tq( self.ci_task_queue.id) started_by = User.objects.get(id=ci_task_history.StartedBy) if started_by.extend_info: result = AccountService.get_avatar_url(started_by) except Exception as ex: SimpleLogger.exception(ex) return result
def get(self, request, *args, **kwargs): result = None try: file_id = kwargs.get('file_id') if file_id.isnumeric(): result = AccountService.download_attachment( file_id, UCenterMongoFile) else: result = TempFileMongoFile.objects.get(file_id) except Exception as ex: result = str(ex) SimpleLogger.exception(ex) return HttpResponse(result, content_type="application/octet-stream")
def upload_avatar(request,userid): account_avatar="" try: message=AccountService.avatar_upload_handler(request) if message=="": message=Account.ucenter_upload_avatar_fail else: account_avatar="/ucenter/account/get_avatar/"+message message="" except Exception as ex: SimpleLogger.exception(ex) message=Account.ucenter_upload_avatar_fail return redirect("/ucenter/"+str(userid)+"/account/avatar?message="+message+"&account_avatar="+account_avatar)
def post(self, request, *args, **kwargs): ''' :param request: /api/ucenter/attachment/upload :param args: :param kwargs: :return: ''' file = request.FILES['file'] message = AccountService.cache_issue_attachments(file, request.user) if message['cache_key'] != "": return response.Response({ 'file_id': message["cache_key"], 'url': WEB_HOST + '/api/ucenter/profiles/download_file/' + str(message['cache_key']) }) else: return response.Response(message, status=status.HTTP_417_EXPECTATION_FAILED)
def avatar(self): self.avatar_url = AccountService.get_avatar_url(self.user)
def commitor_avatar(self): result = "/static/global/images/fruit-avatar/Fruit-1.png" commitor = User.objects.get(id=self.fortesting.Commitor) if commitor.extend_info: result = AccountService.get_avatar_url(commitor) return result
def user_avatar(self): result = "/static/global/images/fruit-avatar/Fruit-1.png" if self.user.extend_info: result = AccountService.get_avatar_url(self.user) return result
def get_avatar(self, obj): return AccountService.get_avatar_url(obj)
def borrower_avatar(self): result = "/static/global/images/fruit-avatar/Fruit-1.png" if self.device.DeviceBorrower: borrower = UserService.get_user(self.device.DeviceBorrower) result = AccountService.get_avatar_url(borrower) return result
def patch(self, request, *args, **kwargs): attachment_key = request.data.get('uploadList', []) AccountService.update_avatar(request.user, attachment_key) return response.Response(status=status.HTTP_202_ACCEPTED)