diff --git a/spa/api/v1/ShowResource.py b/spa/api/v1/ShowResource.py index 51f827f..d87670c 100644 --- a/spa/api/v1/ShowResource.py +++ b/spa/api/v1/ShowResource.py @@ -18,8 +18,7 @@ class ShowResource(BackboneCompatibleResource): class Meta: queryset = Show.objects.all() authorization = Authorization() - resource_name = 'show' - always_return_data = True + resource_name = 'shows' def obj_create(self, bundle, **kwargs): try: diff --git a/static/js/app/models/show/showCollection.coffee b/static/js/app/models/show/showCollection.coffee index 3946352..1859f3f 100644 --- a/static/js/app/models/show/showCollection.coffee +++ b/static/js/app/models/show/showCollection.coffee @@ -5,7 +5,7 @@ define ['backbone', 'models/show/showItem', 'app.lib/backbone.dss.model.collecti page: 0 limit: 20 url: -> - com.podnoms.settings.urlRoot + "show/?limit=" + @limit + "&offset=" + Math.max(@page-1, 0) * @limit + com.podnoms.settings.urlRoot + "shows/?limit=" + @limit + "&offset=" + Math.max(@page-1, 0) * @limit initialize: -> if not ShowItem diff --git a/static/js/app/models/show/showCollection.js b/static/js/app/models/show/showCollection.js index 680d053..5b90c05 100644 --- a/static/js/app/models/show/showCollection.js +++ b/static/js/app/models/show/showCollection.js @@ -20,7 +20,7 @@ ScheduleCollection.prototype.limit = 20; ScheduleCollection.prototype.url = function() { - return com.podnoms.settings.urlRoot + "show/?limit=" + this.limit + "&offset=" + Math.max(this.page - 1, 0) * this.limit; + return com.podnoms.settings.urlRoot + "shows/?limit=" + this.limit + "&offset=" + Math.max(this.page - 1, 0) * this.limit; }; ScheduleCollection.prototype.initialize = function() { diff --git a/static/js/app/models/show/showItem.coffee b/static/js/app/models/show/showItem.coffee index 166bd54..6c4aeb7 100644 --- a/static/js/app/models/show/showItem.coffee +++ b/static/js/app/models/show/showItem.coffee @@ -2,4 +2,4 @@ define ['app.lib/backbone.dss.model'], (DssModel) -> class ShowItem extends DssModel urlRoot: com.podnoms.settings.urlRoot + "show/" - ShowItem \ No newline at end of file + ShowItem diff --git a/static/js/app/views/show/scheduleShowLayout.coffee b/static/js/app/views/show/scheduleShowLayout.coffee index c3fdc63..dc38cb3 100644 --- a/static/js/app/views/show/scheduleShowLayout.coffee +++ b/static/js/app/views/show/scheduleShowLayout.coffee @@ -1,11 +1,11 @@ -define ['app', 'vent', 'utils', 'marionette', 'fullcalendar', +define ['app', 'vent', 'marionette', 'fullcalendar', 'views/show/scheduleShowMixListView', - 'models/show/showCollection', 'models/show/showItem', + 'models/show/showCollection', 'models/mix/mixCollection', 'text!/tpl/ShowScheduleLayout'], -(App, vent, utils, Marionette, fullcalendar, +(App, vent, Marionette, fullcalendar, ScheduleShowMixList, - ShowCollection, ShowItem, + ScheduleCollection, MixCollection, Template)-> class ScheduleShowLayout extends Marionette.Layout @@ -14,17 +14,17 @@ define ['app', 'vent', 'utils', 'marionette', 'fullcalendar', availableMixes: "#external-events" initialize: (options)-> - @collection = new ShowCollection() + @collection = new ScheduleCollection() @options = options - @mixCollection = new MixCollection() - @mixCollection.fetch - data: {for_show: true, order_by: 'latest'} + @collection = new MixCollection() + @collection.fetch + data: options success: (collection)=> @availableMixes.show(new ScheduleShowMixList({collection: collection})) return - onShow: => + onShow: -> @calendar = $("#calendar").fullCalendar( editable: true droppable: true @@ -57,6 +57,20 @@ define ['app', 'vent', 'utils', 'marionette', 'fullcalendar', utils.showError(response.responseText) return + + selectable: true + selectHelper: true + select: (start, end, allDay) -> + calendar.fullCalendar "renderEvent", + title: title + start: start + end: end + allDay: allDay + , true # make the event "stick" + + calendar.fullCalendar "unselect" + return + eventClick: (calEvent, jsEvent, view) -> #display a modal @@ -82,26 +96,21 @@ define ['app', 'vent', 'utils', 'marionette', 'fullcalendar', return ) - @_fetchEvents() - _fetchEvents: -> @collection.fetch( data: @options success: => console.log("ScheduleView: Collection fetched") - @collection.each (model) => - @_renderEvent(model) + @collection.each (model, index, context) => + $("#calendar").fullCalendar("renderEvent", { + title: model.get("description"), + start: model.get("start"), + end: model.get("end"), + allDay: false, + className: "label-important" + }) return ) - - _renderEvent: (model) -> - $("#calendar").fullCalendar("renderEvent", { - title: model.get("description").substring(0, 15), - start: model.get("start"), - end: model.get("end"), - allDay: false, - className: "label-important" - }) true ScheduleShowLayout diff --git a/static/js/app/views/show/scheduleShowLayout.js b/static/js/app/views/show/scheduleShowLayout.js index b939739..5ac337e 100644 --- a/static/js/app/views/show/scheduleShowLayout.js +++ b/static/js/app/views/show/scheduleShowLayout.js @@ -1,17 +1,15 @@ // Generated by CoffeeScript 1.4.0 (function() { - var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, + 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', 'vent', 'utils', 'marionette', 'fullcalendar', 'views/show/scheduleShowMixListView', 'models/show/showCollection', 'models/show/showItem', 'models/mix/mixCollection', 'text!/tpl/ShowScheduleLayout'], function(App, vent, utils, Marionette, fullcalendar, ScheduleShowMixList, ShowCollection, ShowItem, MixCollection, Template) { + define(['app', 'vent', 'marionette', 'fullcalendar', 'views/show/scheduleShowMixListView', 'models/show/showCollection', 'models/mix/mixCollection', 'text!/tpl/ShowScheduleLayout'], function(App, vent, Marionette, fullcalendar, ScheduleShowMixList, ScheduleCollection, MixCollection, Template) { var ScheduleShowLayout; ScheduleShowLayout = (function(_super) { __extends(ScheduleShowLayout, _super); function ScheduleShowLayout() { - this.onShow = __bind(this.onShow, this); return ScheduleShowLayout.__super__.constructor.apply(this, arguments); } @@ -23,14 +21,11 @@ ScheduleShowLayout.prototype.initialize = function(options) { var _this = this; - this.collection = new ShowCollection(); + this.collection = new ScheduleCollection(); this.options = options; - this.mixCollection = new MixCollection(); - this.mixCollection.fetch({ - data: { - for_show: true, - order_by: 'latest' - }, + this.collection = new MixCollection(); + this.collection.fetch({ + data: options, success: function(collection) { return _this.availableMixes.show(new ScheduleShowMixList({ collection: collection @@ -75,6 +70,17 @@ } }); }, + selectable: true, + selectHelper: true, + select: function(start, end, allDay) { + calendar.fullCalendar("renderEvent", { + title: title, + start: start, + end: end, + allDay: allDay + }, true); + calendar.fullCalendar("unselect"); + }, eventClick: function(calEvent, jsEvent, view) { var modal; modal = "
\t\t\t
\t\t\t
\t\t\t\t
\t\t\t\t \t\t\t\t
\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t
\t\t\t\t
\t\t\t\t
\t\t\t\t\t\t\t\t\t\t\t\t\t\t
\t\t\t
\t\t\t
\t\t\t
"; @@ -96,32 +102,23 @@ }); } }); - return this._fetchEvents(); - }; - - ScheduleShowLayout.prototype._fetchEvents = function() { - var _this = this; return this.collection.fetch({ data: this.options, success: function() { console.log("ScheduleView: Collection fetched"); - _this.collection.each(function(model) { - return _this._renderEvent(model); + _this.collection.each(function(model, index, context) { + return $("#calendar").fullCalendar("renderEvent", { + title: model.get("description"), + start: model.get("start"), + end: model.get("end"), + allDay: false, + className: "label-important" + }); }); } }); }; - ScheduleShowLayout.prototype._renderEvent = function(model) { - return $("#calendar").fullCalendar("renderEvent", { - title: model.get("description").substring(0, 15), - start: model.get("start"), - end: model.get("end"), - allDay: false, - className: "label-important" - }); - }; - true; return ScheduleShowLayout; diff --git a/static/js/app/views/show/scheduleShowMixListView.js b/static/js/app/views/show/scheduleShowMixListView.js deleted file mode 100644 index d24c05e..0000000 --- a/static/js/app/views/show/scheduleShowMixListView.js +++ /dev/null @@ -1,54 +0,0 @@ -// 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; }; - - define(['app', 'vent', 'marionette', 'fullcalendar', 'models/show/showCollection', 'models/mix/mixCollection', 'text!/tpl/ShowScheduleMixItem'], function(App, vent, Marionette, fullcalendar, ScheduleCollection, MixCollection, Template) { - var ScheduleShowMixItem, ScheduleShowMixList; - ScheduleShowMixItem = (function(_super) { - - __extends(ScheduleShowMixItem, _super); - - function ScheduleShowMixItem() { - return ScheduleShowMixItem.__super__.constructor.apply(this, arguments); - } - - ScheduleShowMixItem.prototype.template = _.template(Template); - - return ScheduleShowMixItem; - - })(Marionette.ItemView); - ScheduleShowMixList = (function(_super) { - - __extends(ScheduleShowMixList, _super); - - function ScheduleShowMixList() { - return ScheduleShowMixList.__super__.constructor.apply(this, arguments); - } - - ScheduleShowMixList.prototype.itemView = ScheduleShowMixItem; - - ScheduleShowMixList.prototype.initialize = function(options) { - console.log("ScheduleShowMixList: initialize"); - return true; - }; - - ScheduleShowMixList.prototype.onShow = function() { - return $("#external-events div.external-event").each(function() { - $(this).draggable({ - zIndex: 999, - revert: true, - revertDuration: 0 - }); - }); - }; - - true; - - return ScheduleShowMixList; - - })(Marionette.CollectionView); - return ScheduleShowMixList; - }); - -}).call(this);