diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 3209f0b..39f3760 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/templates/core/log_attendance.html b/core/templates/core/log_attendance.html index 2b22f30..71cae69 100644 --- a/core/templates/core/log_attendance.html +++ b/core/templates/core/log_attendance.html @@ -43,7 +43,10 @@
- +
+ + Manage Resources +
{% for checkbox in form.workers %}
diff --git a/core/templates/core/manage_resources.html b/core/templates/core/manage_resources.html index 0de0a83..b79cd4c 100644 --- a/core/templates/core/manage_resources.html +++ b/core/templates/core/manage_resources.html @@ -7,10 +7,22 @@

Manage Resources

-

Toggle the active status of workers, projects, and teams. Inactive items will be hidden from selection forms.

+

Quickly toggle the active status of workers, projects, and teams. Inactive items will be hidden from selection forms.

+ +
+ +
+
-{% endblock %} + + +{% endblock %} \ No newline at end of file diff --git a/core/views.py b/core/views.py index c500732..241de5c 100644 --- a/core/views.py +++ b/core/views.py @@ -8,6 +8,7 @@ from django.db.models import Sum, Q from django.core.mail import send_mail from django.conf import settings from django.contrib import messages +from django.http import JsonResponse from .models import Worker, Project, Team, WorkLog, PayrollRecord from .forms import WorkLogForm from datetime import timedelta @@ -178,6 +179,13 @@ def toggle_resource_status(request, model_type, pk): obj.is_active = not obj.is_active obj.save() + if request.headers.get('x-requested-with') == 'XMLHttpRequest': + return JsonResponse({ + 'success': True, + 'is_active': obj.is_active, + 'message': f"{obj.name} is now {'Active' if obj.is_active else 'Inactive'}." + }) + return redirect('manage_resources') def payroll_dashboard(request): @@ -294,4 +302,4 @@ def payslip_detail(request, pk): 'record': record, 'logs': logs, } - return render(request, 'core/payslip.html', context) \ No newline at end of file + return render(request, 'core/payslip.html', context)