def dispatch(self, request, account_id, *args, **kwargs): self.required_account = utils.get_account(account_id) self.logged_account = request.user.account if request.user.is_authenticated() else None self.own_profile = self.required_account == self.logged_account self.elements_per_page = 5 self.page = 1 return super(ReportsView, self).dispatch(request, *args, **kwargs)
def get_friends(request, account_id): account = utils.get_account(account_id) others = request.GET.get('others') and request.GET.get('others').split(',') or [] friends = utils.get_friends_number_matches(account, others) serialized = [] if friends: for f in friends: friend = serializers.account_serializer(f) friend['qtd'] = f.qtd serialized.append(friend) return JsonResponse({'friends': serialized})
def get_profile(request, account_id): account = utils.get_account(account_id) serialized = serializers.account_serializer(account) return JsonResponse(serialized)