Skip to content

Commit

Permalink
Use admin.register decorators.
Browse files Browse the repository at this point in the history
  • Loading branch information
scragly committed Sep 18, 2020
1 parent 2029cf5 commit 4ad759c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pydis_site/apps/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)


@admin.register(LogEntry)
class LogEntryAdmin(admin.ModelAdmin):
"""Allows viewing logs in the Django Admin without allowing edits."""

Expand Down Expand Up @@ -53,6 +54,7 @@ def has_delete_permission(self, request: HttpRequest, obj: Optional[LogEntry] =
return False


@admin.register(DeletedMessage)
class DeletedMessageAdmin(admin.ModelAdmin):
"""Admin formatting for the DeletedMessage model."""

Expand Down Expand Up @@ -109,6 +111,7 @@ def view_full_log(instance: DeletedMessage) -> str:
)


@admin.register(MessageDeletionContext)
class MessageDeletionContextAdmin(admin.ModelAdmin):
"""Admin formatting for the MessageDeletionContext model."""

Expand All @@ -123,6 +126,7 @@ def message_log(instance: MessageDeletionContext) -> str:
)


@admin.register(Infraction)
class InfractionAdmin(admin.ModelAdmin):
"""Admin formatting for the Infraction model."""

Expand Down Expand Up @@ -167,6 +171,7 @@ class InfractionAdmin(admin.ModelAdmin):
)


@admin.register(Nomination)
class NominationAdmin(admin.ModelAdmin):
"""Admin formatting for the Nomination model."""

Expand Down Expand Up @@ -204,12 +209,14 @@ class NominationAdmin(admin.ModelAdmin):
list_filter = ("active",)


@admin.register(OffTopicChannelName)
class OffTopicChannelNameAdmin(admin.ModelAdmin):
"""Admin formatting for the OffTopicChannelName model."""

search_fields = ("name",)


@admin.register(Role)
class RoleAdmin(admin.ModelAdmin):
"""Admin formatting for the Role model."""

Expand Down Expand Up @@ -266,6 +273,7 @@ def queryset(self, request: HttpRequest, queryset: QuerySet) -> Optional[QuerySe
return queryset.filter(roles__name=value)


@admin.register(User)
class UserAdmin(admin.ModelAdmin):
"""Admin formatting for the User model."""

Expand All @@ -283,13 +291,5 @@ class UserAdmin(admin.ModelAdmin):


admin.site.register(BotSetting)
admin.site.register(DeletedMessage, DeletedMessageAdmin)
admin.site.register(DocumentationLink)
admin.site.register(Infraction, InfractionAdmin)
admin.site.register(LogEntry, LogEntryAdmin)
admin.site.register(MessageDeletionContext, MessageDeletionContextAdmin)
admin.site.register(Nomination, NominationAdmin)
admin.site.register(OffensiveMessage)
admin.site.register(OffTopicChannelName, OffTopicChannelNameAdmin)
admin.site.register(Role, RoleAdmin)
admin.site.register(User, UserAdmin)

0 comments on commit 4ad759c

Please sign in to comment.