Удалена система лояльности из модели Customer
Удалены поля loyalty_tier, is_vip, get_loyalty_discount(), increment_total_spent(). Поле total_spent оставлено для будущего расчёта по заказам. Обновлены admin, forms, views и шаблоны. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,24 +3,6 @@ from django.db import models
|
||||
from .models import Customer
|
||||
|
||||
|
||||
class IsVipFilter(admin.SimpleListFilter):
|
||||
title = 'VIP статус'
|
||||
parameter_name = 'is_vip'
|
||||
|
||||
def lookups(self, request, model_admin):
|
||||
return (
|
||||
('yes', 'VIP'),
|
||||
('no', 'Не VIP'),
|
||||
)
|
||||
|
||||
def queryset(self, request, queryset):
|
||||
if self.value() == 'yes':
|
||||
return queryset.filter(loyalty_tier__in=['gold', 'platinum'])
|
||||
if self.value() == 'no':
|
||||
return queryset.exclude(loyalty_tier__in=['gold', 'platinum'])
|
||||
return queryset
|
||||
|
||||
|
||||
class IsSystemCustomerFilter(admin.SimpleListFilter):
|
||||
title = 'Системный клиент'
|
||||
parameter_name = 'is_system_customer'
|
||||
@@ -46,15 +28,11 @@ class CustomerAdmin(admin.ModelAdmin):
|
||||
'full_name',
|
||||
'email',
|
||||
'phone',
|
||||
'loyalty_tier',
|
||||
'total_spent',
|
||||
'is_vip',
|
||||
'is_system_customer',
|
||||
'created_at'
|
||||
)
|
||||
list_filter = (
|
||||
'loyalty_tier',
|
||||
IsVipFilter,
|
||||
IsSystemCustomerFilter,
|
||||
'created_at'
|
||||
)
|
||||
@@ -65,14 +43,14 @@ class CustomerAdmin(admin.ModelAdmin):
|
||||
)
|
||||
date_hierarchy = 'created_at'
|
||||
ordering = ('-created_at',)
|
||||
readonly_fields = ('created_at', 'updated_at', 'total_spent', 'is_vip', 'is_system_customer')
|
||||
readonly_fields = ('created_at', 'updated_at', 'total_spent', 'is_system_customer')
|
||||
|
||||
fieldsets = (
|
||||
('Основная информация', {
|
||||
'fields': ('name', 'email', 'phone', 'is_system_customer')
|
||||
}),
|
||||
('Программа лояльности', {
|
||||
'fields': ('loyalty_tier', 'total_spent', 'is_vip'),
|
||||
('Статистика покупок', {
|
||||
'fields': ('total_spent',),
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
('Заметки', {
|
||||
@@ -88,7 +66,7 @@ class CustomerAdmin(admin.ModelAdmin):
|
||||
"""Делаем все поля read-only для системного клиента"""
|
||||
if obj and obj.is_system_customer:
|
||||
# Для системного клиента все поля только для чтения
|
||||
return ['name', 'email', 'phone', 'loyalty_tier', 'total_spent', 'is_vip', 'is_system_customer', 'notes', 'created_at', 'updated_at']
|
||||
return ['name', 'email', 'phone', 'total_spent', 'is_system_customer', 'notes', 'created_at', 'updated_at']
|
||||
return self.readonly_fields
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
|
||||
Reference in New Issue
Block a user