From dc97fb1cc5ef21e4290d0ce762e4736e4d547127 Mon Sep 17 00:00:00 2001 From: Joel Falknau Date: Fri, 20 Aug 2021 14:50:44 +1000 Subject: [PATCH] Forgot pre-commit for master > 2.9.x --- allianceauth/notifications/admin.py | 10 +++--- .../notifications/tests/test_handlers.py | 34 +++++++++---------- .../tech_docu/api/notifications.rst | 4 +-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/allianceauth/notifications/admin.py b/allianceauth/notifications/admin.py index 89d22e78..03f1dd4e 100644 --- a/allianceauth/notifications/admin.py +++ b/allianceauth/notifications/admin.py @@ -3,11 +3,11 @@ from .models import Notification @admin.register(Notification) -class NotificationAdmin(admin.ModelAdmin): +class NotificationAdmin(admin.ModelAdmin): list_display = ("timestamp", "_main", "_state", "title", "level", "viewed") list_select_related = ("user", "user__profile__main_character", "user__profile__state") - list_filter = ( - "level", + list_filter = ( + "level", "timestamp", "user__profile__state", ('user__profile__main_character', admin.RelatedOnlyFieldListFilter), @@ -20,12 +20,12 @@ class NotificationAdmin(admin.ModelAdmin): return obj.user.profile.main_character except AttributeError: return obj.user - + _main.admin_order_field = "user__profile__main_character__character_name" def _state(self, obj): return obj.user.profile.state - + _state.admin_order_field = "user__profile__state__name" def has_change_permission(self, request, obj=None): diff --git a/allianceauth/notifications/tests/test_handlers.py b/allianceauth/notifications/tests/test_handlers.py index 2bc04fb2..f90a4726 100644 --- a/allianceauth/notifications/tests/test_handlers.py +++ b/allianceauth/notifications/tests/test_handlers.py @@ -10,18 +10,18 @@ from ..models import Notification MODULE_PATH = 'allianceauth.notifications.handlers' -class TestHandler(TestCase): +class TestHandler(TestCase): def test_do_nothing_if_permission_does_not_exist(self): # given Permission.objects.get(codename="logging_notifications").delete() handler = NotificationHandler() record = LogRecord( - name="name", - level=DEBUG, - pathname="pathname", - lineno=42, - msg="msg", - args=[], + name="name", + level=DEBUG, + pathname="pathname", + lineno=42, + msg="msg", + args=[], exc_info=None, func="func" ) @@ -29,28 +29,28 @@ class TestHandler(TestCase): handler.emit(record) # then self.assertEqual(Notification.objects.count(), 0) - + def test_should_emit_message_to_users_with_permission_only(self): # given AuthUtils.create_user('Lex Luthor') - user_permission = AuthUtils.create_user('Bruce Wayne') + user_permission = AuthUtils.create_user('Bruce Wayne') user_permission = AuthUtils.add_permission_to_user_by_name( "auth.logging_notifications", user_permission ) group = Group.objects.create(name="Dummy Group") perm = Permission.objects.get(codename="logging_notifications") - group.permissions.add(perm) + group.permissions.add(perm) user_group = AuthUtils.create_user('Peter Parker') - user_group.groups.add(group) + user_group.groups.add(group) user_superuser = User.objects.create_superuser("Clark Kent") handler = NotificationHandler() record = LogRecord( - name="name", - level=DEBUG, - pathname="pathname", - lineno=42, - msg="msg", - args=[], + name="name", + level=DEBUG, + pathname="pathname", + lineno=42, + msg="msg", + args=[], exc_info=None, func="func" ) diff --git a/docs/development/tech_docu/api/notifications.rst b/docs/development/tech_docu/api/notifications.rst index 0814739f..be324576 100644 --- a/docs/development/tech_docu/api/notifications.rst +++ b/docs/development/tech_docu/api/notifications.rst @@ -7,13 +7,13 @@ The notifications package has an API for sending notifications. Location: ``allianceauth.notifications`` .. automodule:: allianceauth.notifications.__init__ - :members: notify + :members: notify models =========== .. autoclass:: allianceauth.notifications.models.Notification - :members: Level, mark_viewed, set_level + :members: Level, mark_viewed, set_level managers ===========