From 50259b57df0f93fb06120050a309b25e59886abf Mon Sep 17 00:00:00 2001 From: Deepawali Date: Mon, 6 Oct 2025 18:09:34 +0530 Subject: [PATCH] add button of resume to add candidate --- candidates/forms.py | 17 +++++ candidates/models.py | 4 +- .../templates/candidate_registration.html | 41 +++++++++++- .../templates/edit_view_curriculum.html | 7 ++- candidates/views.py | 9 ++- common/forms.py | 16 ++++- companies/views.py | 62 +++++++++++++++++-- 7 files changed, 141 insertions(+), 15 deletions(-) diff --git a/candidates/forms.py b/candidates/forms.py index 9f78bca3..0b20c432 100644 --- a/candidates/forms.py +++ b/candidates/forms.py @@ -80,6 +80,13 @@ class CandidateForm(forms.ModelForm): empty_label=select_text, required=True, label=_('Marital Status')) + # Resume Upload + resume = forms.FileField( + widget=forms.FileInput(attrs={'class': "form-control", 'accept': ".pdf,.doc,.docx,.txt"}), + required=False, + label=_("Upload Resume") + ) + # min_salary = forms.IntegerField( # required=False, @@ -125,6 +132,15 @@ def __init__(self, *args, **kwargs): # self.fields['state'].choices = get_states(initial_country) # self.fields['municipal'].choices = get_municipals(state_selected) + def clean_resume(self): + file = self.cleaned_data.get('resume', None) + if file: + ext = file.name.split('.')[-1].lower() + if ext not in ['pdf', 'doc', 'docx', 'txt']: + raise forms.ValidationError(_('Only PDF, DOC, DOCX, or TXT files are allowed.')) + if file.size > 5 * 1024 * 1024: # 5MB limit + raise forms.ValidationError(_('The file is too large (Max 5MB).')) + return file def clean_public_photo(self): """ Validates the uploaded image: @@ -154,6 +170,7 @@ def clean_public_photo(self): #validate file size if len(image) > (1 * 1024 * 1024): + #if len(image) > (1 * 1024 * 1024): raise forms.ValidationError(_('The image selected is too large (Max 1MB)')) else: return default_photo diff --git a/candidates/models.py b/candidates/models.py index 98fa13ad..7d24b7a7 100644 --- a/candidates/models.py +++ b/candidates/models.py @@ -81,6 +81,7 @@ class Candidate(models.Model): last_modified = models.DateTimeField(verbose_name=_('Last Modified'), auto_now=True) parent_profile = models.ForeignKey("self", related_name="conflicted_profiles", null=True, blank=True, default=None, on_delete=models.SET_NULL) profile_source = models.CharField(_('Profile Source'), choices=PROFILE_SOURCE, max_length=2, null=True, blank=True, default=None) + resume = models.FileField( upload_to='resumes/', null=True, blank=True, default=None, verbose_name=_('Resume')) def get_fullname(self): """Get the full name combining first name and last name. @@ -682,8 +683,7 @@ class Curriculum(models.Model): advance = models.IntegerField(verbose_name=_('Percent Complete'), blank=True, null=True, default=0) add_date = models.DateTimeField(verbose_name=_('Add Date'), auto_now_add=True) last_modified = models.DateTimeField(verbose_name=_('Last Modified'), auto_now=True) - filecontent = models.TextField(default="", null=True, blank=True) - + filecontent = models.TextField(default="", null=True, blank=True) def get_form(self): from candidates.forms import cv_FileForm diff --git a/candidates/templates/candidate_registration.html b/candidates/templates/candidate_registration.html index 72a578c3..fe91abda 100644 --- a/candidates/templates/candidate_registration.html +++ b/candidates/templates/candidate_registration.html @@ -46,10 +46,23 @@

Talent SignUp

Switch to Employer SignUp Are you an Employer? -
+
-
+ + {% csrf_token %} + {% if messages %} +
+ {% for message in messages %} +
{{ message }}
+ {% endfor %} +
+ {% endif %}
+ + +
+
+ {% if form_user.resume.errors %} +
    + {% for error in form_user.resume.errors %} +
  • {{ error|escape }}
  • + {% endfor %} +
+ {% else %} + + {% endif %} + +
+ {{ form_user.resume }} +
+
+
+
diff --git a/candidates/templates/edit_view_curriculum.html b/candidates/templates/edit_view_curriculum.html index decb6270..870c5286 100644 --- a/candidates/templates/edit_view_curriculum.html +++ b/candidates/templates/edit_view_curriculum.html @@ -61,7 +61,7 @@ {% endif %} {{ fileForm.file }}
-
@@ -132,6 +132,9 @@