diff --git a/cps/admin.py b/cps/admin.py index b250d78c..17331dec 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -702,6 +702,9 @@ def edit_user(user_id): elif "edit_shelf_role" not in to_save and content.role_edit_shelfs(): content.role = content.role - ub.ROLE_EDIT_SHELFS + # next(v for k, v in my_dict.items() if k.startswith('show')) + val=[{k[5:]:v} for k, v in to_save.items() if k.startswith('show')] + # ['15th july'] if "show_random" in to_save and not content.show_random_books(): content.sidebar_view += ub.SIDEBAR_RANDOM elif "show_random" not in to_save and content.show_random_books(): diff --git a/cps/templates/config_view_edit.html b/cps/templates/config_view_edit.html index 86df4451..ad9a0a44 100644 --- a/cps/templates/config_view_edit.html +++ b/cps/templates/config_view_edit.html @@ -114,7 +114,15 @@
+ + {% for element in sidebar %}
+ + +
+ {% endfor %} + +
diff --git a/cps/templates/layout.html b/cps/templates/layout.html index 9b602eec..d1441fee 100644 --- a/cps/templates/layout.html +++ b/cps/templates/layout.html @@ -119,11 +119,8 @@
{% endif %}
-
+ {% for element in sidebar %} + {% if element['public'] %} +
+ + +
+ {% endif %} + {% endfor %} + + {% if not content.role_anonymous() %}
diff --git a/cps/ub.py b/cps/ub.py index 688d5bee..351b18ce 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -156,6 +156,9 @@ class UserBase: def filter_language(self): return self.default_language + def check_visibility(self, value): + return bool((self.sidebar_view is not None) and (self.sidebar_view & value == value)) + def show_random_books(self): return bool((self.sidebar_view is not None)and(self.sidebar_view & SIDEBAR_RANDOM == SIDEBAR_RANDOM)) @@ -548,6 +551,10 @@ class Config: return bool((self.config_default_show is not None) and (self.config_default_show & DETAIL_RANDOM == DETAIL_RANDOM)) + def show_element(self, value): + return bool((self.config_default_show is not None) and + (self.config_default_show & value == value)) + def show_language(self): return bool((self.config_default_show is not None) and (self.config_default_show & SIDEBAR_LANGUAGE == SIDEBAR_LANGUAGE)) diff --git a/cps/web.py b/cps/web.py index a57f2f45..4287f13c 100644 --- a/cps/web.py +++ b/cps/web.py @@ -22,7 +22,8 @@ # along with this program. If not, see . from cps import mimetypes, global_WorkerThread, searched_ids -from flask import render_template, request, redirect, url_for, send_from_directory, make_response, g, flash, abort +from flask import render_template, request, redirect, send_from_directory, make_response, g, flash, abort, \ + url_for from werkzeug.exceptions import default_exceptions import helper import os @@ -109,6 +110,8 @@ EXTENSIONS_AUDIO = {'mp3', 'm4a', 'm4b'} (['rar','cbr'] if feature_support['rar'] else []))''' +# with app.app_context(): + # custom error page def error_http(error): return render_template('http_error.html', @@ -321,7 +324,19 @@ def get_search_results(term): # Returns the template for rendering and includes the instance name def render_title_template(*args, **kwargs): - return render_template(instance=config.config_calibre_web_title, *args, **kwargs) + sidebar=list() + sidebar.append({"glyph":"glyphicon-book","text":_('Recently Added'),"link":url_for('web.index'),"id":"new", "visibility":ub.SIDEBAR_RECENT, 'public':True, "page": "root", "show_text":_('Show recent books')}) + sidebar.append({"glyph":"glyphicon-fire","text":_('Hot Books'),"link":url_for('web.hot_books'),"id":"hot", "visibility":ub.SIDEBAR_HOT, 'public':True, "page": "hot", "show_text":_('Show hot books')}) + sidebar.append({"glyph":"glyphicon-star","text":_('Best rated Books'),"link":url_for('web.best_rated_books'),"id":"rated","visibility":ub.SIDEBAR_BEST_RATED, 'public':True, "page": "rated", "show_text":_('Show best rated books')}) + sidebar.append({"glyph":"glyphicon-eye-open","text":_('Read Books'),"link":url_for('web.read_books'),"id":"read","visibility":ub.SIDEBAR_READ_AND_UNREAD, 'public':(not g.user.is_anonymous), "page": "read", "show_text":_('Show read')}) + sidebar.append({"glyph":"glyphicon-eye-close","text":_('Unread Books'),"link":url_for('web.unread_books'),"id":"unread","visibility":ub.SIDEBAR_READ_AND_UNREAD, 'public':(not g.user.is_anonymous), "page": "read", "show_text":_('Show unread')}) + sidebar.append({"glyph":"glyphicon-random","text":_('Discover'),"link":url_for('web.discover'),"id":"rand","visibility":ub.SIDEBAR_RANDOM, 'public':True, "page": "discover", "show_text":_('Show random books')}) + sidebar.append({"glyph":"glyphicon-inbox","text":_('Categories'),"link":url_for('web.category_list'),"id":"cat","visibility":ub.SIDEBAR_CATEGORY, 'public':True, "page": "category", "show_text":_('Show category selection')}) + sidebar.append({"glyph":"glyphicon-bookmark","text":_('Series'),"link":url_for('web.series_list'),"id":"serie","visibility":ub.SIDEBAR_SERIES, 'public':True, "page": "series", "show_text":_('Show series selection')}) + sidebar.append({"glyph":"glyphicon-user","text":_('Authors'),"link":url_for('web.author_list'),"id":"author","visibility":ub.SIDEBAR_AUTHOR, 'public':True, "page": "author", "show_text":_('Show author selection')}) + sidebar.append({"glyph":"glyphicon-text-size","text":_('Publishers'),"link":url_for('web.publisher_list'),"id":"publisher","visibility":ub.SIDEBAR_PUBLISHER, 'public':True, "page": "publisher", "show_text":_('Show publisher selection')}) + sidebar.append({"glyph":"glyphicon-flag","text":_('Languages'),"link":url_for('web.language_overview'),"id":"lang","visibility":ub.SIDEBAR_LANGUAGE, 'public':(g.user.filter_language() == 'all'), "page": "language", "show_text":_('Show language selection')}) + return render_template(instance=config.config_calibre_web_title, sidebar=sidebar, *args, **kwargs) @web.before_app_request @@ -346,6 +361,9 @@ def get_email_status_json(): return response + + + ''' @web.route("/ajax/getcomic///") @login_required