1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-24 17:10:31 +00:00

Bugfixes from testrun (load images from gdrive)

Fix locale for new users
This commit is contained in:
Ozzie Isaacs 2021-10-07 19:53:32 +02:00
parent aca5324914
commit 25f608d109
5 changed files with 508 additions and 1237 deletions

View File

@ -1352,8 +1352,6 @@ def _handle_new_user(to_save, content, languages, translations, kobo_support):
languages=languages, title=_(u"Add new user"), page="newuser", languages=languages, title=_(u"Add new user"), page="newuser",
kobo_support=kobo_support, registered_oauth=oauth_check) kobo_support=kobo_support, registered_oauth=oauth_check)
try: try:
content.default_language = config.config_default_language
content.locale = config.config_default_locale
content.allowed_tags = config.config_allowed_tags content.allowed_tags = config.config_allowed_tags
content.denied_tags = config.config_denied_tags content.denied_tags = config.config_denied_tags
content.allowed_column_value = config.config_allowed_column_value content.allowed_column_value = config.config_allowed_column_value
@ -1491,6 +1489,8 @@ def new_user():
else: else:
content.role = config.config_default_role content.role = config.config_default_role
content.sidebar_view = config.config_default_show content.sidebar_view = config.config_default_show
content.locale = config.config_default_locale
content.default_language = config.config_default_language
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations, return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
languages=languages, title=_(u"Add new user"), page="newuser", languages=languages, title=_(u"Add new user"), page="newuser",
kobo_support=kobo_support, registered_oauth=oauth_check) kobo_support=kobo_support, registered_oauth=oauth_check)

View File

@ -21,7 +21,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import os import os
import sys
import hashlib import hashlib
import json import json
import tempfile import tempfile
@ -33,7 +32,7 @@ from flask import Blueprint, flash, request, redirect, url_for, abort
from flask_babel import gettext as _ from flask_babel import gettext as _
from flask_login import login_required from flask_login import login_required
from . import logger, gdriveutils, config, ub, calibre_db from . import logger, gdriveutils, config, ub, calibre_db, csrf
from .admin import admin_required from .admin import admin_required
gdrive = Blueprint('gdrive', __name__, url_prefix='/gdrive') gdrive = Blueprint('gdrive', __name__, url_prefix='/gdrive')
@ -117,6 +116,7 @@ def revoke_watch_gdrive():
return redirect(url_for('admin.db_configuration')) return redirect(url_for('admin.db_configuration'))
@csrf.exempt
@gdrive.route("/watch/callback", methods=['GET', 'POST']) @gdrive.route("/watch/callback", methods=['GET', 'POST'])
def on_received_watch_confirmation(): def on_received_watch_confirmation():
if not config.config_google_drive_watch_changes_response: if not config.config_google_drive_watch_changes_response:

View File

@ -33,7 +33,7 @@
<label for="locale">{{_('Language')}}</label> <label for="locale">{{_('Language')}}</label>
<select name="locale" id="locale" class="form-control"> <select name="locale" id="locale" class="form-control">
{% for translation in translations %} {% for translation in translations %}
<option value="{{translation}}" {% if translation|string == content.locale %}selected{% endif %} {% if new_user == 1 and loop.first %}selected{% endif %}>{{ translation.display_name|capitalize }}</option> <option value="{{translation}}" {% if translation|string == content.locale %}selected{% endif %}>{{ translation.display_name|capitalize }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -42,7 +42,7 @@
<div class="form-group"> <div class="form-group">
<label for="default_language">{{_('Language of Books')}}</label> <label for="default_language">{{_('Language of Books')}}</label>
<select name="default_language" id="default_language" class="form-control"> <select name="default_language" id="default_language" class="form-control">
<option value="all" {% if new_user == 1 %}selected{% endif %}>{{ _('Show All') }}</option> <option value="all" {% if content.default_language == "all" %}selected{% endif %}>{{ _('Show All') }}</option>
{% for language in languages %} {% for language in languages %}
<option value="{{ language.lang_code }}" {% if content.default_language == language.lang_code %}selected{% endif %}>{{ language.name }}</option> <option value="{{ language.lang_code }}" {% if content.default_language == language.lang_code %}selected{% endif %}>{{ language.name }}</option>
{% endfor %} {% endfor %}

View File

@ -83,7 +83,7 @@ except ImportError:
@app.after_request @app.after_request
def add_security_headers(resp): def add_security_headers(resp):
resp.headers['Content-Security-Policy'] = "default-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:" resp.headers['Content-Security-Policy'] = "default-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:"
if request.endpoint == "editbook.edit_book": if request.endpoint == "editbook.edit_book" or config.config_use_google_drive:
resp.headers['Content-Security-Policy'] += " *" resp.headers['Content-Security-Policy'] += " *"
resp.headers['X-Content-Type-Options'] = 'nosniff' resp.headers['X-Content-Type-Options'] = 'nosniff'
resp.headers['X-Frame-Options'] = 'SAMEORIGIN' resp.headers['X-Frame-Options'] = 'SAMEORIGIN'

File diff suppressed because it is too large Load Diff