geoip intgration
This commit is contained in:
@@ -10,7 +10,7 @@ from hotels.models import Hotel, Room
|
||||
import pymysql
|
||||
import logging
|
||||
from django.urls import reverse
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -111,10 +111,19 @@ class ExternalDBSettingsAdmin(admin.ModelAdmin):
|
||||
|
||||
@admin.register(UserActivityLog)
|
||||
class UserActivityLogAdmin(admin.ModelAdmin):
|
||||
list_display = ("id", "timestamp", "date_time", "page_id", "url_parameters", "page_url" ,"created", "page_title", "type", "hits")
|
||||
list_display = ("id", "ip", 'get_location',"formatted_timestamp", "date_time", "page_id", "url_parameters", "page_url" ,"created", "page_title", "type", "hits")
|
||||
search_fields = ("page_title", "url_parameters")
|
||||
list_filter = ("page_title", "created")
|
||||
readonly_fields = ("created", "timestamp")
|
||||
|
||||
def get_formatted_timestamp(self, obj):
|
||||
"""
|
||||
Метод для админки для преобразования timestamp в читаемый формат.
|
||||
"""
|
||||
return obj.formatted_timestamp # Используем свойство модели
|
||||
get_formatted_timestamp.short_description = "Таймштамп"
|
||||
|
||||
|
||||
def get_hotel_name(self):
|
||||
"""
|
||||
Возвращает название отеля на основе связанного page_id.
|
||||
@@ -142,7 +151,6 @@ class UserActivityLogAdmin(admin.ModelAdmin):
|
||||
get_hotel_name.short_description = "Отель"
|
||||
get_room_number.short_description = "Комната"
|
||||
|
||||
|
||||
from .views import import_selected_hotels
|
||||
# Регистрируем admin класс для ImportedHotel
|
||||
@admin.register(ImportedHotel)
|
||||
@@ -197,13 +205,13 @@ class ImportedHotelAdmin(admin.ModelAdmin):
|
||||
@admin.register(SyncLog)
|
||||
class SyncLogAdmin(admin.ModelAdmin):
|
||||
change_list_template = "antifroud/admin/sync_log.html"
|
||||
list_display =['id', 'hotel', 'recieved_records', 'processed_records']
|
||||
search_fields = ['id', 'hotel', 'received_records', 'processed_records']
|
||||
list_filter = ['id', 'hotel', 'processed_records']
|
||||
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']
|
||||
|
||||
class Meta:
|
||||
model = SyncLog
|
||||
fields = ['hotel', 'received_records', 'processed_records']
|
||||
fields = ['hotel', 'recieved_records', 'processed_records']
|
||||
|
||||
|
||||
@admin.register(ViolationLog)
|
||||
|
||||
Reference in New Issue
Block a user