This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import psycopg2
|
import psycopg2
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from django.views.decorators.http import require_POST
|
||||||
from kubernetes_connection import apps as kubernetes_connection
|
from kubernetes_connection import apps as kubernetes_connection
|
||||||
import datetime
|
import datetime
|
||||||
from cloudmanager import credentials
|
from cloudmanager import credentials
|
||||||
@@ -13,6 +14,25 @@ def DB_generation(host_in,port_in,user_in,password_in,db_in):
|
|||||||
db = psycopg2.connect(host=host_in, port=port_in, user=user_in, password=password_in,database=db_in)
|
db = psycopg2.connect(host=host_in, port=port_in, user=user_in, password=password_in,database=db_in)
|
||||||
return db
|
return db
|
||||||
|
|
||||||
|
@require_POST
|
||||||
|
def change_schedule(request):
|
||||||
|
# HTMX sends these via standard POST data
|
||||||
|
schedule_id = request.POST.get('schedule_id')
|
||||||
|
server_name = request.POST.get('server_name')
|
||||||
|
|
||||||
|
if not schedule_id or not server_name:
|
||||||
|
return HttpResponse("<span style='color: red;'>Missing parameters.</span>", status=400)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# --- Your Core Logic Here ---
|
||||||
|
# e.g., Server.objects.filter(name=server_name).update(schedule_id=schedule_id)
|
||||||
|
print(f"Updating {server_name} to schedule profile {schedule_id}")
|
||||||
|
|
||||||
|
# Return a success message that will instantly inject into the server's status div
|
||||||
|
return HttpResponse("<span style='color: green;'>✓ Updated successfully!</span>")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return HttpResponse(f"<span style='color: red;'>Error: {str(e)}</span>", status=500)
|
||||||
|
|
||||||
def Launch_sql_query(sql,db):
|
def Launch_sql_query(sql,db):
|
||||||
# prepare a cursor object using cursor() method
|
# prepare a cursor object using cursor() method
|
||||||
|
|||||||
Reference in New Issue
Block a user