diff --git a/NorahUniversity/settings.py b/NorahUniversity/settings.py index 66bd7bb..4f3df89 100644 --- a/NorahUniversity/settings.py +++ b/NorahUniversity/settings.py @@ -62,7 +62,7 @@ INSTALLED_APPS = [ "django_q", "widget_tweaks", "easyaudit", - "mathfilters" + ] diff --git a/recruitment/forms.py b/recruitment/forms.py index 4340ba3..a28b552 100644 --- a/recruitment/forms.py +++ b/recruitment/forms.py @@ -1679,6 +1679,7 @@ class CandidateEmailForm(forms.Form): email_addresses = [] candidates=self.cleaned_data.get('to',[]) + print(f"candidates are {candidates}") if candidates: for candidate in candidates: diff --git a/recruitment/views.py b/recruitment/views.py index 7a42f3a..31bad6f 100644 --- a/recruitment/views.py +++ b/recruitment/views.py @@ -1246,8 +1246,7 @@ def delete_form_template(request, template_id): ) -@login_required -@staff_or_candidate_required + def application_submit_form(request, template_slug): """Display the form as a step-by-step wizard""" if not request.user.is_authenticated: @@ -4813,7 +4812,7 @@ def message_detail(request, message_id): "message": message, } if request.user.user_type != "staff": - return render(request, "messages/candidate_message_detail.html", context) + return render(request, "messages/application_message_detail.html", context) return render(request, "messages/message_detail.html", context) @@ -4832,13 +4831,13 @@ def message_create(request): if message.recipient and message.recipient.email: if request.user.user_type != "staff": - message=message.content + body=message.content else: - message=message.content.append(f"\n\n Sent by: {request.user.get_full_name()} ({request.user.email})") + body=message.content+f"\n\n Sent by: {request.user.get_full_name()} ({request.user.email})" try: email_result = async_task('recruitment.tasks._task_send_individual_email', subject=message.subject, - body_message=message, + body_message=body, recipient=message.recipient.email, attachments=None, sender=False, @@ -5665,7 +5664,7 @@ def compose_application_email(request, job_slug): candidate_ids=request.GET.getlist('candidate_ids') candidates=Application.objects.filter(id__in=candidate_ids) - + if request.method == 'POST': candidate_ids = request.POST.getlist('candidate_ids') @@ -5673,6 +5672,8 @@ def compose_application_email(request, job_slug): applications=Application.objects.filter(id__in=candidate_ids) form = CandidateEmailForm(job, applications, request.POST) + + if form.is_valid(): print("form is valid ...") # Get email addresses @@ -5695,7 +5696,7 @@ def compose_application_email(request, job_slug): subject = form.cleaned_data.get('subject') # Send emails using email service (no attachments, synchronous to avoid pickle issues) - + print(email_addresses) email_result = send_bulk_email( # subject=subject, message=message, @@ -5786,7 +5787,7 @@ def compose_application_email(request, job_slug): else: # GET request - show the form - form = CandidateEmailForm(job, candidates,request) + form = CandidateEmailForm(job, candidates) return render( request, @@ -5996,11 +5997,11 @@ def application_signup(request, slug): # gpa = form.cleaned_data["gpa"] password = form.cleaned_data["password"] gpa=form.cleaned_data["gpa"] - natiional_id=form.cleaned_data["national_id"] + national_id=form.cleaned_data["national_id"] user = User.objects.create_user( username = email,email=email,first_name=first_name,last_name=last_name,phone=phone,user_type="candidate", - gpa=gpa,natiional_id=natiional_id + ) user.set_password(password) user.save() @@ -6011,7 +6012,8 @@ def application_signup(request, slug): phone=phone, gender=gender, nationality=nationality, - # gpa=gpa, + gpa=gpa, + national_id=national_id, address=address, user = user ) diff --git a/templates/includes/email_compose_form.html b/templates/includes/email_compose_form.html index 4d6f482..61b2b5d 100644 --- a/templates/includes/email_compose_form.html +++ b/templates/includes/email_compose_form.html @@ -27,23 +27,45 @@ {% csrf_token %} -
+
+ + {# --- 1. DATA LAYER: Render Hidden Inputs for ALL recipients --- #} + {# This ensures the backend receives every selected user, not just the visible one #} + {% for choice in form.to %} + + {% endfor %} + + {# --- 2. VISUAL LAYER: Show only the first one --- #} + {# We make it disabled so the user knows they can't deselect it here #} {% for choice in form.to|slice:":1" %}
- {{ choice }} + +
{% endfor %} - {% if form.to|length > 0 %} + + {# --- 3. SUMMARY: Show count of hidden recipients --- #} + {% if form.to|length > 1 %}
- {% blocktrans count total=form.to|length %}{{ total }} recipient selected{% plural %}{{ total }} recipients selected{% endblocktrans %} + {# Use simple math to show remaining count #} + {% with remaining=form.to|length|add:"-1" %} + {% blocktrans count total=remaining %} + And {{ total }} other recipient + {% plural %} + And {{ total }} other recipients + {% endblocktrans %} + {% endwith %}
{% endif %}
+ {% if form.to.errors %}
{% for error in form.to.errors %} @@ -53,7 +75,6 @@ {% endif %}
-