fix: avoid deprecated config methods for app/node title
This commit is contained in:
parent
7c3d5b46f3
commit
b8ace1eb98
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2023 Lance Edgar
|
# Copyright © 2010-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -27,8 +27,6 @@ Tailbone Web API - "Common" Views
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
import rattail
|
import rattail
|
||||||
from rattail.db import model
|
|
||||||
from rattail.mail import send_email
|
|
||||||
|
|
||||||
from cornice import Service
|
from cornice import Service
|
||||||
from cornice.service import get_services
|
from cornice.service import get_services
|
||||||
|
@ -66,7 +64,8 @@ class CommonView(APIView):
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_project_title(self):
|
def get_project_title(self):
|
||||||
return self.rattail_config.app_title(default="Tailbone")
|
app = self.get_rattail_app()
|
||||||
|
return app.get_title()
|
||||||
|
|
||||||
def get_project_version(self):
|
def get_project_version(self):
|
||||||
import tailbone
|
import tailbone
|
||||||
|
@ -87,6 +86,8 @@ class CommonView(APIView):
|
||||||
"""
|
"""
|
||||||
View to handle user feedback form submits.
|
View to handle user feedback form submits.
|
||||||
"""
|
"""
|
||||||
|
app = self.get_rattail_app()
|
||||||
|
model = self.model
|
||||||
# TODO: this logic was copied from tailbone.views.common and is largely
|
# TODO: this logic was copied from tailbone.views.common and is largely
|
||||||
# identical; perhaps should merge somehow?
|
# identical; perhaps should merge somehow?
|
||||||
schema = Feedback().bind(session=Session())
|
schema = Feedback().bind(session=Session())
|
||||||
|
@ -106,7 +107,7 @@ class CommonView(APIView):
|
||||||
|
|
||||||
data['client_ip'] = self.request.client_addr
|
data['client_ip'] = self.request.client_addr
|
||||||
email_key = data['email_key'] or self.feedback_email_key
|
email_key = data['email_key'] or self.feedback_email_key
|
||||||
send_email(self.rattail_config, email_key, data=data)
|
app.send_email(email_key, data=data)
|
||||||
return {'ok': True}
|
return {'ok': True}
|
||||||
|
|
||||||
return {'error': "Form did not validate!"}
|
return {'error': "Form did not validate!"}
|
||||||
|
|
|
@ -165,10 +165,11 @@ def before_render(event):
|
||||||
|
|
||||||
request = event.get('request') or threadlocal.get_current_request()
|
request = event.get('request') or threadlocal.get_current_request()
|
||||||
rattail_config = request.rattail_config
|
rattail_config = request.rattail_config
|
||||||
|
app = rattail_config.get_app()
|
||||||
|
|
||||||
renderer_globals = event
|
renderer_globals = event
|
||||||
renderer_globals['rattail_app'] = request.rattail_config.get_app()
|
renderer_globals['rattail_app'] = app
|
||||||
renderer_globals['app_title'] = request.rattail_config.app_title()
|
renderer_globals['app_title'] = app.get_title()
|
||||||
renderer_globals['h'] = helpers
|
renderer_globals['h'] = helpers
|
||||||
renderer_globals['url'] = request.route_url
|
renderer_globals['url'] = request.route_url
|
||||||
renderer_globals['rattail'] = rattail
|
renderer_globals['rattail'] = rattail
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
## -*- coding: utf-8; -*-
|
## -*- coding: utf-8; -*-
|
||||||
|
|
||||||
<%def name="app_title()">${request.rattail_config.node_title(default="Rattail")}</%def>
|
<%def name="app_title()">${rattail_app.get_node_title()}</%def>
|
||||||
|
|
||||||
<%def name="global_title()">${"[STAGE] " if not request.rattail_config.production() else ''}${self.app_title()}</%def>
|
<%def name="global_title()">${"[STAGE] " if not request.rattail_config.production() else ''}${self.app_title()}</%def>
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ class AuthenticationView(View):
|
||||||
"""
|
"""
|
||||||
The login view, responsible for displaying and handling the login form.
|
The login view, responsible for displaying and handling the login form.
|
||||||
"""
|
"""
|
||||||
|
app = self.get_rattail_app()
|
||||||
referrer = self.request.get_referrer(default=self.request.route_url('home'))
|
referrer = self.request.get_referrer(default=self.request.route_url('home'))
|
||||||
|
|
||||||
# redirect if already logged in
|
# redirect if already logged in
|
||||||
|
@ -133,7 +134,7 @@ class AuthenticationView(View):
|
||||||
'form': form,
|
'form': form,
|
||||||
'referrer': referrer,
|
'referrer': referrer,
|
||||||
'image_url': image_url,
|
'image_url': image_url,
|
||||||
'index_title': self.rattail_config.node_title(),
|
'index_title': app.get_node_title(),
|
||||||
'help_url': global_help_url(self.rattail_config),
|
'help_url': global_help_url(self.rattail_config),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ class CommonView(View):
|
||||||
"""
|
"""
|
||||||
Home page view.
|
Home page view.
|
||||||
"""
|
"""
|
||||||
|
app = self.get_rattail_app()
|
||||||
if not self.request.user:
|
if not self.request.user:
|
||||||
if self.rattail_config.getbool('tailbone', 'login_is_home', default=True):
|
if self.rattail_config.getbool('tailbone', 'login_is_home', default=True):
|
||||||
raise self.redirect(self.request.route_url('login'))
|
raise self.redirect(self.request.route_url('login'))
|
||||||
|
@ -60,7 +61,7 @@ class CommonView(View):
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'image_url': image_url,
|
'image_url': image_url,
|
||||||
'index_title': self.rattail_config.node_title(),
|
'index_title': app.get_node_title(),
|
||||||
'help_url': global_help_url(self.rattail_config),
|
'help_url': global_help_url(self.rattail_config),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +100,8 @@ class CommonView(View):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def get_project_title(self):
|
def get_project_title(self):
|
||||||
return self.rattail_config.app_title()
|
app = self.get_rattail_app()
|
||||||
|
return app.get_title()
|
||||||
|
|
||||||
def get_project_version(self):
|
def get_project_version(self):
|
||||||
|
|
||||||
|
@ -121,11 +123,12 @@ class CommonView(View):
|
||||||
"""
|
"""
|
||||||
Generic view to show "about project" info page.
|
Generic view to show "about project" info page.
|
||||||
"""
|
"""
|
||||||
|
app = self.get_rattail_app()
|
||||||
return {
|
return {
|
||||||
'project_title': self.get_project_title(),
|
'project_title': self.get_project_title(),
|
||||||
'project_version': self.get_project_version(),
|
'project_version': self.get_project_version(),
|
||||||
'packages': self.get_packages(),
|
'packages': self.get_packages(),
|
||||||
'index_title': self.rattail_config.node_title(),
|
'index_title': app.get_node_title(),
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_packages(self):
|
def get_packages(self):
|
||||||
|
@ -209,7 +212,7 @@ class CommonView(View):
|
||||||
raise self.forbidden()
|
raise self.forbidden()
|
||||||
|
|
||||||
app = self.get_rattail_app()
|
app = self.get_rattail_app()
|
||||||
app_title = self.rattail_config.app_title()
|
app_title = app.get_title()
|
||||||
poser_handler = app.get_poser_handler()
|
poser_handler = app.get_poser_handler()
|
||||||
poser_dir = poser_handler.get_default_poser_dir()
|
poser_dir = poser_handler.get_default_poser_dir()
|
||||||
poser_dir_exists = os.path.isdir(poser_dir)
|
poser_dir_exists = os.path.isdir(poser_dir)
|
||||||
|
|
|
@ -67,8 +67,9 @@ class AppInfoView(MasterView):
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_index_title(self):
|
def get_index_title(self):
|
||||||
|
app = self.get_rattail_app()
|
||||||
return "{} for {}".format(self.get_model_title_plural(),
|
return "{} for {}".format(self.get_model_title_plural(),
|
||||||
self.rattail_config.app_title())
|
app.get_title())
|
||||||
|
|
||||||
def get_data(self, session=None):
|
def get_data(self, session=None):
|
||||||
pip = os.path.join(sys.prefix, 'bin', 'pip')
|
pip = os.path.join(sys.prefix, 'bin', 'pip')
|
||||||
|
|
|
@ -147,10 +147,11 @@ class UpgradeView(MasterView):
|
||||||
|
|
||||||
def template_kwargs_view(self, **kwargs):
|
def template_kwargs_view(self, **kwargs):
|
||||||
kwargs = super().template_kwargs_view(**kwargs)
|
kwargs = super().template_kwargs_view(**kwargs)
|
||||||
|
app = self.get_rattail_app()
|
||||||
model = self.model
|
model = self.model
|
||||||
upgrade = kwargs['instance']
|
upgrade = kwargs['instance']
|
||||||
|
|
||||||
kwargs['system_title'] = self.rattail_config.app_title()
|
kwargs['system_title'] = app.get_title()
|
||||||
if upgrade.system:
|
if upgrade.system:
|
||||||
system = self.upgrade_handler.get_system(upgrade.system)
|
system = self.upgrade_handler.get_system(upgrade.system)
|
||||||
if system:
|
if system:
|
||||||
|
|
Loading…
Reference in a new issue