synclog finshed

RealtyCalendar import finished (bugfixing remains)
This commit is contained in:
2024-12-24 21:34:56 +09:00
parent 12e99ca5c2
commit 4a82b39146
4 changed files with 124 additions and 183 deletions

View File

@@ -112,7 +112,7 @@ class ExternalDBSettingsAdmin(admin.ModelAdmin):
@admin.register(UserActivityLog)
class UserActivityLogAdmin(admin.ModelAdmin):
list_display = ("id", 'get_location',"formatted_timestamp", "date_time", "page_id", "url_parameters", "page_url" ,"created", "page_title", "type", "hits")
search_fields = ("page_title", "url_parameters")
search_fields = ("page_title", "url_parameters", "page_title")
list_filter = ("page_title", "created")
readonly_fields = ("created", "timestamp")
@@ -204,16 +204,30 @@ class UserActivityLogAdmin(admin.ModelAdmin):
@admin.register(SyncLog)
class SyncLogAdmin(admin.ModelAdmin):
change_list_template = "antifroud/admin/sync_log.html"
list_display =['id', 'hotel', 'created', 'recieved_records', 'processed_records']
search_fields = ['id', 'hotel', 'created', 'recieved_records', 'processed_records']
list_filter = ['id', 'hotel', 'created', 'recieved_records', 'processed_records']
change_list_template = "antifroud/admin/sync_log.html" # Путь к вашему кастомному шаблону
list_display = ['id', 'hotel', 'created', 'recieved_records', 'processed_records']
search_fields = ['id', 'hotel__name', 'recieved_records', 'processed_records']
list_filter = ['hotel', 'created']
class Meta:
model = SyncLog
fields = ['hotel', 'recieved_records', 'processed_records']
def changelist_view(self, request, extra_context=None):
"""
Добавляет фильтрацию по отелям в шаблон.
"""
extra_context = extra_context or {}
# Получаем выбранный фильтр отеля из GET-параметров
hotel_id = request.GET.get('hotel')
hotels = Hotel.objects.all()
sync_logs = SyncLog.objects.all()
if hotel_id:
sync_logs = sync_logs.filter(hotel_id=hotel_id)
extra_context['sync_logs'] = sync_logs
extra_context['hotels'] = hotels
extra_context['selected_hotel'] = hotel_id # Чтобы отобразить выбранный отель
return super().changelist_view(request, extra_context=extra_context)
@admin.register(ViolationLog)
class ViolationLogAdmin(admin.ModelAdmin):
list_display = ['id', 'hotel', 'room_number' , 'hits', 'created_at', 'violation_type', 'violation_details', 'detected_at']