91 lines
3.5 KiB
Python
91 lines
3.5 KiB
Python
from django.contrib import admin
|
|
from .models import (
|
|
Product, Cart, CartItem, Order, OrderItem,
|
|
Review, UserProfile, FAQ, ContactMessage,
|
|
CustomOrder, OrderProgress, GalleryImage
|
|
)
|
|
from django.utils.safestring import mark_safe
|
|
|
|
@admin.register(Product)
|
|
class ProductAdmin(admin.ModelAdmin):
|
|
list_display = ('name', 'price', 'stock', 'fursuit_type', 'style', 'is_featured', 'is_custom_order')
|
|
list_filter = ('fursuit_type', 'style', 'is_featured', 'is_custom_order')
|
|
search_fields = ('name', 'description')
|
|
ordering = ('-created',)
|
|
|
|
@admin.register(Order)
|
|
class OrderAdmin(admin.ModelAdmin):
|
|
list_display = ('id', 'full_name', 'total_amount', 'status', 'payment_status', 'created')
|
|
list_filter = ('status', 'payment_status', 'payment_method')
|
|
search_fields = ('full_name', 'email')
|
|
ordering = ('-created',)
|
|
|
|
@admin.register(OrderItem)
|
|
class OrderItemAdmin(admin.ModelAdmin):
|
|
list_display = ('order', 'product_name', 'quantity', 'price')
|
|
search_fields = ('product_name',)
|
|
|
|
@admin.register(Review)
|
|
class ReviewAdmin(admin.ModelAdmin):
|
|
list_display = ('product', 'user', 'rating', 'created')
|
|
list_filter = ('rating',)
|
|
search_fields = ('comment', 'user__username')
|
|
|
|
@admin.register(Cart)
|
|
class CartAdmin(admin.ModelAdmin):
|
|
list_display = ('id', 'user', 'created')
|
|
search_fields = ('user__username',)
|
|
|
|
@admin.register(CartItem)
|
|
class CartItemAdmin(admin.ModelAdmin):
|
|
list_display = ('cart', 'product', 'quantity')
|
|
|
|
@admin.register(UserProfile)
|
|
class UserProfileAdmin(admin.ModelAdmin):
|
|
list_display = ('user', 'phone', 'newsletter')
|
|
list_filter = ('newsletter',)
|
|
search_fields = ('user__username', 'phone', 'address')
|
|
|
|
@admin.register(FAQ)
|
|
class FAQAdmin(admin.ModelAdmin):
|
|
list_display = ('question', 'category', 'order')
|
|
list_filter = ('category',)
|
|
search_fields = ('question', 'answer')
|
|
ordering = ('category', 'order')
|
|
|
|
@admin.register(ContactMessage)
|
|
class ContactMessageAdmin(admin.ModelAdmin):
|
|
list_display = ('subject', 'name', 'email', 'category', 'status', 'created')
|
|
list_filter = ('category', 'status')
|
|
search_fields = ('name', 'email', 'subject', 'message')
|
|
ordering = ('-created',)
|
|
|
|
@admin.register(CustomOrder)
|
|
class CustomOrderAdmin(admin.ModelAdmin):
|
|
list_display = ('character_name', 'user', 'fursuit_type', 'status', 'created')
|
|
list_filter = ('fursuit_type', 'style', 'status')
|
|
search_fields = ('character_name', 'user__username', 'character_description')
|
|
ordering = ('-created',)
|
|
|
|
@admin.register(OrderProgress)
|
|
class OrderProgressAdmin(admin.ModelAdmin):
|
|
list_display = ('custom_order', 'stage', 'completed', 'created')
|
|
list_filter = ('stage', 'completed')
|
|
search_fields = ('custom_order__character_name', 'description')
|
|
ordering = ('custom_order', 'created')
|
|
|
|
@admin.register(GalleryImage)
|
|
class GalleryImageAdmin(admin.ModelAdmin):
|
|
list_display = ('title', 'fursuit_type', 'style', 'is_featured', 'order', 'created', 'admin_image')
|
|
list_filter = ('fursuit_type', 'style', 'is_featured')
|
|
search_fields = ('title', 'description')
|
|
ordering = ('order', '-created')
|
|
list_editable = ('order', 'is_featured')
|
|
readonly_fields = ('admin_image',)
|
|
|
|
def admin_image(self, obj):
|
|
if obj.image:
|
|
return mark_safe(f'<img src="{obj.image.url}" style="max-height: 50px;" />')
|
|
return "Kein Bild"
|
|
admin_image.short_description = 'Vorschau'
|