diff --git a/spa/ajax.py b/spa/ajax.py index e5263c7..6a519d9 100644 --- a/spa/ajax.py +++ b/spa/ajax.py @@ -178,7 +178,7 @@ def toggle_follow(request): try: if request.is_ajax() and request.method == 'POST' and 'userId' in request.POST: profile = request.user.get_profile() - following = UserProfile.objects.get(pk=request.POST['userId']) + following = UserProfile.objects.get(user__id=request.POST['userId']) if following is not None: if profile.followers is None or (following not in profile.followers.all()): profile.add_follower(following) diff --git a/spa/api/v1/UserResource.py b/spa/api/v1/UserResource.py index 201fe1a..96681bb 100644 --- a/spa/api/v1/UserResource.py +++ b/spa/api/v1/UserResource.py @@ -5,7 +5,7 @@ from tastypie.authorization import DjangoAuthorization from django.conf.urls import url from spa.api.v1.BackboneCompatibleResource import BackboneCompatibleResource -from spa.models import UserProfile +from spa.models import UserProfile, Mix class UserProfileResource(BackboneCompatibleResource): @@ -75,9 +75,9 @@ class UserProfileResource(BackboneCompatibleResource): self._hydrateBitmapOption(bundle.obj.activity_sharing_networks, UserProfile.ACTIVITY_SHARE_NETWORK_TWITTER) - bundle.data['mix_count'] = 4 - bundle.data['follower_count'] = 4 - bundle.data['following_count'] = 8 + bundle.data['mix_count'] = Mix.objects.filter(user=bundle.obj).count() + bundle.data['follower_count'] = bundle.obj.followers.count() + bundle.data['following_count'] = bundle.obj.following.count() bundle.data['following'] = bundle.obj.is_follower(bundle.request.user) return bundle diff --git a/templates/views/SidebarViewUser.html b/templates/views/SidebarViewUser.html index b623dc6..603adab 100644 --- a/templates/views/SidebarViewUser.html +++ b/templates/views/SidebarViewUser.html @@ -3,6 +3,8 @@