daybook/artifacts/admin.py
peter b382eb857b v0.2.1: top-bar avatar, You/Admin settings groups, admin models
- Replace the gear/username button with a round initials avatar (per-user
  deterministic color via a new daybook_extras template filter); dropdown
  now shows the username and keeps Settings/About/theme/logout. Sets up an
  optional profile photo later.
- Regroup the settings nav into "You" (Account, API Keys, Storage, Demo
  Data) and a superuser-only "Admin" (Users), About separate — the split
  now reflects who each setting affects, not a flat list.
- Register ApiKey (key read-only) and TagColor in Django admin so /admin/
  is complete as the operator break-glass tool, distinct from the themed
  Settings product surface.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-04 11:33:23 +01:00

38 lines
1.3 KiB
Python

from django.contrib import admin
from .models import ApiKey, Artifact, Asset, TagColor, UserProfile
@admin.register(Artifact)
class ArtifactAdmin(admin.ModelAdmin):
list_display = ("id", "title", "owner", "source", "kind", "is_kept", "size_bytes", "day", "created_at")
list_filter = ("owner", "source", "source_type", "kind", "is_kept", "day")
search_fields = ("id", "title", "source", "source_name", "source_id")
@admin.register(UserProfile)
class UserProfileAdmin(admin.ModelAdmin):
list_display = ("user", "quota_bytes")
search_fields = ("user__username",)
@admin.register(Asset)
class AssetAdmin(admin.ModelAdmin):
list_display = ("id", "owner", "artifact", "content_type", "size_bytes", "created_at")
list_filter = ("owner", "content_type")
search_fields = ("id",)
@admin.register(ApiKey)
class ApiKeyAdmin(admin.ModelAdmin):
list_display = ("name", "user", "key", "created_at", "last_used_at")
list_filter = ("user",)
search_fields = ("name", "key", "user__username")
# The key value and timestamps are system-managed; show but don't hand-edit.
readonly_fields = ("key", "created_at", "last_used_at")
@admin.register(TagColor)
class TagColorAdmin(admin.ModelAdmin):
list_display = ("name", "color")
search_fields = ("name",)