diff --git a/.gitignore b/.gitignore index 872db17..4a39be4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .gitignore~ tags .tags +.tags_sorted_by_file .idea *.pyc media/* diff --git a/dss/settings.py b/dss/settings.py index 84fc46c..4b8a402 100644 --- a/dss/settings.py +++ b/dss/settings.py @@ -22,6 +22,7 @@ ADMINS = ( MANAGERS = ADMINS AUTH_PROFILE_MODULE = 'spa.UserProfile' + ALLOWED_HOSTS = localsettings.ALLOWED_HOSTS if hasattr(localsettings, 'ALLOWED_HOSTS') else [] DATABASES = { 'default': { diff --git a/spa/api/v1/UserResource.py b/spa/api/v1/UserResource.py index f694add..65636f9 100644 --- a/spa/api/v1/UserResource.py +++ b/spa/api/v1/UserResource.py @@ -1,10 +1,10 @@ -from django.conf.urls import url from tastypie.authentication import Authentication from tastypie.authorization import Authorization -from tastypie.constants import ALL_WITH_RELATIONS +from tastypie.constants import ALL, ALL_WITH_RELATIONS from spa.api.v1.BackboneCompatibleResource import BackboneCompatibleResource from spa.models import UserProfile + class UserResource(BackboneCompatibleResource): class Meta: queryset = UserProfile.objects.all() @@ -14,7 +14,15 @@ class UserResource(BackboneCompatibleResource): always_return_data = True filtering = { 'user': ALL_WITH_RELATIONS, - } + 'username': ALL, + 'id': ALL, + } + + def full_dehydrate(self, bundle, for_list=False): + return super(UserResource, self).full_dehydrate(bundle, for_list) + + def authorized_read_list(self, object_list, bundle): + return object_list.filter(user_id=bundle.request.user.id) def dehydrate(self, bundle): bundle.data['display_name'] = bundle.obj.display_name @@ -23,25 +31,27 @@ class UserResource(BackboneCompatibleResource): bundle.data['email'] = bundle.obj.email if bundle.obj.activity_sharing is not None: - bundle.data['activity_share_likes'] = (bundle.obj.activity_sharing & UserProfile.ACTIVITY_SHARE_LIKES) != 0; - bundle.data['activity_share_favourites'] = (bundle.obj.activity_sharing & UserProfile.ACTIVITY_SHARE_FAVOURITES) != 0; - bundle.data['activity_share_comments'] = (bundle.obj.activity_sharing & UserProfile.ACTIVITY_SHARE_COMMENTS) != 0; + bundle.data['activity_share_likes'] = \ + (bundle.obj.activity_sharing & UserProfile.ACTIVITY_SHARE_LIKES) != 0 + bundle.data['activity_share_favourites'] = \ + (bundle.obj.activity_sharing & UserProfile.ACTIVITY_SHARE_FAVOURITES) != 0 + bundle.data['activity_share_comments'] = \ + (bundle.obj.activity_sharing & UserProfile.ACTIVITY_SHARE_COMMENTS) != 0 else: - bundle.data['activity_share_likes'] =0 - bundle.data['activity_share_favourites'] =0 - bundle.data['activity_share_comments'] =0 + bundle.data['activity_share_likes'] = 0 + bundle.data['activity_share_favourites'] = 0 + bundle.data['activity_share_comments'] = 0 if bundle.obj.activity_sharing_networks is not None: - bundle.data['activity_share_networks_facebook'] = (bundle.obj.activity_sharing_networks & UserProfile.ACTIVITY_SHARE_NETWORK_FACEBOOK) != 0; - bundle.data['activity_share_networks_twitter'] = (bundle.obj.activity_sharing_networks& UserProfile.ACTIVITY_SHARE_NETWORK_TWITTER) != 0; + bundle.data['activity_share_networks_facebook'] = \ + (bundle.obj.activity_sharing_networks & UserProfile.ACTIVITY_SHARE_NETWORK_FACEBOOK) != 0 + bundle.data['activity_share_networks_twitter'] = \ + (bundle.obj.activity_sharing_networks & UserProfile.ACTIVITY_SHARE_NETWORK_TWITTER) != 0 else: bundle.data['activity_share_networks_facebook'] = 0 bundle.data['activity_share_networks_facebook'] = 0 - return bundle - def apply_authorization_limits(self, request, object_list): - if request.user is not None: - return object_list.filter(user=request.user) + return bundle def hydrate_slug(self, bundle): if bundle.data['slug'] == '': diff --git a/spa/api/v1/tests.py b/spa/api/v1/tests.py new file mode 100644 index 0000000..194a99e --- /dev/null +++ b/spa/api/v1/tests.py @@ -0,0 +1,18 @@ +import datetime +from django.contrib.auth.models import User +from tastypie.test import ResourceTestCase + + +class UserProfileResourceTest(ResourceTestCase): + fixtures = ['test_entries.json'] + + def setUp(self): + self.deteail_url = '/api/v1/user/' + + def test_put_detail(self): + # Grab the current data & modify it slightly. + original_data = self.deserialize(self.api_client.get(self.detail_url, format='json', authentication=self.get_credentials())) + new_data = original_data.copy() + new_data['title'] = 'Updated: First Post' + new_data['created'] = '2012-05-01T20:06:12' + diff --git a/spa/models/UserProfile.py b/spa/models/UserProfile.py index 90c34e9..f055546 100644 --- a/spa/models/UserProfile.py +++ b/spa/models/UserProfile.py @@ -57,11 +57,13 @@ class UserProfile(_BaseModel): return super(UserProfile, self).save(force_insert, force_update, using) + """ def create_user_profile(sender, instance, created, **kwargs): if created: UserProfile.objects.create(user=instance) post_save.connect(create_user_profile, sender=User) + """ def get_username(self): return self.user.username diff --git a/static/css/deepsouthsounds.css b/static/css/deepsouthsounds.css index 61b7d08..8d7be37 100644 --- a/static/css/deepsouthsounds.css +++ b/static/css/deepsouthsounds.css @@ -354,6 +354,7 @@ div.event-content td { #sidebar-content-activity { font-size: 85%; } -.no-click{ - cursor: pointer; +[data-bypass="true"] { + /* Styles */ + cursor: pointer; } \ No newline at end of file diff --git a/static/js/app/models/user.js b/static/js/app/models/user.js index ce44452..0e15abb 100644 --- a/static/js/app/models/user.js +++ b/static/js/app/models/user.js @@ -10,8 +10,6 @@ var User = DSSModel.extend({ urlRoot:com.podnoms.settings.urlRoot + "user/", isValid:function () { this.errors = {}; - return ""; } - }); diff --git a/templates/views/HeaderView.html b/templates/views/HeaderView.html index 95850a0..0fb99e2 100644 --- a/templates/views/HeaderView.html +++ b/templates/views/HeaderView.html @@ -19,6 +19,7 @@ Logout  + {% else %}