Bot functionsa mainly operational
This commit is contained in:
@@ -1,12 +1,23 @@
|
||||
from django.contrib import admin
|
||||
from .models import Hotel, UserHotel
|
||||
from .models import Hotel, UserHotel, APIConfiguration, APIRequestLog, PMSConfiguration, PMSIntegrationLog
|
||||
from django import forms
|
||||
class HotelForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Hotel
|
||||
fields = "__all__"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# Исключаем API, которые уже связаны с другими отелями
|
||||
used_apis = Hotel.objects.exclude(api__isnull=True).values_list('api', flat=True)
|
||||
self.fields['api'].queryset = APIConfiguration.objects.exclude(id__in=used_apis)
|
||||
|
||||
@admin.register(Hotel)
|
||||
class HotelAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'pms_type', 'created_at')
|
||||
form = HotelForm
|
||||
list_display = ('name', 'api', 'created_at', 'pms')
|
||||
search_fields = ('name',)
|
||||
list_filter = ('pms_type',)
|
||||
ordering = ('-created_at',)
|
||||
|
||||
admin.site.register(Hotel, HotelAdmin)
|
||||
|
||||
@admin.register(UserHotel)
|
||||
class UserHotelAdmin(admin.ModelAdmin):
|
||||
@@ -14,4 +25,32 @@ class UserHotelAdmin(admin.ModelAdmin):
|
||||
search_fields = ('user', 'hotel')
|
||||
list_filter = ('hotel',)
|
||||
ordering = ('-hotel',)
|
||||
|
||||
|
||||
|
||||
@admin.register(APIConfiguration)
|
||||
class ApiConfigurationAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'url', 'token', 'username', 'password')
|
||||
search_fields = ('name', 'url', 'token', 'username', 'password')
|
||||
list_filter = ('name', 'url', 'token', 'username', 'password')
|
||||
ordering = ('-name',)
|
||||
|
||||
@admin.register(APIRequestLog)
|
||||
class ApiRequestLogAdmin(admin.ModelAdmin):
|
||||
list_display = ('api', 'request_time', 'response_status', 'response_data')
|
||||
search_fields = ('api', 'request_time', 'response_status', 'response_data')
|
||||
list_filter = ('api', 'request_time', 'response_status', 'response_data')
|
||||
ordering = ('-api',)
|
||||
|
||||
|
||||
@admin.register(PMSConfiguration)
|
||||
class PMSConfigurationAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'parser_settings', 'description')
|
||||
|
||||
@admin.register(PMSIntegrationLog)
|
||||
class PMSIntegreationLogAdmin(admin.ModelAdmin):
|
||||
list_display = ('hotel', 'checked_at', 'status', 'message')
|
||||
search_fields = ('hotel', 'checked_at', 'status', 'message')
|
||||
list_filter = ('hotel', 'checked_at', 'status', 'message')
|
||||
ordering = ('-checked_at',)
|
||||
|
||||
Reference in New Issue
Block a user