diff --git a/dss/settings.py b/dss/settings.py index 13171ad..51f78b7 100644 --- a/dss/settings.py +++ b/dss/settings.py @@ -1,4 +1,4 @@ -## Django settings for dss project. +#e Django settings for dss project. from datetime import timedelta import os @@ -44,9 +44,9 @@ USE_L10N = True USE_TZ = True SITE_ROOT = here('') -MEDIA_ROOT = here('media') +MEDIA_ROOT = here('../media') STATIC_ROOT = here('static') #localsettings.STATIC_ROOT if hasattr(localsettings, 'STATIC_ROOT') else '' -CACHE_ROOT = here('media/cache') +CACHE_ROOT = here('../media/cache') if DEBUG: STATIC_URL = '/static/' @@ -133,8 +133,8 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'spa.middleware.uploadify.SWFUploadMiddleware', - 'spa.middleware.sqlprinter.SqlPrintingMiddleware', - 'debug_toolbar.middleware.DebugToolbarMiddleware', + #'spa.middleware.sqlprinter.SqlPrintingMiddleware', + #'debug_toolbar.middleware.DebugToolbarMiddleware', ) WSGI_APPLICATION = 'dss.wsgi.application' diff --git a/spa/api/v1/UserResource.py b/spa/api/v1/UserResource.py index 5ac4313..699e255 100644 --- a/spa/api/v1/UserResource.py +++ b/spa/api/v1/UserResource.py @@ -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%s)/(?P\d+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"), + url(r"^(?P%s)/(?P[\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'] diff --git a/static/img/toolbar-loader.gif b/static/img/toolbar-loader.gif new file mode 100644 index 0000000..6e4bfde Binary files /dev/null and b/static/img/toolbar-loader.gif differ diff --git a/static/js/app/app.js b/static/js/app/app.js index 720138c..aebda69 100644 --- a/static/js/app/app.js +++ b/static/js/app/app.js @@ -9,6 +9,7 @@ var AppRouter = Backbone.Router.extend({ root: '/', routes: { + "debug": "debug", "mixes": "mixList", "mixes/:type": "mixList", "mix/upload": "mixUpload", @@ -52,15 +53,46 @@ var AppRouter = Backbone.Router.extend({ } }, + debug: function () { + var model = new User({ + id: 'fergal' + }); + model.fetch({ + success: function(){ + var content= new SidebarViewUser({ + model: model + }); + $('#content').html(content.render().el); + } + }); + }, user: function (user) { this._renderMixList('latest', { "user": user }); var model = new User({ id: user }); - this.sidebarView = new SidebarViewUser({ - model: model + model.fetch({ + success: function(){ + var content= new SidebarViewUser({ + model: model + }); + $('#sidebar').html(content.render().el); + } + }); + }, + userDetails: function () { + var user = new User({ + id: com.podnoms.settings.currentUser + }); + $('#site-content-fill').html(''); + user.fetch({ + success: function () { + var content = new UserView({ + model: user + }); + $('#content').html(content.render().el); + } }); - $('#sidebar').html(this.sidebarView.el); }, mixList: function (type) { this._renderMixList(type); @@ -84,8 +116,7 @@ var AppRouter = Backbone.Router.extend({ var mixes = new MixListView({ collection: mixList }); - var content = mixes.el; - $('#content').html(content); + $('#content').html(mixes.el); if (mixes.itemPlaying != null) { com.podnoms.settings.setupPlayer(mixes.itemPlaying.toJSON(), mixes.itemPlaying.get('id')); } @@ -119,7 +150,7 @@ var AppRouter = Backbone.Router.extend({ }, mixEdit: function (id) { var mix = new Mix({ - id: id + slug: id }); mix.fetch({ success: function () { @@ -219,20 +250,6 @@ var AppRouter = Backbone.Router.extend({ }, connectAccounts: function () { alert("Connecting accounts"); - }, - userDetails: function () { - var user = new User({ - id: com.podnoms.settings.currentUser - }); - $('#site-content-fill').html(''); - user.fetch({ - success: function () { - var content = new UserView({ - model: user - }); - $('#content').html(content.render().el); - } - }); } }); diff --git a/static/js/app/site.js b/static/js/app/site.js index c43f0e2..005e33e 100644 --- a/static/js/app/site.js +++ b/static/js/app/site.js @@ -7,6 +7,7 @@ */ $(document).ready(function () { + $('#ajax-request').hide(); if (window.location.hash == '#_=_') { window.location.hash = ""; } @@ -14,7 +15,14 @@ $(document).ready(function () { Backbone.history.navigate("/"); } }); - +$(document).on({ + ajaxStart: function () { + $('#ajax-request').show(); + }, + ajaxStop: function () { + $('#ajax-request').hide(); + } +}); $(document).ajaxSend(function (event, xhr, settings) { function getCookie(name) { var cookieValue = null; diff --git a/static/js/app/views/header.js b/static/js/app/views/header.js index 4972fe2..35a7e7a 100644 --- a/static/js/app/views/header.js +++ b/static/js/app/views/header.js @@ -23,15 +23,6 @@ window.HeaderView = Backbone.View.extend({ }, login: function () { com.podnoms.utils.modal('tpl/LoginView'); - return; - $.colorbox({ - href: "/tpl/LoginView/", - onClosed: function () { - Backbone.history.navigate('/', { - trigger: true - }); - } - }); }, logout: function () { com.podnoms.utils.showAlert("Success", "You are now logged out"); diff --git a/static/js/app/views/sidebaruser.js b/static/js/app/views/sidebaruser.js index 9f98b8e..fbb95eb 100644 --- a/static/js/app/views/sidebaruser.js +++ b/static/js/app/views/sidebaruser.js @@ -10,11 +10,10 @@ window.SidebarViewUser = Backbone.View.extend({ events: { }, - initialize: function () { - this.render(); - }, render: function () { - $(this.el).html(this.template({"item":this.model.toJSON()})); + ich.addTemplate('sidebaruser', this.template()); + var rendered = ich.sidebaruser(this.model.toJSON()); + $(this.el).html(rendered); return this; } -}); \ No newline at end of file +}); diff --git a/static/js/app/views/user.js b/static/js/app/views/user.js index cf5ed82..b881f5d 100644 --- a/static/js/app/views/user.js +++ b/static/js/app/views/user.js @@ -12,8 +12,6 @@ UserView = DSSEditableView.extend({ "click #save-changes": "saveChanges", "change input[type=radio]": "selectAvatar" }, - initialize: function () { - }, render: function () { ich.addTemplate('user', this.template()); var renderedTemplate = ich.user(this.model.toJSON()); diff --git a/templates/views/HeaderView.html b/templates/views/HeaderView.html index 70adbd3..354a6c0 100644 --- a/templates/views/HeaderView.html +++ b/templates/views/HeaderView.html @@ -2,9 +2,9 @@ {% load spa_extras %}