diff --git a/spa/models/comment.py b/spa/models/comment.py index 4e9070a..3a2a22e 100755 --- a/spa/models/comment.py +++ b/spa/models/comment.py @@ -1,9 +1,9 @@ from django.contrib.auth.models import User from django.db import models -from spa.models._basemodel import _BaseModel +from spa.models import _BaseModel, UserProfile +from spa.models.notification import Notification from spa.models.mix import Mix - class Comment(_BaseModel): class Meta: app_label = 'spa' @@ -17,3 +17,21 @@ class Comment(_BaseModel): def get_absolute_url(self): return '/comment/%i' % self.id + def create_notification(self): + notification = Notification() + notification.to_user = self.mix.user.user + notification.notification_url = self.mix.get_absolute_url() + notification.verb = "Commented on" + notification.target = self.mix.title + + if self.user is not None: + notification.from_user = self.user.get_profile() + notification.notification_text = "%s %s %s" % ( + self.user.get_profile().get_nice_name(), notification.verb, self.mix.title + ) + else: + notification.notification_text = "%s %s %s" % ( + "Anonymouse", notification.verb, self.mix.title + ) + + notification.save() diff --git a/spa/models/notification.py b/spa/models/notification.py index c9c1fad..cf067bf 100644 --- a/spa/models/notification.py +++ b/spa/models/notification.py @@ -1,3 +1,4 @@ +from django.contrib.auth.models import User import threading from django.db import models from core.realtime.notification import post_notification @@ -17,7 +18,7 @@ class NotificationThread(threading.Thread): class Notification(_BaseModel): - to_user = models.ForeignKey(UserProfile, related_name='to_notications') + to_user = models.ForeignKey(User, related_name='to_notications') from_user = models.ForeignKey(UserProfile, related_name='notifications', null=True, blank=True) date = models.DateTimeField(auto_now=True) diff --git a/static/js/app/appv2.js b/static/js/app/appv2.js index dc650d4..98e4a07 100755 --- a/static/js/app/appv2.js +++ b/static/js/app/appv2.js @@ -1,137 +1,140 @@ // Generated by CoffeeScript 1.4.0 +(function() { -define(['backbone', 'marionette', 'vent', 'utils', 'app.lib/social', 'app.lib/router', 'app.lib/panningRegion', 'app.lib/realtimeController', 'app.lib/audioController', 'models/user/userItem', 'models/mix/mixCollection', 'views/widgets/headerView', 'views/sidebar/sidebarView'], function(Backbone, Marionette, vent, utils, social, DssRouter, PanningRegion, RealtimeController, AudioController, UserItem, MixCollection, HeaderView, SidebarView) { - var App, sidebarView; - App = new Marionette.Application(); - App.audioController = new AudioController(); - App.realtimeController = new RealtimeController(); - App.realtimeController.startSocketIO(); - App.vent.on("routing:started", function() { - var enablePushState, pushState; - console.log("App(vent): routing:started"); - enablePushState = true; - pushState = !!(enablePushState && window.history && window.history.pushState); - Backbone.history.start({ - pushState: pushState, - hashChange: true + define(['backbone', 'marionette', 'vent', 'utils', 'app.lib/social', 'app.lib/router', 'app.lib/panningRegion', 'app.lib/realtimeController', 'app.lib/audioController', 'models/user/userItem', 'models/mix/mixCollection', 'views/widgets/headerView', 'views/sidebar/sidebarView'], function(Backbone, Marionette, vent, utils, social, DssRouter, PanningRegion, RealtimeController, AudioController, UserItem, MixCollection, HeaderView, SidebarView) { + var App, sidebarView; + App = new Marionette.Application(); + App.audioController = new AudioController(); + App.realtimeController = new RealtimeController(); + App.realtimeController.startSocketIO(); + App.vent.on("routing:started", function() { + var enablePushState, pushState; + console.log("App(vent): routing:started"); + enablePushState = true; + pushState = !!(enablePushState && window.history && window.history.pushState); + Backbone.history.start({ + pushState: pushState, + hashChange: true + }); + return true; }); - return true; - }); - App.addRegions({ - headerRegion: "#header", - contentRegion: { - selector: "#content" - }, - footerRegion: "#footer", - sidebarRegion: "#sidebar" - }); - App.addInitializer(function() { - console.log("App: routing starting"); - App.Router = new DssRouter(); - return App.vent.trigger("routing:started"); - }); - App.addInitializer(function() { - $(document).on("click", "a[href]:not([data-bypass])", function(evt) { - var href, root; - href = { - prop: $(this).prop("href"), - attr: $(this).attr("href") - }; - root = location.protocol + "//" + location.host + (App.root || '/'); - if (href.prop.slice(0, root.length) === root) { - evt.preventDefault(); - App.Router.navigate(href.attr, true); + App.addRegions({ + headerRegion: "#header", + contentRegion: { + selector: "#content" + }, + footerRegion: "#footer", + sidebarRegion: "#sidebar" + }); + App.addInitializer(function() { + console.log("App: routing starting"); + App.Router = new DssRouter(); + return App.vent.trigger("routing:started"); + }); + App.addInitializer(function() { + $(document).on("click", "a[href]:not([data-bypass])", function(evt) { + var href, root; + href = { + prop: $(this).prop("href"), + attr: $(this).attr("href") + }; + root = location.protocol + "//" + location.host + (App.root || '/'); + if (href.prop.slice(0, root.length) === root) { + evt.preventDefault(); + App.Router.navigate(href.attr, true); + return true; + } + }); + return true; + }); + App.addInitializer(function() { + this.listenTo(vent, "app:login", function() { + utils.modal("/dlg/LoginView"); return true; - } - }); - return true; - }); - App.addInitializer(function() { - this.listenTo(vent, "app:login", function() { - utils.modal("/dlg/LoginView"); - return true; - }); - this.listenTo(vent, "app:donate", function() { - console.log("App: donate"); - utils.modal("/dlg/Donate"); - return true; - }); - this.listenTo(vent, "mix:favourite", function(model) { - console.log("App(vent): mix:favourite"); - model.save('favourited', !model.get('favourited'), { - patch: true }); - return true; - }); - this.listenTo(vent, "mix:like", function(model, id, success, favourite) { - console.log("App(vent): mix:like"); - model.save('liked', !model.get('liked'), { - patch: true + this.listenTo(vent, "app:donate", function() { + console.log("App: donate"); + utils.modal("/dlg/Donate"); + return true; }); - return true; - }); - this.listenTo(vent, "mix:delete", function(model) { - console.log("App(vent): mix:like"); - return utils.messageBox("/dlg/DeleteMixConfirm", { - yes: function() { - console.log("Controller: mixDeleteYES!!"); - mix.destroy(); - return Backbone.history.navigate("/", { - trigger: true - }); - }, - no: function() { - return console.log("Controller: mixDeleteNO!!"); - } + this.listenTo(vent, "mix:favourite", function(model) { + console.log("App(vent): mix:favourite"); + model.save('favourited', !model.get('favourited'), { + patch: true + }); + return true; }); - }); - this.listenTo(vent, "user:follow", function(model) { - var target, user, - _this = this; - console.log("App(vent): user:follow"); - user = new UserItem({ - id: com.podnoms.settings.currentUser + this.listenTo(vent, "mix:like", function(model, id, success, favourite) { + console.log("App(vent): mix:like"); + model.save('liked', !model.get('liked'), { + patch: true + }); + return true; }); - target = com.podnoms.settings.urlRoot + "user/" + model.get("id") + "/"; - user.fetch({ - success: function() { - var f, newFollowers; - if (!model.get("is_following")) { - newFollowers = user.get("following").concat([target]); - user.save({ - "following": newFollowers, - "is_following": true, - patch: true + this.listenTo(vent, "mix:delete", function(model) { + console.log("App(vent): mix:like"); + return utils.messageBox("/dlg/DeleteMixConfirm", { + yes: function() { + console.log("Controller: mixDeleteYES!!"); + mix.destroy(); + return Backbone.history.navigate("/", { + trigger: true }); - model.set("is_following", true); - } else { - f = user.get("following"); - f.splice(f.indexOf(target), 1); - user.save({ - "following": f, - "is_following": false, - patch: true - }); - model.set("is_following", false); + }, + no: function() { + return console.log("Controller: mixDeleteNO!!"); } - } + }); + }); + this.listenTo(vent, "user:follow", function(model) { + var target, user, + _this = this; + console.log("App(vent): user:follow"); + user = new UserItem({ + id: com.podnoms.settings.currentUser + }); + target = com.podnoms.settings.urlRoot + "user/" + model.get("id") + "/"; + user.fetch({ + success: function() { + var f, newFollowers; + if (!model.get("is_following")) { + newFollowers = user.get("following").concat([target]); + user.save({ + "following": newFollowers, + "is_following": true, + patch: true + }); + model.set("is_following", true); + } else { + f = user.get("following"); + f.splice(f.indexOf(target), 1); + user.save({ + "following": f, + "is_following": false, + patch: true + }); + model.set("is_following", false); + } + } + }); + return true; + }); + return this.listenTo(vent, "mix:share", function(mode, model) { + console.log("App(vent): mix:share (" + mode + ")"); + if (mode === "facebook") { + social.sharePageToFacebook(model); + } else if (mode === "twitter") { + social.sharePageToTwitter(model); + } else if (mode === "embed") { + social.generateEmbedCode(model); + } + return true; }); - return true; - }); - return this.listenTo(vent, "mix:share", function(mode, model) { - console.log("App(vent): mix:share (" + mode + ")"); - if (mode === "facebook") { - social.sharePageToFacebook(model); - } else if (mode === "twitter") { - social.sharePageToTwitter(model); - } else if (mode === "embed") { - social.generateEmbedCode(model); - } - return true; }); + App.headerRegion.show(new HeaderView()); + sidebarView = new SidebarView(); + App.sidebarRegion.show(sidebarView); + return App; }); - App.headerRegion.show(new HeaderView()); - sidebarView = new SidebarView(); - App.sidebarRegion.show(sidebarView); - return App; -}); + +}).call(this); diff --git a/static/js/app/lib/controller.coffee b/static/js/app/lib/controller.coffee index 24876fe..f63e7a4 100755 --- a/static/js/app/lib/controller.coffee +++ b/static/js/app/lib/controller.coffee @@ -27,6 +27,9 @@ define ['app', 'marionette', 'vent', 'utils' @showMixList({stream: true}) showMixListType: (type) -> + @showMixList({order_by: type}) + + showMixListGenre: (type) -> @showMixList({genres__slug: type, order_by: 'latest'}) showMix: (slug)-> diff --git a/static/js/app/lib/controller.js b/static/js/app/lib/controller.js index 604c461..6a796d0 100755 --- a/static/js/app/lib/controller.js +++ b/static/js/app/lib/controller.js @@ -1,217 +1,226 @@ // Generated by CoffeeScript 1.4.0 -var __hasProp = {}.hasOwnProperty, - __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; }; +(function() { + var __hasProp = {}.hasOwnProperty, + __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(['app', 'marionette', 'vent', 'utils', 'views/mix/mixListLayout', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView', 'views/user/userProfileView', 'views/user/userListView', 'views/user/userEditView', 'models/mix/mixCollection', 'models/mix/mixItem', 'models/user/userItem'], function(App, Marionette, vent, utils, MixListLayout, MixListView, MixDetailView, MixEditView, UserProfileView, UserListView, UserEditView, MixCollection, MixItem, UserItem) { - var DssController; - DssController = (function(_super) { + define(['app', 'marionette', 'vent', 'utils', 'views/mix/mixListLayout', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView', 'views/user/userProfileView', 'views/user/userListView', 'views/user/userEditView', 'models/mix/mixCollection', 'models/mix/mixItem', 'models/user/userItem'], function(App, Marionette, vent, utils, MixListLayout, MixListView, MixDetailView, MixEditView, UserProfileView, UserListView, UserEditView, MixCollection, MixItem, UserItem) { + var DssController; + DssController = (function(_super) { - __extends(DssController, _super); + __extends(DssController, _super); - function DssController() { - return DssController.__super__.constructor.apply(this, arguments); - } + function DssController() { + return DssController.__super__.constructor.apply(this, arguments); + } - DssController.prototype.initialize = function() { - return this.listenTo(vent, "mix:random", this.showRandomMix); - }; + DssController.prototype.initialize = function() { + return this.listenTo(vent, "mix:random", this.showRandomMix); + }; - DssController.prototype.home = function() { - console.log("Controller: home"); - return this.showMixList(); - }; + DssController.prototype.home = function() { + console.log("Controller: home"); + return this.showMixList(); + }; - DssController.prototype.doLogin = function() { - return vent.trigger('app:login'); - }; + DssController.prototype.doLogin = function() { + return vent.trigger('app:login'); + }; - DssController.prototype.showMixList = function(options) { - var app; - app = require('app'); - app.contentRegion.show(new MixListLayout(options || { - order_by: 'latest' - })); - return vent.trigger('mix:showlist', options || { - order_by: 'latest' - }); - }; + DssController.prototype.showMixList = function(options) { + var app; + app = require('app'); + app.contentRegion.show(new MixListLayout(options || { + order_by: 'latest' + })); + return vent.trigger('mix:showlist', options || { + order_by: 'latest' + }); + }; - DssController.prototype.showStreamList = function() { - return this.showMixList({ - stream: true - }); - }; + DssController.prototype.showStreamList = function() { + return this.showMixList({ + stream: true + }); + }; - DssController.prototype.showMixListType = function(type) { - return this.showMixList({ - genres__slug: type, - order_by: 'latest' - }); - }; + DssController.prototype.showMixListType = function(type) { + return this.showMixList({ + order_by: type + }); + }; - DssController.prototype.showMix = function(slug) { - var app, mix; - console.log("Controller: showMix"); - app = require('app'); - mix = new MixItem({ - id: slug - }); - return mix.fetch({ - success: function() { - return app.contentRegion.show(new MixDetailView({ - model: mix - })); - } - }); - }; + DssController.prototype.showMixListGenre = function(type) { + return this.showMixList({ + genres__slug: type, + order_by: 'latest' + }); + }; - DssController.prototype.showRandomMix = function() { - var app, mix; - console.log("Controller: showRandomMix"); - app = require('app'); - mix = new MixItem({ - id: 'random' - }); - mix.fetch({ - success: function() { - return app.contentRegion.show(new MixDetailView({ - model: mix - })); - } - }); - return Backbone.history.navigate("/random", { - trigger: false - }); - }; + DssController.prototype.showMix = function(slug) { + var app, mix; + console.log("Controller: showMix"); + app = require('app'); + mix = new MixItem({ + id: slug + }); + return mix.fetch({ + success: function() { + return app.contentRegion.show(new MixDetailView({ + model: mix + })); + } + }); + }; - DssController.prototype.uploadMix = function() { - var app, mix; - console.log("Controller: mixUpload"); - app = require('app'); - mix = new MixItem({ - title: '', - description: '', - mix_image: com.podnoms.settings.staticUrl + 'img/default-track.png', - download_allowed: true, - is_featured: false - }); - app.contentRegion.show(new MixEditView({ - model: mix - })); - return true; - }; + DssController.prototype.showRandomMix = function() { + var app, mix; + console.log("Controller: showRandomMix"); + app = require('app'); + mix = new MixItem({ + id: 'random' + }); + mix.fetch({ + success: function() { + return app.contentRegion.show(new MixDetailView({ + model: mix + })); + } + }); + return Backbone.history.navigate("/random", { + trigger: false + }); + }; - DssController.prototype.editMix = function(slug) { - var app, mix; - console.log("Controller: mixEdit"); - app = require('app'); - mix = new MixItem({ - id: slug - }); - mix.fetch({ - success: function() { - return app.contentRegion.show(new MixEditView({ - model: mix - })); - } - }); - return true; - }; + DssController.prototype.uploadMix = function() { + var app, mix; + console.log("Controller: mixUpload"); + app = require('app'); + mix = new MixItem({ + title: '', + description: '', + mix_image: com.podnoms.settings.staticUrl + 'img/default-track.png', + download_allowed: true, + is_featured: false + }); + app.contentRegion.show(new MixEditView({ + model: mix + })); + return true; + }; - DssController.prototype.showChat = function() { - var app; - console.log("Controller: showChat"); - app = require('app'); - return app.contentRegion.show(new ChatView()); - }; + DssController.prototype.editMix = function(slug) { + var app, mix; + console.log("Controller: mixEdit"); + app = require('app'); + mix = new MixItem({ + id: slug + }); + mix.fetch({ + success: function() { + return app.contentRegion.show(new MixEditView({ + model: mix + })); + } + }); + return true; + }; - DssController.prototype.showUserList = function() { - var app; - console.log("Controller: showUserList"); - app = require('app'); - return app.contentRegion.show(new UserListView()); - }; + DssController.prototype.showChat = function() { + var app; + console.log("Controller: showChat"); + app = require('app'); + return app.contentRegion.show(new ChatView()); + }; - DssController.prototype.showUserProfile = function(slug) { - var app, user; - console.log("Controller: showUserProfile"); - app = require('app'); - user = new UserItem({ - id: slug - }); - return user.fetch({ - success: function() { - return app.contentRegion.show(new UserProfileView({ - model: user - })); - }, - error: function(a, b, c) { - return console.log("Error fetching user"); - } - }); - }; + DssController.prototype.showUserList = function() { + var app; + console.log("Controller: showUserList"); + app = require('app'); + return app.contentRegion.show(new UserListView()); + }; - DssController.prototype.showUserFavourites = function(slug) { - console.log("Controller: showUserFavourites"); - return this.showMixList({ - order_by: 'latest', - favourites__slug: slug - }); - }; + DssController.prototype.showUserProfile = function(slug) { + var app, user; + console.log("Controller: showUserProfile"); + app = require('app'); + user = new UserItem({ + id: slug + }); + return user.fetch({ + success: function() { + return app.contentRegion.show(new UserProfileView({ + model: user + })); + }, + error: function(a, b, c) { + return console.log("Error fetching user"); + } + }); + }; - DssController.prototype.showUserLikes = function(slug) { - console.log("Controller: showUserLikes"); - return this.showMixList({ - order_by: 'latest', - likes__slug: slug - }); - }; + DssController.prototype.showUserFavourites = function(slug) { + console.log("Controller: showUserFavourites"); + return this.showMixList({ + order_by: 'latest', + favourites__slug: slug + }); + }; - DssController.prototype.showUserMixes = function(slug) { - console.log("Controller: showUserMixes"); - return this.showMixList({ - order_by: 'latest', - user: slug - }); - }; + DssController.prototype.showUserLikes = function(slug) { + console.log("Controller: showUserLikes"); + return this.showMixList({ + order_by: 'latest', + likes__slug: slug + }); + }; - DssController.prototype.showUserFollowing = function(slug) { - var app; - console.log("Controller: showUserFollowing"); - app = require('app'); - return app.contentRegion.show(new UserListView({ - followers__slug: slug - })); - }; + DssController.prototype.showUserMixes = function(slug) { + console.log("Controller: showUserMixes"); + return this.showMixList({ + order_by: 'latest', + user: slug + }); + }; - DssController.prototype.showUserFollowers = function(slug) { - var app; - console.log("Controller: showUserFollowers"); - app = require('app'); - return app.contentRegion.show(new UserListView({ - following__slug: slug - })); - }; + DssController.prototype.showUserFollowing = function(slug) { + var app; + console.log("Controller: showUserFollowing"); + app = require('app'); + return app.contentRegion.show(new UserListView({ + followers__slug: slug + })); + }; - DssController.prototype.editUser = function() { - var app, user; - console.log("Controller: editUser"); - app = require('app'); - user = new UserItem({ - id: com.podnoms.settings.currentUser - }); - user.fetch({ - success: function() { - return app.contentRegion.show(new UserEditView({ - model: user - })); - } - }); - return true; - }; + DssController.prototype.showUserFollowers = function(slug) { + var app; + console.log("Controller: showUserFollowers"); + app = require('app'); + return app.contentRegion.show(new UserListView({ + following__slug: slug + })); + }; + DssController.prototype.editUser = function() { + var app, user; + console.log("Controller: editUser"); + app = require('app'); + user = new UserItem({ + id: com.podnoms.settings.currentUser + }); + user.fetch({ + success: function() { + return app.contentRegion.show(new UserEditView({ + model: user + })); + } + }); + return true; + }; + + return DssController; + + })(Marionette.Controller); return DssController; + }); - })(Marionette.Controller); - return DssController; -}); +}).call(this); diff --git a/static/js/app/lib/router.coffee b/static/js/app/lib/router.coffee index 06ef4a2..0f7c475 100755 --- a/static/js/app/lib/router.coffee +++ b/static/js/app/lib/router.coffee @@ -9,6 +9,7 @@ define ['marionette', 'vent', 'app.lib/controller'], "mix/upload": "uploadMix", "mixes": "showMixList", "mixes/:type": "showMixListType" + "mixes/genre/:type": "showMixListGenre" "mix/:slug": "showMix" "mix/edit/:slug": "editMix", diff --git a/static/js/app/lib/router.js b/static/js/app/lib/router.js index 11a37fd..33ef889 100755 --- a/static/js/app/lib/router.js +++ b/static/js/app/lib/router.js @@ -1,49 +1,53 @@ // Generated by CoffeeScript 1.4.0 -var __hasProp = {}.hasOwnProperty, - __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; }; +(function() { + var __hasProp = {}.hasOwnProperty, + __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(['marionette', 'vent', 'app.lib/controller'], function(Marionette, vent, Controller) { - var DssRouter; - return DssRouter = (function(_super) { + define(['marionette', 'vent', 'app.lib/controller'], function(Marionette, vent, Controller) { + var DssRouter; + return DssRouter = (function(_super) { - __extends(DssRouter, _super); + __extends(DssRouter, _super); - function DssRouter() { - return DssRouter.__super__.constructor.apply(this, arguments); - } + function DssRouter() { + return DssRouter.__super__.constructor.apply(this, arguments); + } - DssRouter.prototype.controller = new Controller; + DssRouter.prototype.controller = new Controller; - DssRouter.prototype.appRoutes = { - "": "home", - "/": "home", - "mix/upload": "uploadMix", - "mixes": "showMixList", - "mixes/:type": "showMixListType", - "mix/:slug": "showMix", - "mix/edit/:slug": "editMix", - "chat": "showChat", - "random": "showRandomMix", - "stream": "showStreamList", - "login": "doLogin", - "users": "showUserList", - "user/:slug/favourites": "showUserFavourites", - "user/:slug/likes": "showUserLikes", - "user/:slug/followers": "showUserFollowers", - "user/:slug/following": "showUserFollowing", - "user/:slug/mixes": "showUserMixes", - "user/:slug": "showUserProfile", - "me": "editUser" - }; + DssRouter.prototype.appRoutes = { + "": "home", + "/": "home", + "mix/upload": "uploadMix", + "mixes": "showMixList", + "mixes/:type": "showMixListType", + "mixes/genre/:type": "showMixListGenre", + "mix/:slug": "showMix", + "mix/edit/:slug": "editMix", + "chat": "showChat", + "random": "showRandomMix", + "stream": "showStreamList", + "login": "doLogin", + "users": "showUserList", + "user/:slug/favourites": "showUserFavourites", + "user/:slug/likes": "showUserLikes", + "user/:slug/followers": "showUserFollowers", + "user/:slug/following": "showUserFollowing", + "user/:slug/mixes": "showUserMixes", + "user/:slug": "showUserProfile", + "me": "editUser" + }; - DssRouter.prototype.initialize = function() { - console.log("Router: initialize"); - return this.listenTo(vent, "navigate:mix", function(slug) { - return this.navigate('mix/' + slug, true); - }); - }; + DssRouter.prototype.initialize = function() { + console.log("Router: initialize"); + return this.listenTo(vent, "navigate:mix", function(slug) { + return this.navigate('mix/' + slug, true); + }); + }; - return DssRouter; + return DssRouter; - })(Marionette.AppRouter); -}); + })(Marionette.AppRouter); + }); + +}).call(this); diff --git a/static/js/app/models/mix/mixItem.js b/static/js/app/models/mix/mixItem.js index dc7dbca..349ef76 100755 --- a/static/js/app/models/mix/mixItem.js +++ b/static/js/app/models/mix/mixItem.js @@ -1,57 +1,60 @@ // Generated by CoffeeScript 1.4.0 -var __hasProp = {}.hasOwnProperty, - __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; }; +(function() { + var __hasProp = {}.hasOwnProperty, + __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(['utils', 'vent', 'models/comment/commentCollection', 'models/comment/commentItem', 'models/genre/genreCollection', 'models/genre/genreItem', 'app.lib/backbone.dss.model'], function(utils, vent, CommentCollection, CommentItem, GenreCollection, GenreItem, DssModel) { - var MixItem; - return MixItem = (function(_super) { + define(['utils', 'vent', 'models/comment/commentCollection', 'models/comment/commentItem', 'models/genre/genreCollection', 'models/genre/genreItem', 'app.lib/backbone.dss.model'], function(utils, vent, CommentCollection, CommentItem, GenreCollection, GenreItem, DssModel) { + var MixItem; + return MixItem = (function(_super) { - __extends(MixItem, _super); + __extends(MixItem, _super); - function MixItem() { - return MixItem.__super__.constructor.apply(this, arguments); - } - - MixItem.prototype.urlRoot = com.podnoms.settings.urlRoot + "mix/"; - - MixItem.prototype.relations = [ - { - type: Backbone.Many, - key: "comments", - relatedModel: CommentItem, - collectionType: CommentCollection - }, { - type: Backbone.Many, - key: "genres", - relatedModel: GenreItem, - collectionType: GenreCollection + function MixItem() { + return MixItem.__super__.constructor.apply(this, arguments); } - ]; - MixItem.prototype.addComment = function(comment, success, error) { - var c; - c = void 0; - if (comment) { - return c = this.get("comments").create({ - comment: comment, - mix_id: this.get("slug") + MixItem.prototype.urlRoot = com.podnoms.settings.urlRoot + "mix/"; + + MixItem.prototype.relations = [ + { + type: Backbone.Many, + key: "comments", + relatedModel: CommentItem, + collectionType: CommentCollection }, { - success: function() { - return success(); - }, - error: function() { - return error(); - } - }); - } else { - return error("Comment cannot be empty"); - } - }; + type: Backbone.Many, + key: "genres", + relatedModel: GenreItem, + collectionType: GenreCollection + } + ]; - MixItem; + MixItem.prototype.addComment = function(comment, success, error) { + var c; + c = void 0; + if (comment) { + return c = this.get("comments").create({ + comment: comment, + mix_id: this.get("slug") + }, { + success: function() { + return success(); + }, + error: function() { + return error(); + } + }); + } else { + return error("Comment cannot be empty"); + } + }; + + MixItem; - return MixItem; + return MixItem; - })(DssModel); -}); + })(DssModel); + }); + +}).call(this); diff --git a/static/js/app/views/mix/mixEditView.js b/static/js/app/views/mix/mixEditView.js index 9e55663..3fede79 100644 --- a/static/js/app/views/mix/mixEditView.js +++ b/static/js/app/views/mix/mixEditView.js @@ -1,71 +1,72 @@ // Generated by CoffeeScript 1.4.0 -var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __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; }; +(function() { + var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + __hasProp = {}.hasOwnProperty, + __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(['app.lib/editableView', 'vent', 'moment', 'utils', 'backbone.syphon', 'text!/tpl/MixEditView', 'models/genre/genreCollection', 'lib/jdataview', 'ace', 'dropzone', 'wizard', 'ajaxfileupload', 'jquery.fileupload', 'lib/ace/uncompressed/select2'], function(EditableView, vent, moment, utils, Syphon, Template, GenreCollection, jDataView) { - var MixEditView; - return MixEditView = (function(_super) { + define(['app.lib/editableView', 'vent', 'moment', 'utils', 'backbone.syphon', 'text!/tpl/MixEditView', 'models/genre/genreCollection', 'lib/jdataview', 'ace', 'dropzone', 'wizard', 'ajaxfileupload', 'jquery.fileupload', 'lib/ace/uncompressed/select2'], function(EditableView, vent, moment, utils, Syphon, Template, GenreCollection, jDataView) { + var MixEditView; + return MixEditView = (function(_super) { - __extends(MixEditView, _super); + __extends(MixEditView, _super); - function MixEditView() { - this.saveChanges = __bind(this.saveChanges, this); - return MixEditView.__super__.constructor.apply(this, arguments); - } - - MixEditView.prototype.template = _.template(Template); - - MixEditView.prototype.events = { - "click #login": "login", - "change input[name='...']": "imageChanged" - }; - - MixEditView.prototype.ui = { - image: "#mix-image", - progress: "#mix-upload-progress", - uploadError: '#mix-upload-error' - }; - - MixEditView.prototype.initialize = function() { - this.guid = utils.generateGuid(); - this.uploadState = 0; - this.detailsEntered = false; - return this.patch = false; - }; - - MixEditView.prototype.onRender = function() { - var wizard, - _this = this; - console.log("MixEditView: onRender js"); - $('.progress', this.el).hide(); - this.sendImage = false; - if (!this.model.id) { - $('input[name="upload-hash"]', this.el).val(this.guid); - } else { - $('#header-step1', this.el).remove(); - $('#step1', this.el).remove(); - $('#header-step2', this.el).addClass("active"); - $('#step2', this.el).addClass("active"); - $('.progress', this.el).hide(); - this.patch = true; - this.uploadState = 2; + function MixEditView() { + this.saveChanges = __bind(this.saveChanges, this); + return MixEditView.__super__.constructor.apply(this, arguments); } - wizard = $("#fuelux-wizard", this.el).ace_wizard().on("change", function(e, info) { - if (info.step === 1 && _this.uploadState === 0) { - console.log("MixEditView: No mix uploaded"); - _this.ui.uploadError.fadeIn(); - $('#step1').addClass("alert-danger"); - return false; + + MixEditView.prototype.template = _.template(Template); + + MixEditView.prototype.events = { + "click #login": "login", + "change input[name='...']": "imageChanged" + }; + + MixEditView.prototype.ui = { + image: "#mix-image", + progress: "#mix-upload-progress", + uploadError: '#mix-upload-error' + }; + + MixEditView.prototype.initialize = function() { + this.guid = utils.generateGuid(); + this.uploadState = 0; + this.detailsEntered = false; + return this.patch = false; + }; + + MixEditView.prototype.onRender = function() { + var wizard, + _this = this; + console.log("MixEditView: onRender js"); + $('.progress', this.el).hide(); + this.sendImage = false; + if (!this.model.id) { + $('input[name="upload-hash"]', this.el).val(this.guid); } else { - return true; + $('#header-step1', this.el).remove(); + $('#step1', this.el).remove(); + $('#header-step2', this.el).addClass("active"); + $('#step2', this.el).addClass("active"); + $('.progress', this.el).hide(); + this.patch = true; + this.uploadState = 2; } - }).on("finished", function(e) { - console.log("Finished"); - return _this.saveChanges(); - }); - $("#mix-upload-form", this.el).dropzone({ - previewTemplate: '