diff --git a/bookwyrm/emailing.py b/bookwyrm/emailing.py index e767d5374..80aacf7f4 100644 --- a/bookwyrm/emailing.py +++ b/bookwyrm/emailing.py @@ -48,6 +48,7 @@ def moderation_report_email(report): if report.user: data["reportee"] = report.user.localname or report.user.username data["report_link"] = report.remote_id + data["link_domain"] = report.links.exists() for admin in models.User.objects.filter( groups__name__in=["admin", "moderator"] diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index de898609f..1f9cd87ed 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -147,6 +147,9 @@ LOGGING = { "require_debug_true": { "()": "django.utils.log.RequireDebugTrue", }, + "ignore_missing_variable": { + "()": "bookwyrm.utils.log.IgnoreVariableDoesNotExist", + }, }, "handlers": { # Overrides the default handler to make it log to console @@ -154,6 +157,7 @@ LOGGING = { # console if DEBUG=False) "console": { "level": LOG_LEVEL, + "filters": ["ignore_missing_variable"], "class": "logging.StreamHandler", }, # This is copied as-is from the default logger, and is diff --git a/bookwyrm/templates/email/moderation_report/html_content.html b/bookwyrm/templates/email/moderation_report/html_content.html index 3828ff70c..0e604ebf8 100644 --- a/bookwyrm/templates/email/moderation_report/html_content.html +++ b/bookwyrm/templates/email/moderation_report/html_content.html @@ -3,7 +3,7 @@ {% block content %}

-{% if report_link %} +{% if link_domain %} {% blocktrans trimmed %} @{{ reporter }} has flagged a link domain for moderation. diff --git a/bookwyrm/templates/email/moderation_report/text_content.html b/bookwyrm/templates/email/moderation_report/text_content.html index 764a3c72a..351ab58ed 100644 --- a/bookwyrm/templates/email/moderation_report/text_content.html +++ b/bookwyrm/templates/email/moderation_report/text_content.html @@ -2,7 +2,7 @@ {% load i18n %} {% block content %} -{% if report_link %} +{% if link_domain %} {% blocktrans trimmed %} @{{ reporter }} has flagged a link domain for moderation. {% endblocktrans %} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 7af123016..a1e0ef844 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -297,7 +297,7 @@ urlpatterns = [ name="settings-imports", ), re_path( - r"^settings/imports/(?P\d+)/complete?$", + r"^settings/imports/(?P\d+)/complete/?$", views.ImportList.as_view(), name="settings-imports-complete", ), diff --git a/bookwyrm/utils/log.py b/bookwyrm/utils/log.py new file mode 100644 index 000000000..70f32ef03 --- /dev/null +++ b/bookwyrm/utils/log.py @@ -0,0 +1,20 @@ +""" Logging utilities """ +import logging + + +class IgnoreVariableDoesNotExist(logging.Filter): + """ + Filter to ignore VariableDoesNotExist errors + + We intentionally pass nonexistent variables to templates a lot, so + these errors are not useful to us. + """ + + def filter(self, record): + if record.exc_info: + (_, err_value, _) = record.exc_info + while err_value: + if type(err_value).__name__ == "VariableDoesNotExist": + return False + err_value = err_value.__context__ + return True