From 48b6c3b9e25e35599192784bf23f9478667bfced Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Tue, 6 May 2014 19:55:28 +0100 Subject: [PATCH] Fixed 301 redirects on templates --- dss/settings.py | 7 -- dss/urls.py | 29 ++--- spa/api/v1/ShowResource.py | 2 +- spa/models/show.py | 1 - spa/urls.py | 2 +- static/js/app/lib/controller.coffee | 8 +- static/js/app/lib/controller.js | 6 +- .../js/app/models/show/showCollection.coffee | 15 +++ static/js/app/models/show/showCollection.js | 38 ++++++ static/js/app/models/show/showItem.coffee | 12 ++ static/js/app/models/show/showItem.js | 33 ++++++ .../js/app/models/user/userCollection.coffee | 1 - static/js/app/models/user/userCollection.js | 1 - .../scheduleShowLayout.coffee} | 109 ++++++++---------- .../scheduleShowLayout.js} | 109 +++++++++--------- .../views/show/scheduleShowMixListView.coffee | 38 ++++++ .../app/views/show/scheduleShowMixListView.js | 59 ++++++++++ templates/views/ScheduleView.html | 61 ---------- templates/views/ShowScheduleLayout.html | 20 ++++ templates/views/ShowScheduleMixItem.html | 4 + 20 files changed, 347 insertions(+), 208 deletions(-) create mode 100644 static/js/app/models/show/showCollection.coffee create mode 100644 static/js/app/models/show/showCollection.js create mode 100644 static/js/app/models/show/showItem.coffee create mode 100644 static/js/app/models/show/showItem.js rename static/js/app/views/{schedule/scheduleView.coffee => show/scheduleShowLayout.coffee} (59%) rename static/js/app/views/{schedule/scheduleView.js => show/scheduleShowLayout.js} (60%) create mode 100644 static/js/app/views/show/scheduleShowMixListView.coffee create mode 100644 static/js/app/views/show/scheduleShowMixListView.js delete mode 100644 templates/views/ScheduleView.html create mode 100644 templates/views/ShowScheduleLayout.html create mode 100644 templates/views/ShowScheduleMixItem.html diff --git a/dss/settings.py b/dss/settings.py index fbc97f6..b9c7366 100755 --- a/dss/settings.py +++ b/dss/settings.py @@ -49,13 +49,6 @@ s = True SITE_ROOT = here('') -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', - 'LOCATION': '127.0.0.1:11211', - } -} - ADMIN_MEDIA_PREFIX = STATIC_URL + "grappelli/" TINYMCE_JS_URL = os.path.join(STATIC_ROOT, "js/libs/tiny_mce/tiny_mce.js") diff --git a/dss/urls.py b/dss/urls.py index e41f0c2..d8e2fec 100755 --- a/dss/urls.py +++ b/dss/urls.py @@ -1,6 +1,6 @@ from django.conf.urls import patterns, include, url from django.contrib import admin -from django.views.generic import TemplateView +from django.views.generic import TemplateView, RedirectView from dss import settings @@ -10,19 +10,20 @@ admin.autodiscover() # from django.contrib import admin # admin.autodiscover() -urlpatterns = patterns('', - url(r'^admin/', include(admin.site.urls)), - #(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/static/img/favicon.ico'}), - (r'^channel\.html$', TemplateView.as_view(template_name='boiler/fb_channel.html')), - (r'^privacy\.html$', TemplateView.as_view(template_name='boiler/privacy.html')), - (r'^robots\.txt', TemplateView.as_view(template_name='boiler/robots.txt')), - (r'^tos\.html$', TemplateView.as_view(template_name='boiler/tos.html')), - (r'^test\.html$', TemplateView.as_view(template_name='boiler/test.html')), - (r'^500', 'django.views.defaults.server_error'), - (r'^grappelli/', include('grappelli.urls')), - url(r'^accounts/', include('allauth.urls')), - (r'^avatar/', include('avatar.urls')), - url(r'^', include('spa.urls')), +urlpatterns = patterns( + '', + url(r'^favicon\.ico$', RedirectView.as_view(url='/static/img/favicon.ico')), + url(r'^admin/', include(admin.site.urls)), + (r'^channel\.html$', TemplateView.as_view(template_name='boiler/fb_channel.html')), + (r'^privacy\.html$', TemplateView.as_view(template_name='boiler/privacy.html')), + (r'^robots\.txt', TemplateView.as_view(template_name='boiler/robots.txt')), + (r'^tos\.html$', TemplateView.as_view(template_name='boiler/tos.html')), + (r'^test\.html$', TemplateView.as_view(template_name='boiler/test.html')), + (r'^500', 'django.views.defaults.server_error'), + (r'^grappelli/', include('grappelli.urls')), + url(r'^accounts/', include('allauth.urls')), + (r'^avatar/', include('avatar.urls')), + url(r'^', include('spa.urls')), ) handler500 = 'spa.views.debug_500' diff --git a/spa/api/v1/ShowResource.py b/spa/api/v1/ShowResource.py index 6a85e05..2f38e5a 100644 --- a/spa/api/v1/ShowResource.py +++ b/spa/api/v1/ShowResource.py @@ -14,7 +14,7 @@ class ShowResource(BackboneCompatibleResource): class Meta: queryset = Show.objects.all() authorization = Authorization() - resource_name = 'schedules' + resource_name = 'shows' def obj_create(self, bundle, **kwargs): try: diff --git a/spa/models/show.py b/spa/models/show.py index 1650cec..6a5c52b 100644 --- a/spa/models/show.py +++ b/spa/models/show.py @@ -13,7 +13,6 @@ class Show(Event): """ throw an exception if event overlaps with another event """ - import ipdb; ipdb.set_trace() overlaps = Show.objects.filter( Q(start__gte=self.start, end__lte=self.start) | Q(start__gte=self.end, end__lte=self.end) diff --git a/spa/urls.py b/spa/urls.py index 172c675..9c6728b 100755 --- a/spa/urls.py +++ b/spa/urls.py @@ -34,7 +34,7 @@ audio = AudioHandler() urlpatterns = patterns( '', url(r'^$', 'spa.views.app', name='home'), - url(r'^tpl/(?P\w+)/$', 'spa.templates.get_template'), + url(r'^tpl/(?P\w+)', 'spa.templates.get_template'), url(r'^dlg/(?P\w+)/$', 'spa.templates.get_dialog'), url(r'^dlg/embed/(?P[\w\d_.-]+)/$', 'spa.templates.get_embed_codes_dialog'), url(r'^js/(?P\w+)/$', 'spa.templates.get_javascript'), diff --git a/static/js/app/lib/controller.coffee b/static/js/app/lib/controller.coffee index a1cad1a..b416fd4 100755 --- a/static/js/app/lib/controller.coffee +++ b/static/js/app/lib/controller.coffee @@ -1,11 +1,11 @@ define ['app', 'marionette', 'vent', 'utils', 'views/mix/mixListLayout', 'views/mix/mixListView', 'views/mix/mixDetailView', - 'views/schedule/scheduleView', + 'views/show/scheduleShowLayout', 'views/mix/mixEditView', 'views/user/userProfileView', 'views/user/userListView', 'views/user/userEditView', 'models/mix/mixCollection', 'models/mix/mixItem', 'models/user/userItem'], (App, Marionette, vent, utils, MixListLayout, MixListView, MixDetailView, - ScheduleView, + ScheduleShowLayout, MixEditView, UserProfileView, UserListView, UserEditView, MixCollection, MixItem, UserItem)-> class DssController extends Marionette.Controller @@ -22,8 +22,8 @@ define ['app', 'marionette', 'vent', 'utils', showSchedule: -> app = require('app') - app.contentRegion.show(new ScheduleView()) - vent.trigger('schedule:show') + app.contentRegion.show(new ScheduleShowLayout()) + vent.trigger('show:schedule:show') showMixList: (options, emptyTemplate) -> app = require('app') diff --git a/static/js/app/lib/controller.js b/static/js/app/lib/controller.js index 0207e52..a47ad6d 100755 --- a/static/js/app/lib/controller.js +++ b/static/js/app/lib/controller.js @@ -3,7 +3,7 @@ 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/schedule/scheduleView', '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, ScheduleView, MixEditView, UserProfileView, UserListView, UserEditView, MixCollection, MixItem, UserItem) { + define(['app', 'marionette', 'vent', 'utils', 'views/mix/mixListLayout', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/show/scheduleShowLayout', '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, ScheduleShowLayout, MixEditView, UserProfileView, UserListView, UserEditView, MixCollection, MixItem, UserItem) { var DssController; DssController = (function(_super) { @@ -29,8 +29,8 @@ DssController.prototype.showSchedule = function() { var app; app = require('app'); - app.contentRegion.show(new ScheduleView()); - return vent.trigger('schedule:show'); + app.contentRegion.show(new ScheduleShowLayout()); + return vent.trigger('show:schedule:show'); }; DssController.prototype.showMixList = function(options, emptyTemplate) { diff --git a/static/js/app/models/show/showCollection.coffee b/static/js/app/models/show/showCollection.coffee new file mode 100644 index 0000000..1859f3f --- /dev/null +++ b/static/js/app/models/show/showCollection.coffee @@ -0,0 +1,15 @@ +define ['backbone', 'models/show/showItem', 'app.lib/backbone.dss.model.collection'], +(Backbone, ShowItem, DssCollection) -> + class ScheduleCollection extends DssCollection + model: ShowItem + page: 0 + limit: 20 + url: -> + com.podnoms.settings.urlRoot + "shows/?limit=" + @limit + "&offset=" + Math.max(@page-1, 0) * @limit + + initialize: -> + if not ShowItem + @model = require('models/show/showItem') + + ScheduleCollection + diff --git a/static/js/app/models/show/showCollection.js b/static/js/app/models/show/showCollection.js new file mode 100644 index 0000000..5b90c05 --- /dev/null +++ b/static/js/app/models/show/showCollection.js @@ -0,0 +1,38 @@ +// 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(['backbone', 'models/show/showItem', 'app.lib/backbone.dss.model.collection'], function(Backbone, ShowItem, DssCollection) { + var ScheduleCollection; + ScheduleCollection = (function(_super) { + + __extends(ScheduleCollection, _super); + + function ScheduleCollection() { + return ScheduleCollection.__super__.constructor.apply(this, arguments); + } + + ScheduleCollection.prototype.model = ShowItem; + + ScheduleCollection.prototype.page = 0; + + ScheduleCollection.prototype.limit = 20; + + ScheduleCollection.prototype.url = function() { + return com.podnoms.settings.urlRoot + "shows/?limit=" + this.limit + "&offset=" + Math.max(this.page - 1, 0) * this.limit; + }; + + ScheduleCollection.prototype.initialize = function() { + if (!ShowItem) { + return this.model = require('models/show/showItem'); + } + }; + + return ScheduleCollection; + + })(DssCollection); + return ScheduleCollection; + }); + +}).call(this); diff --git a/static/js/app/models/show/showItem.coffee b/static/js/app/models/show/showItem.coffee new file mode 100644 index 0000000..45f1847 --- /dev/null +++ b/static/js/app/models/show/showItem.coffee @@ -0,0 +1,12 @@ +define ['models/user/userCollection', 'app.lib/backbone.dss.model'], +(UserCollection, DssModel) -> + class UserItem extends DssModel + urlRoot: com.podnoms.settings.urlRoot + "user/" + relations: [ + type: Backbone.Many + key: "followers" + relatedModel: Backbone.Self + collectionType: UserCollection + ] + + UserItem \ No newline at end of file diff --git a/static/js/app/models/show/showItem.js b/static/js/app/models/show/showItem.js new file mode 100644 index 0000000..da7fae2 --- /dev/null +++ b/static/js/app/models/show/showItem.js @@ -0,0 +1,33 @@ +// 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(['models/user/userCollection', 'app.lib/backbone.dss.model'], function(UserCollection, DssModel) { + var UserItem; + UserItem = (function(_super) { + + __extends(UserItem, _super); + + function UserItem() { + return UserItem.__super__.constructor.apply(this, arguments); + } + + UserItem.prototype.urlRoot = com.podnoms.settings.urlRoot + "user/"; + + UserItem.prototype.relations = [ + { + type: Backbone.Many, + key: "followers", + relatedModel: Backbone.Self, + collectionType: UserCollection + } + ]; + + return UserItem; + + })(DssModel); + return UserItem; + }); + +}).call(this); diff --git a/static/js/app/models/user/userCollection.coffee b/static/js/app/models/user/userCollection.coffee index c454744..97c7a16 100755 --- a/static/js/app/models/user/userCollection.coffee +++ b/static/js/app/models/user/userCollection.coffee @@ -7,7 +7,6 @@ define ['backbone', 'models/user/userItem', 'app.lib/backbone.dss.model.collecti url: -> com.podnoms.settings.urlRoot + "user/?limit=" + @limit + "&offset=" + Math.max(@page-1, 0) * @limit initialize: -> - console.clear() if not UserItem @model = require('models/user/userItem') diff --git a/static/js/app/models/user/userCollection.js b/static/js/app/models/user/userCollection.js index 625931f..c92f000 100755 --- a/static/js/app/models/user/userCollection.js +++ b/static/js/app/models/user/userCollection.js @@ -24,7 +24,6 @@ }; UserCollection.prototype.initialize = function() { - console.clear(); if (!UserItem) { return this.model = require('models/user/userItem'); } diff --git a/static/js/app/views/schedule/scheduleView.coffee b/static/js/app/views/show/scheduleShowLayout.coffee similarity index 59% rename from static/js/app/views/schedule/scheduleView.coffee rename to static/js/app/views/show/scheduleShowLayout.coffee index 20b6574..1f83b28 100644 --- a/static/js/app/views/schedule/scheduleView.coffee +++ b/static/js/app/views/show/scheduleShowLayout.coffee @@ -1,34 +1,33 @@ -define ['app', 'vent', 'marionette', 'fullcalendar', 'text!/tpl/ScheduleView'], -(App, vent, Marionette, fullcalendar, Template)-> - class ScheduleView extends Marionette.ItemView +define ['app', 'vent', 'marionette', 'fullcalendar', + 'views/show/scheduleShowMixListView', + 'models/show/showCollection', + 'models/mix/mixCollection', + 'text!/tpl/ShowScheduleLayout'], +(App, vent, Marionette, fullcalendar, + ScheduleShowMixList, + ScheduleCollection, + MixCollection, + Template)-> + class ScheduleShowLayout extends Marionette.Layout template: _.template(Template) + regions: + availableMixes: "#external-events" + + initialize: (options)-> + @collection = new ScheduleCollection() + @options = options + + @collection = new MixCollection() + @collection.fetch + data: options + success: (collection)=> + @availableMixes.show(new ScheduleShowMixList({collection: collection})) + return onShow: -> + @calendar = $("#calendar").fullCalendar( + default: "agendaDay" - $("#external-events div.external-event").each -> - - # create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/) - # it doesn't need to have a start or end - eventObject = - title: $.trim($(this).text()) # use the element's text as the event title - - # store the Event Object in the DOM element so we can get to it later - $(this).data "eventObject", eventObject - - # make the event draggable using jQuery UI - $(this).draggable - zIndex: 999 - revert: true # will cause the event to go back to its - revertDuration: 0 # original position after the drag - - return - - date = new Date() - d = date.getDate() - m = date.getMonth() - y = date.getFullYear() - calendar = $("#calendar").fullCalendar( - #isRTL: true, buttonText: prev: "" next: "" @@ -38,27 +37,9 @@ define ['app', 'vent', 'marionette', 'fullcalendar', 'text!/tpl/ScheduleView'], center: "title" right: "month,agendaWeek,agendaDay" - events: [ - { - title: "All Day Event" - start: new Date(y, m, 1) - className: "label-important" - } - { - title: "Long Event" - start: new Date(y, m, d - 5) - end: new Date(y, m, d - 2) - className: "label-success" - } - { - title: "Some Event" - start: new Date(y, m, d - 3, 16, 0) - allDay: false - } - ] editable: true droppable: true # this allows things to be dropped onto the calendar !!! - drop: (date, allDay) -> # this function is called when something is dropped + drop: (date, allDay, jsEvent, ui) -> # this function is called when something is dropped # retrieve the dropped element's stored Event Object originalEventObject = $(this).data("eventObject") @@ -76,8 +57,7 @@ define ['app', 'vent', 'marionette', 'fullcalendar', 'text!/tpl/ScheduleView'], # the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/) $("#calendar").fullCalendar "renderEvent", copiedEventObject, true - # is the "remove after drop" checkbox checked? - + # is the "remove after drop" checbox checked? # if so, remove the element from the "Draggable Events" list $(this).remove() if $("#drop-remove").is(":checked") return @@ -85,15 +65,12 @@ define ['app', 'vent', 'marionette', 'fullcalendar', 'text!/tpl/ScheduleView'], selectable: true selectHelper: true select: (start, end, allDay) -> - bootbox.prompt "New Event Title:", (title) -> - if title isnt null - calendar.fullCalendar "renderEvent", - title: title - start: start - end: end - allDay: allDay - , true # make the event "stick" - return + calendar.fullCalendar "renderEvent", + title: title + start: start + end: end + allDay: allDay + , true # make the event "stick" calendar.fullCalendar "unselect" return @@ -123,8 +100,22 @@ define ['app', 'vent', 'marionette', 'fullcalendar', 'text!/tpl/ScheduleView'], return ) + + @collection.fetch( + data: @options + success: => + console.log("ScheduleView: Collection fetched") + @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 + ) true - - ScheduleView + ScheduleShowLayout diff --git a/static/js/app/views/schedule/scheduleView.js b/static/js/app/views/show/scheduleShowLayout.js similarity index 60% rename from static/js/app/views/schedule/scheduleView.js rename to static/js/app/views/show/scheduleShowLayout.js index b18b899..a6975b3 100644 --- a/static/js/app/views/schedule/scheduleView.js +++ b/static/js/app/views/show/scheduleShowLayout.js @@ -3,37 +3,41 @@ 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', 'text!/tpl/ScheduleView'], function(App, vent, Marionette, fullcalendar, Template) { - var ScheduleView; - ScheduleView = (function(_super) { + 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(ScheduleView, _super); + __extends(ScheduleShowLayout, _super); - function ScheduleView() { - return ScheduleView.__super__.constructor.apply(this, arguments); + function ScheduleShowLayout() { + return ScheduleShowLayout.__super__.constructor.apply(this, arguments); } - ScheduleView.prototype.template = _.template(Template); + ScheduleShowLayout.prototype.template = _.template(Template); - ScheduleView.prototype.onShow = function() { - var calendar, d, date, m, y; - $("#external-events div.external-event").each(function() { - var eventObject; - eventObject = { - title: $.trim($(this).text()) - }; - $(this).data("eventObject", eventObject); - $(this).draggable({ - zIndex: 999, - revert: true, - revertDuration: 0 - }); + ScheduleShowLayout.prototype.regions = { + availableMixes: "#external-events" + }; + + ScheduleShowLayout.prototype.initialize = function(options) { + var _this = this; + this.collection = new ScheduleCollection(); + this.options = options; + this.collection = new MixCollection(); + this.collection.fetch({ + data: options, + success: function(collection) { + return _this.availableMixes.show(new ScheduleShowMixList({ + collection: collection + })); + } }); - date = new Date(); - d = date.getDate(); - m = date.getMonth(); - y = date.getFullYear(); - return calendar = $("#calendar").fullCalendar({ + }; + + ScheduleShowLayout.prototype.onShow = function() { + var _this = this; + this.calendar = $("#calendar").fullCalendar({ + "default": "agendaDay", buttonText: { prev: "", next: "" @@ -43,25 +47,9 @@ center: "title", right: "month,agendaWeek,agendaDay" }, - events: [ - { - title: "All Day Event", - start: new Date(y, m, 1), - className: "label-important" - }, { - title: "Long Event", - start: new Date(y, m, d - 5), - end: new Date(y, m, d - 2), - className: "label-success" - }, { - title: "Some Event", - start: new Date(y, m, d - 3, 16, 0), - allDay: false - } - ], editable: true, droppable: true, - drop: function(date, allDay) { + drop: function(date, allDay, jsEvent, ui) { var $extraEventClass, copiedEventObject, originalEventObject; originalEventObject = $(this).data("eventObject"); $extraEventClass = $(this).attr("data-class"); @@ -79,16 +67,12 @@ selectable: true, selectHelper: true, select: function(start, end, allDay) { - bootbox.prompt("New Event Title:", function(title) { - if (title !== null) { - calendar.fullCalendar("renderEvent", { - title: title, - start: start, - end: end, - allDay: allDay - }, true); - } - }); + calendar.fullCalendar("renderEvent", { + title: title, + start: start, + end: end, + allDay: allDay + }, true); calendar.fullCalendar("unselect"); }, eventClick: function(calEvent, jsEvent, view) { @@ -112,14 +96,29 @@ }); } }); + return this.collection.fetch({ + data: this.options, + success: function() { + console.log("ScheduleView: Collection fetched"); + _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" + }); + }); + } + }); }; true; - return ScheduleView; + return ScheduleShowLayout; - })(Marionette.ItemView); - return ScheduleView; + })(Marionette.Layout); + return ScheduleShowLayout; }); }).call(this); diff --git a/static/js/app/views/show/scheduleShowMixListView.coffee b/static/js/app/views/show/scheduleShowMixListView.coffee new file mode 100644 index 0000000..a9b961e --- /dev/null +++ b/static/js/app/views/show/scheduleShowMixListView.coffee @@ -0,0 +1,38 @@ +define ['app', 'vent', 'marionette', 'fullcalendar', + 'models/show/showCollection', + 'models/mix/mixCollection', + 'text!/tpl/ShowScheduleMixItem'], +(App, vent, Marionette, fullcalendar, + ScheduleCollection, MixCollection, + Template)-> + + class ScheduleShowMixItem extends Marionette.ItemView + template: _.template(Template) + + class ScheduleShowMixList extends Marionette.CollectionView + itemView: ScheduleShowMixItem + + initialize: (options)-> + console.log("ScheduleShowMixList: initialize") + true + + onShow: -> + $("#external-events div.external-event").each -> + + eventObject = + title: $.trim($(this).text()) # use the element's text as the event title + + # store the Event Object in the DOM element so we can get to it later + $(this).data "eventObject", eventObject + + # make the event draggable using jQuery UI + $(this).draggable + zIndex: 999 + revert: true # will cause the event to go back to its + revertDuration: 0 # original position after the drag + + return + true + ScheduleShowMixList + + diff --git a/static/js/app/views/show/scheduleShowMixListView.js b/static/js/app/views/show/scheduleShowMixListView.js new file mode 100644 index 0000000..39dda5d --- /dev/null +++ b/static/js/app/views/show/scheduleShowMixListView.js @@ -0,0 +1,59 @@ +// 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() { + var eventObject; + eventObject = { + title: $.trim($(this).text()) + }; + $(this).data("eventObject", eventObject); + $(this).draggable({ + zIndex: 999, + revert: true, + revertDuration: 0 + }); + }); + }; + + true; + + return ScheduleShowMixList; + + })(Marionette.CollectionView); + return ScheduleShowMixList; + }); + +}).call(this); diff --git a/templates/views/ScheduleView.html b/templates/views/ScheduleView.html deleted file mode 100644 index c0653ed..0000000 --- a/templates/views/ScheduleView.html +++ /dev/null @@ -1,61 +0,0 @@ -
-
-
- -
-
- -
-
-
-

Draggable events

-
- -
-
-
-
- - My Event 1 -
- -
- - My Event 2 -
- -
- - My Event 3 -
- -
- - My Event 4 -
- -
- - My Event 5 -
- -
- - My Event 6 -
- -
- - My Event 7 -
- - -
-
-
-
-
-
\ No newline at end of file diff --git a/templates/views/ShowScheduleLayout.html b/templates/views/ShowScheduleLayout.html new file mode 100644 index 0000000..4ff1012 --- /dev/null +++ b/templates/views/ShowScheduleLayout.html @@ -0,0 +1,20 @@ +
+
+
+ +
+
+
+
+
+

Schedule shows

+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/templates/views/ShowScheduleMixItem.html b/templates/views/ShowScheduleMixItem.html new file mode 100644 index 0000000..428d688 --- /dev/null +++ b/templates/views/ShowScheduleMixItem.html @@ -0,0 +1,4 @@ +
+ + <%= title %> +
\ No newline at end of file