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>
This commit is contained in:
parent
19c1798f90
commit
b382eb857b
8 changed files with 134 additions and 12 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Artifact, Asset, UserProfile
|
||||
from .models import ApiKey, Artifact, Asset, TagColor, UserProfile
|
||||
|
||||
|
||||
@admin.register(Artifact)
|
||||
|
|
@ -21,3 +21,18 @@ 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",)
|
||||
|
|
|
|||
0
artifacts/templatetags/__init__.py
Normal file
0
artifacts/templatetags/__init__.py
Normal file
30
artifacts/templatetags/daybook_extras.py
Normal file
30
artifacts/templatetags/daybook_extras.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
# A small fixed palette. A user's avatar color is picked deterministically from
|
||||
# their username, so it stays stable across sessions and page loads.
|
||||
_AVATAR_COLORS = [
|
||||
"#4a6ea8",
|
||||
"#3f8f7b",
|
||||
"#a3712a",
|
||||
"#8a4f9e",
|
||||
"#a3312a",
|
||||
"#2f7d95",
|
||||
"#6b7280",
|
||||
"#7b6a3f",
|
||||
]
|
||||
|
||||
|
||||
@register.filter
|
||||
def avatar_color(value):
|
||||
text = str(value or "")
|
||||
if not text:
|
||||
return _AVATAR_COLORS[0]
|
||||
return _AVATAR_COLORS[sum(ord(c) for c in text) % len(_AVATAR_COLORS)]
|
||||
|
||||
|
||||
@register.filter
|
||||
def avatar_initial(value):
|
||||
text = str(value or "").strip()
|
||||
return text[0].upper() if text else "?"
|
||||
Loading…
Add table
Add a link
Reference in a new issue