diff --git a/spa/api/v1/GenreResource.py b/spa/api/v1/GenreResource.py index 0f851d5..d45fff0 100644 --- a/spa/api/v1/GenreResource.py +++ b/spa/api/v1/GenreResource.py @@ -11,6 +11,9 @@ class GenreResource(BackboneCompatibleResource): resource_name = 'genres' excludes = ['resource_uri'] + filtering = { + 'slug': ('exact',), + } authorization = Authorization() authentication = Authentication() always_return_data = True diff --git a/static/js/app/lib/controller.coffee b/static/js/app/lib/controller.coffee index 477dc81..24876fe 100755 --- a/static/js/app/lib/controller.coffee +++ b/static/js/app/lib/controller.coffee @@ -27,7 +27,7 @@ define ['app', 'marionette', 'vent', 'utils' @showMixList({stream: true}) showMixListType: (type) -> - @showMixList({order_by: type}) + @showMixList({genres__slug: type, order_by: 'latest'}) showMix: (slug)-> console.log "Controller: showMix" diff --git a/static/js/app/lib/controller.js b/static/js/app/lib/controller.js index bee763e..604c461 100755 --- a/static/js/app/lib/controller.js +++ b/static/js/app/lib/controller.js @@ -1,219 +1,217 @@ // Generated by CoffeeScript 1.4.0 -(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; }; +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({ - order_by: type - }); - }; + DssController.prototype.showMixListType = function(type) { + return this.showMixList({ + genres__slug: type, + order_by: 'latest' + }); + }; - 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.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.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.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.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.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.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.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.showChat = function() { - var app; - console.log("Controller: showChat"); - app = require('app'); - return app.contentRegion.show(new ChatView()); - }; + DssController.prototype.showChat = function() { + var app; + console.log("Controller: showChat"); + app = require('app'); + return app.contentRegion.show(new ChatView()); + }; - DssController.prototype.showUserList = function() { - var app; - console.log("Controller: showUserList"); - app = require('app'); - return app.contentRegion.show(new UserListView()); - }; + DssController.prototype.showUserList = function() { + var app; + console.log("Controller: showUserList"); + app = require('app'); + return app.contentRegion.show(new UserListView()); + }; - 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.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.showUserFavourites = function(slug) { - console.log("Controller: showUserFavourites"); - return this.showMixList({ - order_by: 'latest', - favourites__slug: slug - }); - }; + DssController.prototype.showUserFavourites = function(slug) { + console.log("Controller: showUserFavourites"); + return this.showMixList({ + order_by: 'latest', + favourites__slug: slug + }); + }; - DssController.prototype.showUserLikes = function(slug) { - console.log("Controller: showUserLikes"); - return this.showMixList({ - order_by: 'latest', - likes__slug: slug - }); - }; + DssController.prototype.showUserLikes = function(slug) { + console.log("Controller: showUserLikes"); + return this.showMixList({ + order_by: 'latest', + likes__slug: slug + }); + }; - DssController.prototype.showUserMixes = function(slug) { - console.log("Controller: showUserMixes"); - return this.showMixList({ - order_by: 'latest', - user: slug - }); - }; + DssController.prototype.showUserMixes = function(slug) { + console.log("Controller: showUserMixes"); + return this.showMixList({ + order_by: 'latest', + user: 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.showUserFollowing = function(slug) { + var app; + console.log("Controller: showUserFollowing"); + app = require('app'); + return app.contentRegion.show(new UserListView({ + followers__slug: 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.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; - }; + 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; - }); -}).call(this); + })(Marionette.Controller); + return DssController; +}); diff --git a/static/js/app/lib/router.js b/static/js/app/lib/router.js index 18c488f..11a37fd 100755 --- a/static/js/app/lib/router.js +++ b/static/js/app/lib/router.js @@ -1,52 +1,49 @@ // Generated by CoffeeScript 1.4.0 -(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; }; +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", + "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); - }); - -}).call(this); + })(Marionette.AppRouter); +}); diff --git a/static/js/app/models/mix/mixItem.coffee b/static/js/app/models/mix/mixItem.coffee index fcdc86b..a34f565 100755 --- a/static/js/app/models/mix/mixItem.coffee +++ b/static/js/app/models/mix/mixItem.coffee @@ -35,4 +35,4 @@ define [ else error "Comment cannot be empty" - MixItem \ No newline at end of file + MixItem diff --git a/static/js/app/models/mix/mixItem.js b/static/js/app/models/mix/mixItem.js index 349ef76..dc7dbca 100755 --- a/static/js/app/models/mix/mixItem.js +++ b/static/js/app/models/mix/mixItem.js @@ -1,60 +1,57 @@ // Generated by CoffeeScript 1.4.0 -(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; }; +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); + 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 } + ]; - MixItem.prototype.urlRoot = com.podnoms.settings.urlRoot + "mix/"; - - MixItem.prototype.relations = [ - { - type: Backbone.Many, - key: "comments", - relatedModel: CommentItem, - collectionType: CommentCollection + 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") }, { - type: Backbone.Many, - key: "genres", - relatedModel: GenreItem, - collectionType: GenreCollection - } - ]; + success: function() { + return success(); + }, + error: function() { + return error(); + } + }); + } else { + return error("Comment cannot be empty"); + } + }; - 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; + MixItem; - return MixItem; + return MixItem; - })(DssModel); - }); - -}).call(this); + })(DssModel); +}); diff --git a/static/js/app/views/mix/mixEditView.coffee b/static/js/app/views/mix/mixEditView.coffee index b55cc50..3d82be0 100755 --- a/static/js/app/views/mix/mixEditView.coffee +++ b/static/js/app/views/mix/mixEditView.coffee @@ -19,18 +19,9 @@ define ['app.lib/editableView', @detailsEntered = false @patch = false - onDomRefresh: -> - """ - @setupImageEditable - el: $("#mix-image", @el) - chooseMessage: "Choose mix image" - """ - - true - onRender: -> console.log("MixEditView: onRender js") - @ui.progress.hide() + $('.progress', @el).hide() @sendImage = false if not @model.id @@ -80,7 +71,7 @@ define ['app.lib/editableView', ' uploadprogress: (e, progress, bytesSent) => - @ui.progress.show() + $('.progress', @el).hide() @uploadState = 1 percentage = Math.round(progress) console.log("Progressing") diff --git a/static/js/app/views/mix/mixEditView.js b/static/js/app/views/mix/mixEditView.js index 6ed1347..9e55663 100644 --- a/static/js/app/views/mix/mixEditView.js +++ b/static/js/app/views/mix/mixEditView.js @@ -1,77 +1,71 @@ // Generated by CoffeeScript 1.4.0 -(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; }; +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); + 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; } - - 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.onDomRefresh = function() { - "@setupImageEditable\n el: $(\"#mix-image\", @el)\n chooseMessage: \"Choose mix image\""; - return true; - }; - - MixEditView.prototype.onRender = function() { - var wizard, - _this = this; - console.log("MixEditView: onRender js"); - this.ui.progress.hide(); - this.sendImage = false; - if (!this.model.id) { - $('input[name="upload-hash"]', this.el).val(this.guid); + 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; } 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; + return true; } - 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; - } else { - return true; - } - }).on("finished", function(e) { - console.log("Finished"); - return _this.saveChanges(); - }); - $("#mix-upload-form", this.el).dropzone({ - previewTemplate: '
\n\ + }).on("finished", function(e) { + console.log("Finished"); + return _this.saveChanges(); + }); + $("#mix-upload-form", this.el).dropzone({ + previewTemplate: '
\n\
\n\
\n\
\n\ @@ -84,149 +78,147 @@
\n\
\n\
', - dictDefaultMessage: ' Drop files to upload\ + dictDefaultMessage: ' Drop files to upload\ (or click)
\ ', - uploadprogress: function(e, progress, bytesSent) { - var percentage; - _this.ui.progress.show(); - _this.uploadState = 1; - percentage = Math.round(progress); - console.log("Progressing"); - return _this.ui.progress.css("width", percentage + "%").parent().attr("data-percent", percentage + "%"); - }, - complete: function() { - _this.uploadState = 2; - return _this.checkRedirect(); - } - }); - $("#genres", this.el).select2({ - placeholder: "Start typing and choose from list or create your own.", - minimumInputLength: 1, - multiple: true, - ajax: { - url: "/ajax/lookup/genre/", - dataType: "json", - data: function(term, page) { - return { - q: term - }; - }, - results: function(data, page) { - return { - results: data - }; - } - }, - formatResult: function(genre) { - return genre.description; - }, - formatSelection: function(genre) { - return "
" + genre.description + "
"; - }, - initSelection: function(element, callback) { - var genres, result; - console.log("MixEditView: genres:initSelection"); - result = []; - genres = _this.model.get("genres"); - if (genres !== undefined) { - genres.each(function(data) { - return result.push({ - id: data.get("id"), - description: data.get("description") - }); - }); - } - return callback(result); - } - }, "createSearchChoice: (term, data) ->\n if $(data).filter(->\n @description.localeCompare(term) is 0\n ).length is 0\n id: term\n text: term"); - return true; - }; - - MixEditView.prototype.saveChanges = function() { - var flair, - _this = this; - console.log("MixEditView: saveChanges"); - this.model.set(Syphon.serialize($("#mix-details-form", this.el)[0])); - flair = Syphon.serialize($("#mix-flair-form", this.el)[0], { - exclude: ["...", ""] - }); - this.model.set(flair); - this.model.set("upload-hash", this.guid); - this.model.set("upload-extension", $("#upload-extension", this.el).val()); - this.model.set("genres", new GenreCollection()); - $.each($("#genres", this.el).select2("data"), function(i, item) { - "if @model.get(\"genres\") is undefined\n @model.set(\"genres\", new GenreCollection())"; - return _this.model.get("genres").add({ - id: item.id, - description: item.text - }); - }); - if (!this.sendImage) { - this.model.unset("mix_image"); + uploadprogress: function(e, progress, bytesSent) { + var percentage; + $('.progress', _this.el).hide(); + _this.uploadState = 1; + percentage = Math.round(progress); + console.log("Progressing"); + return _this.ui.progress.css("width", percentage + "%").parent().attr("data-percent", percentage + "%"); + }, + complete: function() { + _this.uploadState = 2; + return _this.checkRedirect(); } - this.model.unset("comments"); - this._saveChanges({ - patch: this.patch, - success: function() { - if (_this.sendImage) { - $.ajaxFileUpload({ - url: "/ajax/upload_mix_image/" + _this.model.get("id") + "/", - secureuri: false, - fileElementId: "input[name='...']", - success: function(data, status) { - if (typeof data.error !== "undefined") { - if (data.error !== "") { - return alert(data.error); - } else { - return alert(data.msg); - } + }); + $("#genres", this.el).select2({ + placeholder: "Start typing and choose from list or create your own.", + minimumInputLength: 1, + multiple: true, + ajax: { + url: "/ajax/lookup/genre/", + dataType: "json", + data: function(term, page) { + return { + q: term + }; + }, + results: function(data, page) { + return { + results: data + }; + } + }, + formatResult: function(genre) { + return genre.description; + }, + formatSelection: function(genre) { + return "
" + genre.description + "
"; + }, + initSelection: function(element, callback) { + var genres, result; + console.log("MixEditView: genres:initSelection"); + result = []; + genres = _this.model.get("genres"); + if (genres !== undefined) { + genres.each(function(data) { + return result.push({ + id: data.get("id"), + description: data.get("description") + }); + }); + } + return callback(result); + } + }, "createSearchChoice: (term, data) ->\n if $(data).filter(->\n @description.localeCompare(term) is 0\n ).length is 0\n id: term\n text: term"); + return true; + }; + + MixEditView.prototype.saveChanges = function() { + var flair, + _this = this; + console.log("MixEditView: saveChanges"); + this.model.set(Syphon.serialize($("#mix-details-form", this.el)[0])); + flair = Syphon.serialize($("#mix-flair-form", this.el)[0], { + exclude: ["...", ""] + }); + this.model.set(flair); + this.model.set("upload-hash", this.guid); + this.model.set("upload-extension", $("#upload-extension", this.el).val()); + this.model.set("genres", new GenreCollection()); + $.each($("#genres", this.el).select2("data"), function(i, item) { + "if @model.get(\"genres\") is undefined\n @model.set(\"genres\", new GenreCollection())"; + return _this.model.get("genres").add({ + id: item.id, + description: item.text + }); + }); + if (!this.sendImage) { + this.model.unset("mix_image"); + } + this.model.unset("comments"); + this._saveChanges({ + patch: this.patch, + success: function() { + if (_this.sendImage) { + $.ajaxFileUpload({ + url: "/ajax/upload_mix_image/" + _this.model.get("id") + "/", + secureuri: false, + fileElementId: "input[name='...']", + success: function(data, status) { + if (typeof data.error !== "undefined") { + if (data.error !== "") { + return alert(data.error); } else { - $("#mix-upload-wizard", _this.el).hide(); - _this.detailsEntered = true; - return _this.checkRedirect(); + return alert(data.msg); } - }, - error: function(data, status, e) { - return utils.showError(e); + } else { + $("#mix-upload-wizard", _this.el).hide(); + _this.detailsEntered = true; + return _this.checkRedirect(); } - }); - } else { - $("#mix-upload-wizard", _this.el).hide(); - _this.detailsEntered = true; - _this.checkRedirect(); - } - return true; - }, - error: function(model, response) { - return utils.showError("Error", "Something went wrong
Nerd stuff is: " + response); + }, + error: function(data, status, e) { + return utils.showError(e); + } + }); + } else { + $("#mix-upload-wizard", _this.el).hide(); + _this.detailsEntered = true; + _this.checkRedirect(); } - }); - return false; - }; - - MixEditView.prototype.checkRedirect = function() { - if (this.detailsEntered && this.uploadState === 2) { - return Backbone.history.navigate("/mix/" + this.model.get("slug"), { - trigger: true - }); + return true; + }, + error: function(model, response) { + return utils.showError("Error", "Something went wrong
Nerd stuff is: " + response); } - }; + }); + return false; + }; - MixEditView.prototype.login = function() { - return vent.trigger('app:login'); - }; + MixEditView.prototype.checkRedirect = function() { + if (this.detailsEntered && this.uploadState === 2) { + return Backbone.history.navigate("/mix/" + this.model.get("slug"), { + trigger: true + }); + } + }; - MixEditView.prototype.imageChanged = function(evt) { - return this.sendImage = true; - }; + MixEditView.prototype.login = function() { + return vent.trigger('app:login'); + }; - MixEditView; + MixEditView.prototype.imageChanged = function(evt) { + return this.sendImage = true; + }; + + MixEditView; - return MixEditView; + return MixEditView; - })(EditableView); - }); - -}).call(this); + })(EditableView); +}); diff --git a/static/js/app/views/mix/mixItemView.coffee b/static/js/app/views/mix/mixItemView.coffee index b250677..cedbdfd 100755 --- a/static/js/app/views/mix/mixItemView.coffee +++ b/static/js/app/views/mix/mixItemView.coffee @@ -37,7 +37,6 @@ define ['moment', 'app', 'vent', 'marionette', 'utils', if @model.get('duration') $('#player-duration-' + id, this.el).text(@model.secondsToHms('duration')) - #@renderGenres() return onShow: -> @@ -47,13 +46,6 @@ define ['moment', 'app', 'vent', 'marionette', 'utils', @mixPlay(@model) true - __renderGenres: => - el = @el - $.each @model.get("genres"), (data) -> - $("#genre-list", el).append '' + @description + '' - true - true - doStart: => console.log("MixItemView: mixStart") this.ui.playButton diff --git a/static/js/app/views/mix/mixItemView.js b/static/js/app/views/mix/mixItemView.js index 7771bb0..c398bba 100755 --- a/static/js/app/views/mix/mixItemView.js +++ b/static/js/app/views/mix/mixItemView.js @@ -1,167 +1,152 @@ // Generated by CoffeeScript 1.4.0 -(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; }; +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(['moment', 'app', 'vent', 'marionette', 'utils', 'text!/tpl/MixListItemView'], function(moment, App, vent, Marionette, utils, Template) { - var MixItemView; - MixItemView = (function(_super) { +define(['moment', 'app', 'vent', 'marionette', 'utils', 'text!/tpl/MixListItemView'], function(moment, App, vent, Marionette, utils, Template) { + var MixItemView; + MixItemView = (function(_super) { - __extends(MixItemView, _super); + __extends(MixItemView, _super); - function MixItemView() { - this.doStart = __bind(this.doStart, this); + function MixItemView() { + this.doStart = __bind(this.doStart, this); - this.__renderGenres = __bind(this.__renderGenres, this); + this.onRender = __bind(this.onRender, this); - this.onRender = __bind(this.onRender, this); + this.initialize = __bind(this.initialize, this); + return MixItemView.__super__.constructor.apply(this, arguments); + } - this.initialize = __bind(this.initialize, this); - return MixItemView.__super__.constructor.apply(this, arguments); + MixItemView.prototype.template = _.template(Template); + + MixItemView.prototype.tagName = MixItemView.tagName || "li"; + + MixItemView.prototype.className = MixItemView.className || ""; + + MixItemView.prototype.events = { + "click .play-button-small-start": "doStart", + "click .play-button-small-resume": "doResume", + "click .play-button-small-pause": "doPause", + "click .mix-link": "mixLink", + "click .delete-button a": "mixDelete", + "click .like-button a": "mixLike", + "click .favourite-button a": "mixFavourite", + "click .share-button": "mixShare", + "click .download-button a": "mixDownload", + "click .login-download-button a": "login" + }; + + MixItemView.prototype.ui = { + playButton: ".play-button-small" + }; + + MixItemView.prototype.initialize = function() { + this.listenTo(this.model, 'change:favourited', this.render); + this.listenTo(this.model, 'change:liked', this.render); + this.listenTo(this.model, 'nested-change', this.render); + this.listenTo(vent, 'mix:play', this.mixPlay); + this.listenTo(vent, 'mix:pause', this.mixPause); + return true; + }; + + MixItemView.prototype.onRender = function() { + var id; + id = this.model.get('id'); + if (this.model.get('duration')) { + $('#player-duration-' + id, this.el).text(this.model.secondsToHms('duration')); } + }; - MixItemView.prototype.template = _.template(Template); + MixItemView.prototype.onShow = function() { + if (com.podnoms.player.isPlayingId(this.model.id)) { + com.podnoms.settings.setupPlayerWrapper(this.model.get('id'), com.podnoms.player.getStreamUrl(), this.el); + this.mixPlay(this.model); + } + return true; + }; - MixItemView.prototype.tagName = MixItemView.tagName || "li"; + MixItemView.prototype.doStart = function() { + console.log("MixItemView: mixStart"); + this.ui.playButton.toggleClass('play-button-small-start', false).toggleClass('play-button-small-resume', false).toggleClass('play-button-small-pause', true); + vent.trigger('mix:init', this.model); + }; - MixItemView.prototype.className = MixItemView.className || ""; + MixItemView.prototype.doPause = function() { + console.log("MixItemView: mixPause"); + vent.trigger("mix:pause", this.model); + return true; + }; - MixItemView.prototype.events = { - "click .play-button-small-start": "doStart", - "click .play-button-small-resume": "doResume", - "click .play-button-small-pause": "doPause", - "click .mix-link": "mixLink", - "click .delete-button a": "mixDelete", - "click .like-button a": "mixLike", - "click .favourite-button a": "mixFavourite", - "click .share-button": "mixShare", - "click .download-button a": "mixDownload", - "click .login-download-button a": "login" - }; + MixItemView.prototype.doResume = function() { + console.log("MixItemView: mixResume"); + vent.trigger("mix:play", this.model); + return true; + }; - MixItemView.prototype.ui = { - playButton: ".play-button-small" - }; - - MixItemView.prototype.initialize = function() { - this.listenTo(this.model, 'change:favourited', this.render); - this.listenTo(this.model, 'change:liked', this.render); - this.listenTo(this.model, 'nested-change', this.render); - this.listenTo(vent, 'mix:play', this.mixPlay); - this.listenTo(vent, 'mix:pause', this.mixPause); - return true; - }; - - MixItemView.prototype.onRender = function() { - var id; - id = this.model.get('id'); - if (this.model.get('duration')) { - $('#player-duration-' + id, this.el).text(this.model.secondsToHms('duration')); - } - }; - - MixItemView.prototype.onShow = function() { - if (com.podnoms.player.isPlayingId(this.model.id)) { - com.podnoms.settings.setupPlayerWrapper(this.model.get('id'), com.podnoms.player.getStreamUrl(), this.el); - this.mixPlay(this.model); - } - return true; - }; - - MixItemView.prototype.__renderGenres = function() { - var el; - el = this.el; - $.each(this.model.get("genres"), function(data) { - $("#genre-list", el).append('' + this.description + ''); - return true; - }); - return true; - }; - - MixItemView.prototype.doStart = function() { - console.log("MixItemView: mixStart"); + MixItemView.prototype.mixPlay = function(model) { + if (this.model.get('id') === model.get('id')) { this.ui.playButton.toggleClass('play-button-small-start', false).toggleClass('play-button-small-resume', false).toggleClass('play-button-small-pause', true); - vent.trigger('mix:init', this.model); - }; + } + }; - MixItemView.prototype.doPause = function() { - console.log("MixItemView: mixPause"); - vent.trigger("mix:pause", this.model); - return true; - }; + MixItemView.prototype.mixPause = function(model) { + if (this.model.get('id') === model.get('id')) { + this.ui.playButton.toggleClass('play-button-small-start', false).toggleClass('play-button-small-resume', true).toggleClass('play-button-small-pause', false); + } + }; - MixItemView.prototype.doResume = function() { - console.log("MixItemView: mixResume"); - vent.trigger("mix:play", this.model); - return true; - }; + MixItemView.prototype.mixStop = function(model) { + if (this.model.get('id') === model.get('id')) { + this.ui.playButton.toggleClass('play-button-small-start', true).toggleClass('play-button-small-resume', false).toggleClass('play-button-small-pause', false); + } + }; - MixItemView.prototype.mixPlay = function(model) { - if (this.model.get('id') === model.get('id')) { - this.ui.playButton.toggleClass('play-button-small-start', false).toggleClass('play-button-small-resume', false).toggleClass('play-button-small-pause', true); - } - }; + MixItemView.prototype.mixFavourite = function() { + var app; + console.log("MixItemView: favouriteMix"); + app = require('app'); + vent.trigger("mix:favourite", this.model); + return true; + }; - MixItemView.prototype.mixPause = function(model) { - if (this.model.get('id') === model.get('id')) { - this.ui.playButton.toggleClass('play-button-small-start', false).toggleClass('play-button-small-resume', true).toggleClass('play-button-small-pause', false); - } - }; + MixItemView.prototype.mixDelete = function() { + var _this = this; + console.log("MixItemView: mixDelete"); + return utils.messageBox("/dlg/DeleteMixConfirm", function() { + return _this.model.destroy(); + }); + }; - MixItemView.prototype.mixStop = function(model) { - if (this.model.get('id') === model.get('id')) { - this.ui.playButton.toggleClass('play-button-small-start', true).toggleClass('play-button-small-resume', false).toggleClass('play-button-small-pause', false); - } - }; + MixItemView.prototype.mixLike = function() { + console.log("MixItemView: likeMix"); + vent.trigger("mix:like", this.model); + return true; + }; - MixItemView.prototype.mixFavourite = function() { - var app; - console.log("MixItemView: favouriteMix"); - app = require('app'); - vent.trigger("mix:favourite", this.model); - return true; - }; + MixItemView.prototype.mixShare = function(e) { + var mode; + console.log("MixItemView: shareMix"); + mode = $(e.currentTarget).data("mode"); + console.log("MixItemView: " + mode); + vent.trigger("mix:share", mode, this.model); + return true; + }; - MixItemView.prototype.mixDelete = function() { - var _this = this; - console.log("MixItemView: mixDelete"); - return utils.messageBox("/dlg/DeleteMixConfirm", function() { - return _this.model.destroy(); - }); - }; + MixItemView.prototype.mixDownload = function() { + console.log("MixItemView: mixDownload"); + utils.downloadURL("/audio/download/" + this.model.get('id')); + return true; + }; - MixItemView.prototype.mixLike = function() { - console.log("MixItemView: likeMix"); - vent.trigger("mix:like", this.model); - return true; - }; + MixItemView.prototype.login = function() { + console.log("MixItemView: login"); + vent.trigger('app:login'); + return true; + }; - MixItemView.prototype.mixShare = function(e) { - var mode; - console.log("MixItemView: shareMix"); - mode = $(e.currentTarget).data("mode"); - console.log("MixItemView: " + mode); - vent.trigger("mix:share", mode, this.model); - return true; - }; - - MixItemView.prototype.mixDownload = function() { - console.log("MixItemView: mixDownload"); - utils.downloadURL("/audio/download/" + this.model.get('id')); - return true; - }; - - MixItemView.prototype.login = function() { - console.log("MixItemView: login"); - vent.trigger('app:login'); - return true; - }; - - return MixItemView; - - })(Marionette.ItemView); return MixItemView; - }); -}).call(this); + })(Marionette.ItemView); + return MixItemView; +}); diff --git a/static/js/app/views/mix/mixListView.coffee b/static/js/app/views/mix/mixListView.coffee index 2ebc179..27ea9a4 100755 --- a/static/js/app/views/mix/mixListView.coffee +++ b/static/js/app/views/mix/mixListView.coffee @@ -16,5 +16,8 @@ define ['marionette', 'vent', 'models/mix/mixCollection', 'views/mix/mixItemView currentMix = model.cid return + onRender: -> + window.scrollTo 0, 0 + MixListView diff --git a/static/js/app/views/mix/mixListView.js b/static/js/app/views/mix/mixListView.js index 56065e5..dd8f159 100755 --- a/static/js/app/views/mix/mixListView.js +++ b/static/js/app/views/mix/mixListView.js @@ -1,42 +1,43 @@ // Generated by CoffeeScript 1.4.0 -(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; }; +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', 'models/mix/mixCollection', 'views/mix/mixItemView', 'text!/tpl/MixListView'], function(Marionette, vent, MixCollection, MixItemView, Template) { - var MixListView; - MixListView = (function(_super) { - var currentMix; +define(['marionette', 'vent', 'models/mix/mixCollection', 'views/mix/mixItemView', 'text!/tpl/MixListView'], function(Marionette, vent, MixCollection, MixItemView, Template) { + var MixListView; + MixListView = (function(_super) { + var currentMix; - __extends(MixListView, _super); + __extends(MixListView, _super); - function MixListView() { - return MixListView.__super__.constructor.apply(this, arguments); + function MixListView() { + return MixListView.__super__.constructor.apply(this, arguments); + } + + MixListView.prototype.template = _.template(Template); + + MixListView.prototype.className = "mix-listing audio-listing"; + + MixListView.prototype.itemView = MixItemView; + + MixListView.prototype.itemViewContainer = "#mix-list-container-ul"; + + currentMix = -1; + + MixListView.prototype.mixPlay = function(model) { + var v; + if (currentMix !== -1) { + v = this.children.findByModelCid(currentMix); + v.mixStop(v.model); } + currentMix = model.cid; + }; - MixListView.prototype.template = _.template(Template); + MixListView.prototype.onRender = function() { + return window.scrollTo(0, 0); + }; - MixListView.prototype.className = "mix-listing audio-listing"; - - MixListView.prototype.itemView = MixItemView; - - MixListView.prototype.itemViewContainer = "#mix-list-container-ul"; - - currentMix = -1; - - MixListView.prototype.mixPlay = function(model) { - var v; - if (currentMix !== -1) { - v = this.children.findByModelCid(currentMix); - v.mixStop(v.model); - } - currentMix = model.cid; - }; - - return MixListView; - - })(Marionette.CompositeView); return MixListView; - }); -}).call(this); + })(Marionette.CompositeView); + return MixListView; +}); diff --git a/templates/views/MixEditView.html b/templates/views/MixEditView.html index d531130..be459b2 100755 --- a/templates/views/MixEditView.html +++ b/templates/views/MixEditView.html @@ -45,7 +45,7 @@
-
+
{% include "views/_MixEditView_Step_Mix.html" %} @@ -58,7 +58,6 @@
-
-
\ No newline at end of file +