work on databse model
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s

This commit is contained in:
pierre geeraert
2026-06-11 22:12:00 +01:00
parent 883e028cae
commit d3061eddaf
22 changed files with 275 additions and 43 deletions
+18 -27
View File
@@ -1,33 +1,24 @@
from django.http import HttpResponse
from django.views.decorators.http import require_POST
#from django.contrib.auth.decorators import login_required # optional but recommended
def trigger_my_action(request):
# 1. Run your Django module/function
result = "1"
print('here')
# 2. Return ONLY the HTML fragment you want to show on the page
# This will replace the content inside the "hx-target" div
return HttpResponse("Done!")
# IMPORT AT THE TOP HERE: This is completely safe!
from apps.cloudmanager.models import CmmData
def coucou(request):
# 1. Prepare the data inside the function
data = CmmData(
name="test",
namespace="testspace",
schedule_hour="1",
schedule_day="deux",
replicas=3
)
#@login_required
@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')
# 2. This line actually pushes the data into your cloudmanager_db!
data.save()
if not schedule_id or not server_name:
return HttpResponse("<span style='color: red;'>Missing parameters.</span>", status=400)
return HttpResponse('<h1>Hello cmm! Data saved successfully!</h1>')
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 display(request):
data = CmmData.objects.all()
print(data[0].namespace)
return HttpResponse(data)