From 8d07c328d87ba2fc76376fa80862a8b2287975ac Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Mon, 29 Jul 2013 19:56:28 +0100 Subject: [PATCH] Removed notifications for anonymous user --- spa/embedding/__init__.py | 2 +- .../app/lib/backbone.dss.model.collection.js | 61 ------------------- static/js/app/views/widgets/headerView.coffee | 3 +- static/js/app/views/widgets/headerView.js | 13 ++-- 4 files changed, 10 insertions(+), 69 deletions(-) diff --git a/spa/embedding/__init__.py b/spa/embedding/__init__.py index 6d4caf8..8133f5e 100644 --- a/spa/embedding/__init__.py +++ b/spa/embedding/__init__.py @@ -1 +1 @@ -__author__ = 'fergalm' +__author__ = 'fergalm' diff --git a/static/js/app/lib/backbone.dss.model.collection.js b/static/js/app/lib/backbone.dss.model.collection.js index 3b3978d..d8c3f2b 100755 --- a/static/js/app/lib/backbone.dss.model.collection.js +++ b/static/js/app/lib/backbone.dss.model.collection.js @@ -4,67 +4,6 @@ define(['backbone'], function (Backbone) { this.meta = response.meta || {}; this.page_count = Math.ceil(this.meta.total_count / this.meta.limit); return response.objects || response; - }, - /* - sync: function (method, model, options) { - var headers = {}; - - if (Backbone.Tastypie.apiKey && Backbone.Tastypie.apiKey.username) { - headers[ 'Authorization' ] = 'ApiKey ' + Backbone.Tastypie.apiKey.username + ':' + Backbone.Tastypie.apiKey.key; - } - - if (Backbone.Tastypie.csrfToken) { - headers[ 'X-CSRFToken' ] = Backbone.Tastypie.csrfToken; - } - - // Keep `headers` for a potential second request - headers = _.extend(headers, options.headers); - options.headers = headers; - - if (( method === 'create' && Backbone.Tastypie.doGetOnEmptyPostResponse ) || - ( method === 'update' && Backbone.Tastypie.doGetOnEmptyPutResponse )) { - var dfd = new $.Deferred(); - - // Set up 'success' handling - var success = options.success; - dfd.done(function (resp, textStatus, xhr) { - _.isFunction(success) && success(resp); - }); - - options.success = function (resp, textStatus, xhr) { - // If create is successful but doesn't return a response, fire an extra GET. - // Otherwise, resolve the deferred (which triggers the original 'success' callbacks). - if (!resp && ( xhr.status === 201 || xhr.status === 202 || xhr.status === 204 )) { // 201 CREATED, 202 ACCEPTED or 204 NO CONTENT; response null or empty. - var location = xhr.getResponseHeader('Location') || model.id; - return Backbone.ajax({ - url: location, - headers: headers, - success: dfd.resolve, - error: dfd.reject - }); - } - else { - return dfd.resolveWith(options.context || options, [ resp, textStatus, xhr ]); - } - }; - - // Set up 'error' handling - var error = options.error; - dfd.fail(function (xhr, textStatus, errorThrown) { - _.isFunction(error) && error(xhr.responseText); - }); - - options.error = function (xhr, textStatus, errorText) { - dfd.rejectWith(options.context || options, [ xhr, textStatus, xhr.responseText ]); - }; - - // Create the request, and make it accessibly by assigning it to the 'request' property on the deferred - dfd.request = Backbone.oldSync(method, model, options); - return dfd; - } - - return Backbone.oldSync(method, model, options); } - */ }) }); diff --git a/static/js/app/views/widgets/headerView.coffee b/static/js/app/views/widgets/headerView.coffee index b5b94d8..5e039c1 100755 --- a/static/js/app/views/widgets/headerView.coffee +++ b/static/js/app/views/widgets/headerView.coffee @@ -36,7 +36,8 @@ define ["underscore", "marionette", "vent", "utils", "views/widgets/searchView", onShow: -> @searchRegion.show(new SearchView()) - @notificationsRegion.show(new NotificationsListView()) + if com.podnoms.settings.currentUser != -1 + @notificationsRegion.show(new NotificationsListView()) login: -> vent.trigger('app:login') diff --git a/static/js/app/views/widgets/headerView.js b/static/js/app/views/widgets/headerView.js index 5be6451..d1d9ab0 100644 --- a/static/js/app/views/widgets/headerView.js +++ b/static/js/app/views/widgets/headerView.js @@ -1,4 +1,5 @@ -// Generated by CoffeeScript 1.6.2 +// Generated by CoffeeScript 1.3.3 + /* @license @@ -14,16 +15,14 @@ Code provided under the BSD License: __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; define(["underscore", "marionette", "vent", "utils", "views/widgets/searchView", "views/notifications/notificationsListView", "text!/tpl/HeaderView"], function(_, Marionette, vent, utils, SearchView, NotificationsListView, Template) { - var HeaderView, _ref; - + var HeaderView; HeaderView = (function(_super) { var NowrapRegion; __extends(HeaderView, _super); function HeaderView() { - _ref = HeaderView.__super__.constructor.apply(this, arguments); - return _ref; + return HeaderView.__super__.constructor.apply(this, arguments); } NowrapRegion = Marionette.Region.extend({ @@ -60,7 +59,9 @@ Code provided under the BSD License: HeaderView.prototype.onShow = function() { this.searchRegion.show(new SearchView()); - return this.notificationsRegion.show(new NotificationsListView()); + if (com.podnoms.settings.currentUser !== -1) { + return this.notificationsRegion.show(new NotificationsListView()); + } }; HeaderView.prototype.login = function() {