from django.contrib import admin

from news.models import ServerMessage


class ServerMessageAdmin(admin.ModelAdmin):
    readonly_fields = [
        "modified",
        "created",
    ]
    list_display = [
        "id",
        "subject",
        "publish_on",
        "is_active",
    ]
    search_fields = [
        "subject"
    ]

    def save_model(self, request, obj, form, change):
        obj.save(user=request.user)


admin.site.register(ServerMessage, ServerMessageAdmin)

