feat: implement Fil-A-Management Django MVP
This commit is contained in:
commit
1127e7ecf4
66 files changed
+3774
No files matched your search
@@ -0,0 +1,69 @@
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
from django.contrib.auth.models import Group, User
|
||||
|
||||
from .models import Color, Manufacturer, ProductType, Variant
|
||||
|
||||
admin.site.site_header = "Fil-A-Management · Administration"
|
||||
admin.site.site_title = "Fil-A-Management"
|
||||
admin.site.index_title = "Konten und gemeinsamer Katalog"
|
||||
admin.site.unregister(User)
|
||||
admin.site.unregister(Group)
|
||||
|
||||
|
||||
@admin.register(User)
|
||||
class AccountAdmin(UserAdmin):
|
||||
# Accounts only: never expose members' private profile fields here.
|
||||
fieldsets = (
|
||||
(None, {"fields": ("username", "password")}),
|
||||
("Kontostatus", {"fields": ("is_active",)}),
|
||||
)
|
||||
list_display = ("username", "is_active")
|
||||
list_filter = ("is_active",)
|
||||
search_fields = ("username",)
|
||||
ordering = ("username",)
|
||||
filter_horizontal = ()
|
||||
|
||||
def lookup_allowed(self, lookup, value, request=None):
|
||||
# Django normally permits direct filters on all local model fields.
|
||||
# Block private-profile/password inference via crafted changelist URLs.
|
||||
return lookup.split("__", 1)[0] in {
|
||||
"username",
|
||||
"is_active",
|
||||
"id",
|
||||
} and super().lookup_allowed(lookup, value, request)
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
return False # Deactivate; preserve requests, ownership and private data.
|
||||
|
||||
|
||||
@admin.register(Manufacturer, Color)
|
||||
class NamedCatalogAdmin(admin.ModelAdmin):
|
||||
search_fields = ("name",)
|
||||
|
||||
|
||||
@admin.register(ProductType)
|
||||
class ProductTypeAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "manufacturer")
|
||||
list_filter = ("manufacturer",)
|
||||
search_fields = ("name", "manufacturer__name")
|
||||
list_select_related = ("manufacturer",)
|
||||
|
||||
|
||||
@admin.register(Variant)
|
||||
class VariantAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"product_type",
|
||||
"color",
|
||||
"spool_type",
|
||||
"manufacturer_color_code",
|
||||
"net_weight_g",
|
||||
"diameter_mm",
|
||||
"is_active",
|
||||
)
|
||||
list_filter = ("is_active", "product_type__manufacturer", "product_type", "spool_type")
|
||||
search_fields = ("manufacturer_color_code", "color__name", "product_type__name")
|
||||
list_select_related = ("product_type__manufacturer", "color")
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
return False # Catalog history stays addressable: deactivate instead.
|
||||
Reference in new issue
Block a user