mirror of
https://github.com/fergalmoran/dss.git
synced 2025-12-26 03:27:33 +00:00
First draft user profile sidebar
This commit is contained in:
@@ -4,6 +4,7 @@ from tastypie.authentication import Authentication
|
||||
from tastypie.authorization import DjangoAuthorization
|
||||
from spa.api.v1.BackboneCompatibleResource import BackboneCompatibleResource
|
||||
from spa.models import UserProfile
|
||||
from django.conf.urls import url
|
||||
|
||||
|
||||
class UserProfileResource(BackboneCompatibleResource):
|
||||
@@ -19,7 +20,6 @@ class UserProfileResource(BackboneCompatibleResource):
|
||||
def _hydrateBitmapOption(self, source, comparator):
|
||||
return "checked" if (source & comparator) != 0 else ""
|
||||
|
||||
|
||||
def hydrate(self, bundle):
|
||||
if 'activity_sharing_likes' in bundle.data:
|
||||
likes = UserProfile.ACTIVITY_SHARE_LIKES if bundle.data['activity_sharing_likes'] else 0
|
||||
@@ -55,6 +55,8 @@ class UserProfileResource(BackboneCompatibleResource):
|
||||
def dehydrate(self, bundle):
|
||||
del bundle.data['activity_sharing']
|
||||
del bundle.data['activity_sharing_networks']
|
||||
bundle.data['display_name'] = bundle.obj.get_nice_name()
|
||||
bundle.data['avatar_image'] = bundle.obj.get_avatar_image()
|
||||
if bundle.obj.user.id == bundle.request.user.id:
|
||||
bundle.data['activity_sharing_likes'] = \
|
||||
self._hydrateBitmapOption(bundle.obj.activity_sharing, UserProfile.ACTIVITY_SHARE_LIKES)
|
||||
@@ -80,6 +82,12 @@ class UserResource(BackboneCompatibleResource):
|
||||
authorization = DjangoAuthorization()
|
||||
authentication = Authentication()
|
||||
|
||||
def prepend_urls(self):
|
||||
return [
|
||||
url(r"^(?P<resource_name>%s)/(?P<pk>\d+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
|
||||
url(r"^(?P<resource_name>%s)/(?P<userprofile__slug>[\w\d_.-]+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
|
||||
]
|
||||
|
||||
def dehydrate(self, bundle):
|
||||
if bundle.obj.id != bundle.request.user.id:
|
||||
del bundle.data['email']
|
||||
|
||||
Reference in New Issue
Block a user