Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions candidates/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions candidates/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
41 changes: 38 additions & 3 deletions candidates/templates/candidate_registration.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,23 @@ <h1 class="text-center text-light">Talent SignUp</h1>
<a class="btn btn-sm btn-block btn-info" href="{% url 'companies_record_recruiter' %}">Switch to Employer SignUp</a>
<small class="text-light">Are you an Employer?</small>
</div>
<div clas="col-xs-12 clearfix"></div>
<div class="col-xs-12 clearfix"></div>
</div>
<form id="create-candidate-form" action="." method="post" role="form" class="row mt10 mb50">
<form id="create-candidate-form"
action="."
method="post"
enctype="multipart/form-data"
role="form"
class="row mt10 mb50">

{% csrf_token %}
{% if messages %}
<div class="col-sm-8 col-sm-push-2">
{% for message in messages %}
<div class="alert alert-{{ message.tags }}">{{ message }}</div>
{% endfor %}
</div>
{% endif %}
<div class="col-sm-8 col-sm-push-2 panel mt20">
<div class="row panel-body panel-shadow">
<div class="col-xs-12 hidden">
Expand Down Expand Up @@ -154,14 +167,36 @@ <h2 class="text-center text-light"></h2>
<li>{{ error|escape }}</li>
{% endfor %}
</ul>
{% else %}
{% else %}
<label for="id_password_repeat">{% trans 'Confirm password' %}<span class="required">*</span></label>
{% endif %}
<div class="input-group {% if form_user.password_repeat.errors %}has-error{% endif %} mb20">
<div class="input-group-addon"><i class="fa fa-lock fa-lg"></i></div>
{{ form_user.password_repeat }}
</div>
</div></div>
<!-- Resume Upload -->
<!-- Resume Upload -->
<div class="col-xs-12">
<div class="form-group">
{% if form_user.resume.errors %}
<ul class="list-unstyled error-list">
{% for error in form_user.resume.errors %}
<li>{{ error|escape }}</li>
{% endfor %}
</ul>
{% else %}
<label for="{{ form_user.resume.id_for_label }}">
{% trans 'Upload Resume' %}
</label>
{% endif %}

<div class="input-group {% if form_user.resume.errors %}has-error{% endif %} mb20">
{{ form_user.resume }}
</div>
</div>
</div>


