diff --git a/ordering/static/js/index.js b/ordering/static/js/index.js index 0007a6a..e916c51 100644 --- a/ordering/static/js/index.js +++ b/ordering/static/js/index.js @@ -6,28 +6,6 @@ window.open(url, '_blank'); }; - var addFilters = function() { - var toFilterList = []; - - var selectedOptions = $('#show-filter-select').select2('data'); - $.each(selectedOptions, function() { - toFilterList.push(this.id); - }); - - var url = ''; - - if (toFilterList.length > 0) { - url = '/hide/' + toFilterList.join('+'); - } - - url += '/'; - - if (document.baseURI.match('/newest_first/$')) { - url += 'newest_first/'; - } - window.location = url; - }; - var disableColours = function() { $('.episode, thead').addClass('no-color'); $('#episode-list').addClass('table-striped table-hover'); @@ -44,7 +22,6 @@ var registerListeners = function() { $('.episode').click(openWiki); - $('#filter-button').click(addFilters); $('#no-color').click(function() { if (Cookies.get('colour') === '1') { diff --git a/ordering/templates/index.html b/ordering/templates/index.html index 55e36e4..ebdd957 100644 --- a/ordering/templates/index.html +++ b/ordering/templates/index.html @@ -38,20 +38,23 @@

Arrowverse Episode Order

- +
+ + +
-
@@ -65,11 +68,13 @@

Arrowverse Episode Order

diff --git a/ordering/utils.py b/ordering/utils.py index 47475fe..aa7c047 100644 --- a/ordering/utils.py +++ b/ordering/utils.py @@ -187,3 +187,10 @@ def get_full_series_episode_list(excluded_series=None): show_lists.append(show_list) return sort_episodes(show_lists) + + +def _get_bool(arg): + if isinstance(arg, bool): + return arg + + return arg == 'True' diff --git a/ordering/views.py b/ordering/views.py index e946400..62f5cae 100644 --- a/ordering/views.py +++ b/ordering/views.py @@ -1,17 +1,25 @@ -from flask import render_template +from flask import render_template, request from . import app -from .utils import get_full_series_episode_list +from .utils import _get_bool, get_full_series_episode_list @app.route('/', methods=['GET']) def index(): context = {} - episode_list = get_full_series_episode_list() + newest_first = request.args.get('newest_first', default=False, type=_get_bool) + hide_shows_list = request.args.getlist('hide_show') + + episode_list = get_full_series_episode_list(excluded_series=hide_shows_list) + + if newest_first: + episode_list = episode_list[::-1] context['table_content'] = episode_list context['show_list'] = app.config['SHOW_DICT'] + context['hidden_show_list'] = hide_shows_list + context['newest_first'] = newest_first return render_template('index.html', **context) @@ -35,7 +43,7 @@ def index_with_hidden(hide_list): episode_list = get_full_series_episode_list(hide_list) - context['hidden_list'] = hide_list + context['hidden_show_list'] = hide_list context['table_content'] = episode_list context['show_list'] = app.config['SHOW_DICT'] @@ -49,7 +57,7 @@ def index_with_hidden_newest_first(hide_list): episode_list = get_full_series_episode_list(hide_list) episode_list = episode_list[::-1] - context['hidden_list'] = hide_list + context['hidden_show_list'] = hide_list context['table_content'] = episode_list context['show_list'] = app.config['SHOW_DICT']