Add Project Files

This commit is contained in:
2022-06-20 13:41:51 +03:00
parent a5aecd6dda
commit 09e209b988
24 changed files with 388 additions and 51 deletions

27
hosts/admin.py Normal file
View File

@@ -0,0 +1,27 @@
import requests
from django.contrib import admin
from .models import Host
def toggle_check_hosts(queryset):
for item in queryset:
try:
r = requests.get(item.host_name)
if r.status_code == 200:
item.status = True
else:
item.status = False
except requests.RequestException:
item.status = False
item.save()
toggle_check_hosts.short_description = "Проверить"
@admin.register(Host)
class HostAdmin(admin.ModelAdmin):
list_display = (
"host_name", "port", "status", "status_code", "created", "updated"
)
actions = [toggle_check_hosts]