42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from django.contrib import admin
|
|
from .models import Favorite, FavoriteTag, FavoriteTagMapping, PriceMonitor, PriceHistory
|
|
|
|
|
|
@admin.register(Favorite)
|
|
class FavoriteAdmin(admin.ModelAdmin):
|
|
list_display = ['id', 'user', 'product', 'website', 'created_at']
|
|
list_filter = ['website']
|
|
search_fields = ['user__name', 'product__name']
|
|
ordering = ['-created_at']
|
|
raw_id_fields = ['user', 'product', 'website']
|
|
|
|
|
|
@admin.register(FavoriteTag)
|
|
class FavoriteTagAdmin(admin.ModelAdmin):
|
|
list_display = ['id', 'user', 'name', 'color', 'created_at']
|
|
search_fields = ['name', 'user__name']
|
|
ordering = ['-created_at']
|
|
raw_id_fields = ['user']
|
|
|
|
|
|
@admin.register(FavoriteTagMapping)
|
|
class FavoriteTagMappingAdmin(admin.ModelAdmin):
|
|
list_display = ['id', 'favorite', 'tag', 'created_at']
|
|
ordering = ['-created_at']
|
|
raw_id_fields = ['favorite', 'tag']
|
|
|
|
|
|
@admin.register(PriceMonitor)
|
|
class PriceMonitorAdmin(admin.ModelAdmin):
|
|
list_display = ['id', 'favorite', 'user', 'current_price', 'target_price', 'is_active', 'updated_at']
|
|
list_filter = ['is_active']
|
|
ordering = ['-updated_at']
|
|
raw_id_fields = ['favorite', 'user']
|
|
|
|
|
|
@admin.register(PriceHistory)
|
|
class PriceHistoryAdmin(admin.ModelAdmin):
|
|
list_display = ['id', 'monitor', 'price', 'price_change', 'percent_change', 'recorded_at']
|
|
ordering = ['-recorded_at']
|
|
raw_id_fields = ['monitor']
|