<!-- Submit Form -->
<div class="col-xs-12 mt30">
Expand Down
7 changes: 5 additions & 2 deletions candidates/templates/edit_view_curriculum.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h5 class="modal-title">{% trans 'Upload my CV/Resume/Profile' %}</h5>
{% endif %}
{{ fileForm.file }}
<div class="mt20">
<button id="submit_btn" type="submit" class="btn btn-sm btn-block btn-info">
<button id="upload_cv_submit_btn" type="submit" class="btn btn-sm btn-block btn-info">
{% if cv_file %}
{% trans 'Upload' %}
{% else %}
Expand Down Expand Up @@ -98,7 +98,7 @@ <h6 style="font-style: italic; text-align: justify;">
{% endif %}
{{ form_user_photo.photo }}
<div class="mt20">
<button id="submit_btn" type="submit" class="btn btn-sm btn-block btn-info">
<button id="update_image_submit_btn" type="submit" class="btn btn-sm btn-block btn-info">
Update Image
</button>
</div>
Expand Down Expand Up @@ -132,6 +132,9 @@ <h5 class="modal-title">Remove <span class="header">Experience</span></h5>
<nav class="affix-top mt40" data-spy="affix" data-offset-top="50" >
<a class="btn btn-info btn-block mb20 hidden" href="#"> Import from Linked<i class="fa fa-linkedin-square fa-fw"></i></a>
<a class="btn btn-default btn-block mb20" href="{% url 'vacancies_curriculum_to_pdf' candidate.id %}">Download Profile</a>
{% if candidate.resume %}
<a class="btn btn-default btn-block mb20" href="{{ candidate.resume.url }}" target="_blank">View uploaded resume</a>
{% endif %}
{% if recruiter %}
<h6 class="text-left mb20"> <i class="fa fa-flag-checkered"></i> &nbsp;<small class="text-light">Current Process</small> <br>
<span class="text-left">
Expand Down
9 changes: 6 additions & 3 deletions candidates/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,20 @@ def record_candidate(request):
redirects after successful registration.
"""
if request.method == 'POST':
form_user = UserDataForm(data=request.POST,
files=request.FILES,)
form_user = UserDataForm(request.POST, request.FILES)
#form_user = Form(data=request.POST,
# files=request.FILES,)
if form_user.is_valid():
new_user = form_user.save()
candidate_profile = Profile.objects.get(codename='candidate')
new_user.profile = candidate_profile
new_user.logued_by = 'EL'
new_user.save()
# try:
Candidate.objects.create(user=new_user, first_name=new_user.first_name, last_name=new_user.last_name)
Candidate.objects.create(user=new_user, first_name=new_user.first_name, last_name=new_user.last_name,resume=form_user.cleaned_data.get('resume'))
form_user.send_verification_mail(new_user)
if form_user.cleaned_data.get('resume'):
messages.success(request,_('Resume uploaded successfully'))
request.session['new_email'] = new_user.email
# raise ValueError(request.session.keys())
# raise ValueError(request.session['new_email'])
Expand Down
16 changes: 15 additions & 1 deletion common/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class UserDataForm(forms.ModelForm):
Handles user registration with email verification, password confirmation,
and basic user information collection including name, email, and phone.
"""
resume = forms.FileField(required=False)
email_repeat_msg = _('Confirm your email')
password_repeat_msg = _('* Confirm your Password')
username = forms.RegexField(
Expand Down Expand Up @@ -272,6 +273,19 @@ def clean(self):

return self.cleaned_data

def clean_resume(self):
"""Validate resume file type and size."""
file = self.cleaned_data.get('resume')
if not file:
return None
# Max 5MB
if getattr(file, 'size', 0) > 5 * 1024 * 1024:
raise forms.ValidationError(_('The file is too large (Max 5MB).'))
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.'))
return file

def send_verification_mail(self, new_user):
AccountVerification.objects.send_verification_mail(new_user=new_user)

Expand Down Expand Up @@ -306,7 +320,7 @@ def save(self, *args, **kwargs):

class Meta():
model = User
fields = ('username', 'first_name', 'last_name', 'email',)
fields = ('username', 'first_name', 'last_name', 'email')
# ---------------------------------------------- #
# Registration Form End User Data #
# ---------------------------------------------- #
Expand Down
62 changes: 58 additions & 4 deletions companies/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,15 @@ def site_management(request, setting=None):
return redirect(redirect_page)
context={}
context['success'] = False
if not setting:
setting = 'template'
#if not setting:
# setting = 'template'
# if not setting:
# setting = 'subdomain'
if setting == 'embed' and company.check_service('CSM_JOBS_WIDGET'):
setting = 'template'
try:
recruiter = Recruiter.objects.get(user=request.user, user__is_active=True)
except:
except Recruiter.DoesNotExist:
raise Http404
if not recruiter.is_admin():
raise Http404
Expand All @@ -530,7 +532,8 @@ def site_management(request, setting=None):
elif setting == 'subdomain' and company.check_service('CSM_CNAME'):
context['isSubdomainPage'] = True
if request.method == 'POST':
form_subdomain = SubdomainForm(instance=context['sub_domain'], data=request.POST, files = request.FILES)
#form_subdomain = SubdomainForm(instance=context['sub_domain'], data=request.POST, files = request.FILES)
form_subdomain = SubdomainForm(instance=company, data=request.POST, files=request.FILES)
if form_subdomain.is_valid():
form_subdomain.save()
messages.success(request, 'The subdomain has been successfully updated')
Expand All @@ -550,6 +553,57 @@ def site_management(request, setting=None):
raise Http404
context['isCompanyManagement'] = True
return render(request,'site_management.html',context)
"""def site_management(request, setting=None):
if request.user.is_authenticated and not request.user.email:
return redirect('common_register_blank_email')

if not setting:
setting = 'template'

try:
recruiter = Recruiter.objects.get(user=request.user, user__is_active=True)
except Recruiter.DoesNotExist:
raise Http404

if not recruiter.is_admin():
raise Http404

company = recruiter.company.first()
if not company:
raise Http404

context = {
"success": False,
"user": request.user,
"recruiter": recruiter,
"company": company,
"sub_domain": company.subdomain,
"isCompanyManagement": True,
}

if setting == 'template':
context["isTemplatePage"] = True

elif setting == 'subdomain' and company.check_service("CSM_CNAME"):
context["isSubdomainPage"] = True
if request.method == "POST":
form_subdomain = SubdomainForm(instance=company, data=request.POST, files=request.FILES)
if form_subdomain.is_valid():
form_subdomain.save()
messages.success(request, "The subdomain has been successfully updated")
else:
form_subdomain = SubdomainForm(instance=company)
context["form_subdomain"] = form_subdomain

elif setting == 'embed' and company.check_service("CSM_JOBS_WIDGET"):
context["isEmbedPage"] = True
context["Embedurl"] = company.geturl() + reverse("companies_job_widget")

else:
raise Http404

return render(request, "site_management.html", context)"""


@login_required
def team_space(request):
Expand Down