55# SPDX-License-Identifier: GPL-3.0-or-later
66# See CONTRIBUTORS for full list of authors.
77
8- from flask import render_template , g , abort , request , flash
8+ from flask import render_template , g , abort , request , flash , current_app
99from flask_babel import gettext as _
1010from flask_babel import get_locale
1111import polib
@@ -224,6 +224,13 @@ def translations_missing_notification() -> None:
224224# Returns the template for rendering and includes the instance name
225225def render_title_template (* args , ** kwargs ):
226226 sidebar , simple = get_sidebar_config (kwargs )
227+ try :
228+ magic_shelf_routes = {
229+ "render" : 'web.render_magic_shelf' in current_app .view_functions ,
230+ "create" : 'web.create_magic_shelf' in current_app .view_functions ,
231+ }
232+ except Exception :
233+ magic_shelf_routes = {"render" : False , "create" : False }
227234 if current_user .role_admin ():
228235 try :
229236 cwa_update_notification ()
@@ -241,8 +248,9 @@ def render_title_template(*args, **kwargs):
241248 print (f"[translation-notification-service] The following error occurred when checking for missing translations:\n { e } " , flush = True )
242249 try :
243250 return render_template (instance = config .config_calibre_web_title , sidebar = sidebar , simple = simple ,
244- accept = config .config_upload_formats .split (',' ),
245- * args , ** kwargs )
251+ accept = config .config_upload_formats .split (',' ),
252+ magic_shelf_routes = magic_shelf_routes ,
253+ * args , ** kwargs )
246254 except PermissionError :
247255 log .error ("No permission to access {} file." .format (args [0 ]))
248256 abort (403 )
0 commit comments