Move "test error" button to about dialog; require perm to use
This commit is contained in:
parent
8b526af843
commit
52c35ed85c
|
@ -36,6 +36,7 @@ from traceback import format_exception
|
|||
from rattail import app as base
|
||||
from rattail.config import make_config
|
||||
from rattail.files import resource_path
|
||||
from rattail.util import simple_error
|
||||
|
||||
import flet as ft
|
||||
|
||||
|
@ -96,6 +97,7 @@ def main(page: ft.Page):
|
|||
|
||||
app.send_email('uncaught_exception', {
|
||||
'extra_context': extra_context,
|
||||
'error': simple_error(exc_value),
|
||||
'traceback': traceback,
|
||||
})
|
||||
|
||||
|
|
|
@ -133,11 +133,28 @@ You should have received a copy of the GNU General Public License along with
|
|||
WuttaPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
if self.page.session.get('user_uuid'):
|
||||
buttons = []
|
||||
|
||||
user_uuid = self.page.session.get('user_uuid')
|
||||
if user_uuid:
|
||||
|
||||
session = self.app.make_session()
|
||||
model = self.app.model
|
||||
user = session.get(model.User, user_uuid)
|
||||
auth = self.app.get_auth_handler()
|
||||
has_perm = auth.has_permission(session, user, 'pos.test_error')
|
||||
session.close()
|
||||
if has_perm:
|
||||
test_error = self.make_button("TEST ERROR", font_size=24,
|
||||
height=60,
|
||||
width=60 * 3,
|
||||
bgcolor='red',
|
||||
on_click=self.test_error_click)
|
||||
buttons.append(test_error)
|
||||
|
||||
feedback = WuttaFeedback(self.config, page=self.page,
|
||||
on_send=self.reset, on_cancel=self.reset)
|
||||
else:
|
||||
feedback = ft.Text() # no display
|
||||
buttons.append(feedback)
|
||||
|
||||
self.dlg = ft.AlertDialog(
|
||||
title=ft.Text(title),
|
||||
|
@ -150,7 +167,10 @@ WuttaPOS. If not, see <http://www.gnu.org/licenses/>.
|
|||
ft.Divider(),
|
||||
ft.Text(license),
|
||||
ft.Container(
|
||||
content=feedback,
|
||||
content=ft.Row(
|
||||
controls=buttons,
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
),
|
||||
alignment=ft.alignment.center,
|
||||
expand=True,
|
||||
),
|
||||
|
@ -180,6 +200,15 @@ WuttaPOS. If not, see <http://www.gnu.org/licenses/>.
|
|||
self.dlg.open = True
|
||||
self.page.update()
|
||||
|
||||
def test_error_click(self, e):
|
||||
|
||||
# first get the dialog out of the way
|
||||
self.dlg.open = False
|
||||
self.reset()
|
||||
self.page.update()
|
||||
|
||||
raise RuntimeError("FAKE ERROR - to test error handling")
|
||||
|
||||
def close_dlg(self, e):
|
||||
self.dlg.open = False
|
||||
self.reset()
|
||||
|
|
|
@ -667,8 +667,8 @@ class POSView(WuttaView):
|
|||
[
|
||||
meta_button("Adjust\nPrice", font_size=30, bgcolor='yellow',
|
||||
on_click=self.adjust_price_click),
|
||||
meta_button("(TEST ERROR)", bgcolor='red', on_click=self.not_supported,
|
||||
font_size=24, data={'error': True}),
|
||||
meta_button("TODO", bgcolor='yellow', on_click=self.not_supported,
|
||||
font_size=24),
|
||||
],
|
||||
spacing=0,
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue