mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 20:40:17 +02:00
Forgot pre-commit for master > 2.9.x
This commit is contained in:
parent
392a0c4dcb
commit
dc97fb1cc5
@ -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):
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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
|
||||
===========
|
||||
|
Loading…
x
Reference in New Issue
Block a user