logged errors: remove support for "acking" errors (#49626)

This commit is contained in:
Frédéric Péters 2020-12-20 14:16:21 +01:00
parent 03cee694ba
commit 1e12191ecf
4 changed files with 4 additions and 19 deletions

View File

@ -4831,10 +4831,6 @@ def test_backoffice_logged_errors(pub):
resp = resp2.click('Failed to evaluate condition')
assert 'ZeroDivisionError: integer division or modulo by zero' in resp.text
assert 'Python Expression: <code>1//0</code>' in resp.text
assert not 'Acked' in resp.text
resp = resp.click('Ack').follow()
assert 'Acked' in resp.text
assert pub.loggederror_class.select()[0].acked is True
resp = resp.click('Delete').follow()
assert pub.loggederror_class.count() == 0

View File

@ -93,19 +93,10 @@ class LoggedErrorDirectory(Directory):
def get_sidebar(self):
r = TemplateIO(html=True)
r += htmltext('<ul id="sidebar-actions">')
if not self.error.acked:
r += htmltext('<li><a href="ack">%s</a></li>') % ('Ack')
else:
r += htmltext('<li>%s</li>' % _('Acked'))
r += htmltext('<li><a href="delete">%s</a></li>') % _('Delete')
r += htmltext('</ul>')
return r.getvalue()
def ack(self):
self.error.acked = True
self.error.store()
return redirect('.')
def delete(self):
get_publisher().loggederror_class.remove_object(self.error.id)
return redirect('..')

View File

@ -42,7 +42,6 @@ class LoggedError(object):
occurences_count = 0
first_occurence_timestamp = None
latest_occurence_timestamp = None
acked = False
@classmethod
def record(cls, error_summary, plain_error_msg=None, formdata=None,

View File

@ -884,8 +884,7 @@ def do_loggederrors_table(concurrently=False):
exception_message VARCHAR,
occurences_count INTEGER,
first_occurence_timestamp TIMESTAMP WITH TIME ZONE,
latest_occurence_timestamp TIMESTAMP WITH TIME ZONE,
acked BOOLEAN
latest_occurence_timestamp TIMESTAMP WITH TIME ZONE
)''' % table_name)
cur.execute('''SELECT column_name FROM information_schema.columns
WHERE table_schema = 'public'
@ -2548,7 +2547,6 @@ class LoggedError(SqlMixin, wcs.logged_errors.LoggedError):
('occurences_count', 'integer'),
('first_occurence_timestamp', 'timestamptz'),
('latest_occurence_timestamp', 'timestamptz'),
('acked', 'boolean'),
]
_numerical_id = False
@ -2870,7 +2868,7 @@ def get_period_total(period_start=None, include_start=True, period_end=None, inc
# latest migration, number + description (description is not used
# programmaticaly but will make sure git conflicts if two migrations are
# separately added with the same number)
SQL_LEVEL = (47, 'use SQL to store LoggedError')
SQL_LEVEL = (48, 'remove acked attribute from LoggedError')
def migrate_global_views(conn, cur):
@ -3025,8 +3023,9 @@ def migrate():
if sql_level < 42:
# 42: create snapshots table
do_snapshots_table()
if sql_level < 47:
if sql_level < 48:
# 47: store LoggedErrors in SQL
# 48: remove acked attribute from LoggedError
do_loggederrors_table()
cur.execute('''UPDATE wcs_meta SET value = %s WHERE key = %s''', (