From dee84c0493a3558cbf16543e4a2c09f2f9b3b13d Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 26 Aug 2015 18:05:36 +0200 Subject: [PATCH] Suggestion & Charts cleanup --- couchpotato/core/media/movie/charts/__init__.py | 9 +----- .../core/media/movie/charts/static/charts.js | 34 ++-------------------- .../media/movie/providers/automation/bluray.py | 2 +- .../core/media/movie/providers/automation/imdb.py | 2 +- couchpotato/core/media/movie/suggestion.py | 24 +++++++++++++++ couchpotato/static/scripts/combined.plugins.min.js | 28 ++---------------- 6 files changed, 32 insertions(+), 67 deletions(-) diff --git a/couchpotato/core/media/movie/charts/__init__.py b/couchpotato/core/media/movie/charts/__init__.py index 1888f85..0b89eaf 100644 --- a/couchpotato/core/media/movie/charts/__init__.py +++ b/couchpotato/core/media/movie/charts/__init__.py @@ -14,14 +14,7 @@ config = [{ 'type': 'list', 'name': 'charts_providers', 'tab': 'display', - 'options': [ - { - 'name': 'max_items', - 'default': 5, - 'type': 'int', - 'description': 'Maximum number of items displayed from each chart.', - }, - ], + 'options': [], }, ], }] diff --git a/couchpotato/core/media/movie/charts/static/charts.js b/couchpotato/core/media/movie/charts/static/charts.js index 0481fb6..5c956d9 100644 --- a/couchpotato/core/media/movie/charts/static/charts.js +++ b/couchpotato/core/media/movie/charts/static/charts.js @@ -14,28 +14,8 @@ var Charts = new Class({ create: function(){ var self = this; - self.el = new Element('div.charts').adopt( - self.el_no_charts_enabled = new Element('p.no_charts_enabled', { - 'html': 'Hey, it looks like you have no charts enabled at the moment. If you\'d like some great movie suggestions you can go to settings and turn on some charts of your choice.' - }), - self.el_refresh_container = new Element('div.refresh').adopt( - self.el_refresh_link = new Element('a.refresh.icon2', { - 'href': '#', - 'events': { - 'click': function(e) { - e.preventDefault(); - - self.el.getElements('.chart').destroy(); - self.el_refreshing_text.show(); - self.el_refresh_link.hide(); - - self.api_request = Api.request('charts.view', { - 'data': { 'force_update': 1 }, - 'onComplete': self.fill.bind(self) - }); - } - } - }), + self.el = new Element('div.charts').grab( + self.el_refresh_container = new Element('div.refresh').grab( self.el_refreshing_text = new Element('span.refreshing', { 'text': 'Refreshing charts...' }) @@ -52,16 +32,8 @@ var Charts = new Class({ var self = this; self.el_refreshing_text.hide(); - self.el_refresh_link.show(); - - if(!json || json.count === 0){ - self.el_no_charts_enabled.show(); - self.el_refresh_link.show(); - self.el_refreshing_text.hide(); - } - else { - self.el_no_charts_enabled.hide(); + if(json && json.count > 0){ json.charts.sort(function(a, b) { return a.order - b.order; }); diff --git a/couchpotato/core/media/movie/providers/automation/bluray.py b/couchpotato/core/media/movie/providers/automation/bluray.py index ab312c0..1227c60 100644 --- a/couchpotato/core/media/movie/providers/automation/bluray.py +++ b/couchpotato/core/media/movie/providers/automation/bluray.py @@ -116,7 +116,7 @@ class Bluray(Automation, RSS): if not movie_list['list']: movie_ids = [] - max_items = int(self.conf('max_items', section='charts', default=5)) + max_items = 10 rss_movies = self.getRSSData(self.rss_url) for movie in rss_movies: diff --git a/couchpotato/core/media/movie/providers/automation/imdb.py b/couchpotato/core/media/movie/providers/automation/imdb.py index 4a5d07a..b84949f 100644 --- a/couchpotato/core/media/movie/providers/automation/imdb.py +++ b/couchpotato/core/media/movie/providers/automation/imdb.py @@ -181,7 +181,7 @@ class IMDBCharts(IMDBBase): def getChartList(self): # Nearly identical to 'getIMDBids', but we don't care about minimalMovie and return all movie data (not just id) movie_lists = [] - max_items = int(self.conf('max_items', section = 'charts', default=5)) + max_items = 10 for name in self.charts: chart = self.charts[name].copy() diff --git a/couchpotato/core/media/movie/suggestion.py b/couchpotato/core/media/movie/suggestion.py index 2b4fd7b..04cda51 100644 --- a/couchpotato/core/media/movie/suggestion.py +++ b/couchpotato/core/media/movie/suggestion.py @@ -23,6 +23,11 @@ class Suggestion(Plugin): addEvent('app.load', test) def suggestView(self, limit = 6, **kwargs): + if self.isDisabled(): + return { + 'success': True, + 'movies': [] + } movies = splitString(kwargs.get('movies', '')) ignored = splitString(kwargs.get('ignored', '')) @@ -139,3 +144,22 @@ class Suggestion(Plugin): self.setCache('suggestion_cached', new_suggestions, timeout = 3024000) return new_suggestions + +config = [{ + 'name': 'suggestion', + 'groups': [ + { + 'label': 'Suggestions', + 'description': 'Displays suggestions on the home page', + 'name': 'suggestions', + 'tab': 'display', + 'options': [ + { + 'name': 'enabled', + 'default': True, + 'type': 'enabler', + }, + ], + }, + ], +}] diff --git a/couchpotato/static/scripts/combined.plugins.min.js b/couchpotato/static/scripts/combined.plugins.min.js index 9b3a158..42e9c14 100644 --- a/couchpotato/static/scripts/combined.plugins.min.js +++ b/couchpotato/static/scripts/combined.plugins.min.js @@ -2351,25 +2351,7 @@ var Charts = new Class({ }, create: function() { var self = this; - self.el = new Element("div.charts").adopt(self.el_no_charts_enabled = new Element("p.no_charts_enabled", { - html: "Hey, it looks like you have no charts enabled at the moment. If you'd like some great movie suggestions you can go to settings and turn on some charts of your choice.' - }), self.el_refresh_container = new Element("div.refresh").adopt(self.el_refresh_link = new Element("a.refresh.icon2", { - href: "#", - events: { - click: function(e) { - e.preventDefault(); - self.el.getElements(".chart").destroy(); - self.el_refreshing_text.show(); - self.el_refresh_link.hide(); - self.api_request = Api.request("charts.view", { - data: { - force_update: 1 - }, - onComplete: self.fill.bind(self) - }); - } - } - }), self.el_refreshing_text = new Element("span.refreshing", { + self.el = new Element("div.charts").grab(self.el_refresh_container = new Element("div.refresh").grab(self.el_refreshing_text = new Element("span.refreshing", { text: "Refreshing charts..." }))); self.show(); @@ -2378,13 +2360,7 @@ var Charts = new Class({ fill: function(json) { var self = this; self.el_refreshing_text.hide(); - self.el_refresh_link.show(); - if (!json || json.count === 0) { - self.el_no_charts_enabled.show(); - self.el_refresh_link.show(); - self.el_refreshing_text.hide(); - } else { - self.el_no_charts_enabled.hide(); + if (json && json.count > 0) { json.charts.sort(function(a, b) { return a.order - b.order; });