diff --git a/NzbDrone.Core/Datastore/Converters/UtcConverter.cs b/NzbDrone.Core/Datastore/Converters/UtcConverter.cs index 9fd2b7aa9..0bdc802dc 100644 --- a/NzbDrone.Core/Datastore/Converters/UtcConverter.cs +++ b/NzbDrone.Core/Datastore/Converters/UtcConverter.cs @@ -13,6 +13,11 @@ namespace NzbDrone.Core.Datastore.Converters public object ToDB(object clrValue) { + if (clrValue == DBNull.Value) + { + return clrValue; + } + var dateTime = (DateTime)clrValue; return dateTime.ToUniversalTime(); } diff --git a/UI/Calendar/CalendarView.js b/UI/Calendar/CalendarView.js index e14786893..950b0b939 100644 --- a/UI/Calendar/CalendarView.js +++ b/UI/Calendar/CalendarView.js @@ -64,7 +64,7 @@ define(['app', 'Calendar/Collection'], function () { success: function (calendarCollection) { _.each(calendarCollection.models, function (element) { var episodeTitle = element.get('title'); - var seriesTitle = element.get('series').title; + var seriesTitle = element.get('series').get('title'); var start = element.get('airDate'); element.set('title', seriesTitle); diff --git a/UI/Calendar/UpcomingItemTemplate.html b/UI/Calendar/UpcomingItemTemplate.html index 9b4ac731c..75f9a48b0 100644 --- a/UI/Calendar/UpcomingItemTemplate.html +++ b/UI/Calendar/UpcomingItemTemplate.html @@ -3,7 +3,7 @@

{{day}}

{{month}}

- +

{{series.title}}

{{startTime}} {{date airDate}}{{seasonNumber}}x{{paddedEpisodeNumber}}
{{episodeTitle}}

diff --git a/UI/Cells/EpisodeNumberCell.js b/UI/Cells/EpisodeNumberCell.js index 6e20c1cd0..c15ded062 100644 --- a/UI/Cells/EpisodeNumberCell.js +++ b/UI/Cells/EpisodeNumberCell.js @@ -7,26 +7,41 @@ define(['app', 'Cells/NzbDroneCell'], function () { render: function () { - var airDate = this.cellValue.get('airDate') || this.get(this.column.get("airDate")); - var seasonNumber = this.cellValue.get('seasonNumber') || this.model.get(this.column.get("seasonNumber")); - var episodes = this.cellValue.get('episodeNumber') || this.model.get(this.column.get("episodes")); + this.$el.empty(); - var result = 'Unknown'; + var airDateField = this.column.get('airDate') || 'airDate'; + var seasonFiled = this.column.get('seasonNumber') || 'seasonNumber'; + var episodeFiled = this.column.get('episodes') || 'episodeNumber'; - if (airDate) { + if (this.cellValue) { - result = new Date(airDate).toLocaleDateString(); + var airDate = this.cellValue.get(airDateField); + var seasonNumber = this.cellValue.get(seasonFiled); + var episodes = this.cellValue.get(episodeFiled); + + var result = 'Unknown'; + + if (episodes) { + + var paddedEpisodes; + + if (episodes.constructor === Array) { + paddedEpisodes = _.map(episodes,function (episodeNumber) { + return episodeNumber.pad(2); + }).join(); + } + else { + paddedEpisodes = episodes.pad(2); + } + + result = 'S{0}-E{1}'.format(seasonNumber.pad(2), paddedEpisodes); + } + else if (airDate) { + result = new Date(airDate).toLocaleDateString(); + } + + this.$el.html(result); } - else { - - var paddedEpisodes = _.map(episodes, function (episodeNumber) { - return episodeNumber.pad(2); - }); - - result = 'S{0}-E{1}'.format(seasonNumber, paddedEpisodes.join()); - } - - this.$el.html(result); this.delegateEvents(); return this; } diff --git a/UI/Cells/NzbDroneCell.js b/UI/Cells/NzbDroneCell.js index 3decea035..9d4e619f0 100644 --- a/UI/Cells/NzbDroneCell.js +++ b/UI/Cells/NzbDroneCell.js @@ -28,9 +28,13 @@ define(['app'], function () { var value = this.model.get(name); + if(!value){ + return undefined; + } + //if not a model if (!value.get) { - return value = new Backbone.Model(value); + value = new Backbone.Model(value); } return value; diff --git a/UI/Series/EpisodeModel.js b/UI/Series/EpisodeModel.js index da86988c6..31924b647 100644 --- a/UI/Series/EpisodeModel.js +++ b/UI/Series/EpisodeModel.js @@ -1,5 +1,5 @@ "use strict"; -define(['app','Series/SeriesModel'], function () { +define(['app', 'Series/SeriesModel'], function () { NzbDrone.Series.EpisodeModel = Backbone.Model.extend({ mutators: { @@ -62,6 +62,13 @@ define(['app','Series/SeriesModel'], function () { return model; }, + toJSON: function () { + var json = _.clone(this.attributes); + json.series = this.get('series').toJSON(); + + return json; + }, + defaults: { seasonNumber: 0, status : 0