diff --git a/NorahUniversity/__pycache__/urls.cpython-313.pyc b/NorahUniversity/__pycache__/urls.cpython-313.pyc index e4ba51d..2d1e76d 100644 Binary files a/NorahUniversity/__pycache__/urls.cpython-313.pyc and b/NorahUniversity/__pycache__/urls.cpython-313.pyc differ diff --git a/NorahUniversity/urls.py b/NorahUniversity/urls.py index 5990780..10dfb34 100644 --- a/NorahUniversity/urls.py +++ b/NorahUniversity/urls.py @@ -1,11 +1,12 @@ +from recruitment import views +from django.conf import settings from django.contrib import admin from django.urls import path, include from django.conf.urls.static import static -from django.conf import settings -from django.conf.urls.i18n import i18n_patterns # Import i18n_patterns +from django.views.generic import RedirectView +from django.conf.urls.i18n import i18n_patterns from rest_framework.routers import DefaultRouter -from recruitment import views router = DefaultRouter() router.register(r'jobs', views.JobPostingViewSet) @@ -34,7 +35,6 @@ urlpatterns = [ urlpatterns += i18n_patterns( path('', include('recruitment.urls')), - ) # 2. URLs that DO have a language prefix (user-facing views) # This includes the root path (''), which is handled by 'recruitment.urls' diff --git a/recruitment/__pycache__/signals.cpython-313.pyc b/recruitment/__pycache__/signals.cpython-313.pyc index 421b199..84dce03 100644 Binary files a/recruitment/__pycache__/signals.cpython-313.pyc and b/recruitment/__pycache__/signals.cpython-313.pyc differ diff --git a/recruitment/signals.py b/recruitment/signals.py index ebc9f9b..ebba334 100644 --- a/recruitment/signals.py +++ b/recruitment/signals.py @@ -1,5 +1,8 @@ import logging from django.db import transaction +from django_q.models import Schedule +from django_q.tasks import schedule + from django.dispatch import receiver from django_q.tasks import async_task from django.db.models.signals import post_save @@ -16,7 +19,31 @@ def format_job(sender, instance, created, **kwargs): instance.pk, # hook='myapp.tasks.email_sent_callback' # Optional callback ) + else: + existing_schedule = Schedule.objects.filter( + func='recruitment.tasks.form_close', + args=f'[{instance.pk}]', + schedule_type=Schedule.ONCE + ).first() + if instance.is_active and instance.application_deadline: + if not existing_schedule: + # Create a new schedule if one does not exist + schedule( + 'recruitment.tasks.form_close', + instance.pk, + schedule_type=Schedule.ONCE, + next_run=instance.application_deadline, + repeats=-1, # Ensure the schedule is deleted after it runs + name=f'job_closing_{instance.pk}' # Add a name for easier lookup + ) + elif existing_schedule.next_run != instance.application_deadline: + # Update an existing schedule's run time + existing_schedule.next_run = instance.application_deadline + existing_schedule.save() + elif existing_schedule: + # If the instance is no longer active, delete the scheduled task + existing_schedule.delete() @receiver(post_save, sender=Candidate) def score_candidate_resume(sender, instance, created, **kwargs): diff --git a/recruitment/tasks.py b/recruitment/tasks.py index 3c3adeb..bf024e9 100644 --- a/recruitment/tasks.py +++ b/recruitment/tasks.py @@ -552,3 +552,10 @@ def linkedin_post_task(job_slug, access_token): job.linkedin_post_status = f"CRITICAL_ERROR: {str(e)}" job.save() return False + + +def form_close(job_id): + job = get_object_or_404(JobPosting, pk=job_id) + job.is_active = False + job.template_form.is_active = False + job.save() \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 0250f32..333d46d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -344,7 +344,7 @@ }); } - form_loader(); + //form_loader(); try{ document.addEventListener('htmx:afterSwap', form_loader); diff --git a/templates/forms/form_wizard.html b/templates/forms/form_wizard.html index bacb6d1..1447255 100644 --- a/templates/forms/form_wizard.html +++ b/templates/forms/form_wizard.html @@ -824,7 +824,7 @@ }); try { - const response = await fetch(`/${state.templateId}/submit/`, { + const response = await fetch(`/form/${state.templateId}/submit/`, { method: 'POST', body: formData // IMPORTANT: Do NOT set Content-Type header when using FormData diff --git a/templates/recruitment/source_form.html b/templates/recruitment/source_form.html index bf81f61..05f789a 100644 --- a/templates/recruitment/source_form.html +++ b/templates/recruitment/source_form.html @@ -297,7 +297,7 @@ window.generateRandomKey = generateRandomKey; {% endblock %} -{% block extra_js %} +{% block customJS %}