Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Fix Salutation to improved list and add flexibility to load from settings #190

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Change Salutation to form list and add flexible choice to be optional…
…ly loaded from settings: 'ALDRYN_JOBS_SALUTATIONS'.
carderm authored and carderm committed Apr 30, 2018
commit 138702423996862b8c5af868ad5e2efdcf28c97c
5 changes: 4 additions & 1 deletion aldryn_jobs/forms.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
from .models import (
JobApplication, JobApplicationAttachment, JobCategory, JobOpening,
JobsConfig, JobListPlugin, JobCategoriesPlugin)
from .utils import namespace_is_apphooked
from .utils import namespace_is_apphooked, SALUTATION_CHOICES

SEND_ATTACHMENTS_WITH_EMAIL = getattr(
settings, 'ALDRYN_JOBS_SEND_ATTACHMENTS_WITH_EMAIL', True)
@@ -109,6 +109,9 @@ def get_app_config_filter(self):

class JobApplicationForm(forms.ModelForm):
FIVE_MEGABYTES = 1024 * 1024 * 5

salutation = forms.ChoiceField(required=False, choices=SALUTATION_CHOICES())

attachments = MultiFileField(
max_num=getattr(settings, 'ALDRYN_JOBS_ATTACHMENTS_MAX_COUNT', 5),
min_num=getattr(settings, 'ALDRYN_JOBS_ATTACHMENTS_MIN_COUNT', 0),
11 changes: 1 addition & 10 deletions aldryn_jobs/models.py
Original file line number Diff line number Diff line change
@@ -234,17 +234,8 @@ def get_notification_emails(self):

@python_2_unicode_compatible
class JobApplication(models.Model):
# FIXME: Gender is not the same as salutation.
MALE = 'male'
FEMALE = 'female'

SALUTATION_CHOICES = (
(MALE, _('Mr.')),
(FEMALE, _('Mrs.')),
)

job_opening = models.ForeignKey(JobOpening, related_name='applications')
salutation = models.CharField(_('salutation'), max_length=20, blank=True, choices=SALUTATION_CHOICES, default=MALE)
salutation = models.CharField(_('salutation'), max_length=20, blank=True)
first_name = models.CharField(_('first name'), max_length=20)
last_name = models.CharField(_('last name'), max_length=20)
email = models.EmailField(_('email'), max_length=254)
20 changes: 19 additions & 1 deletion aldryn_jobs/utils.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
from django.core.urlresolvers import reverse, NoReverseMatch
from django.utils.text import get_valid_filename as get_valid_filename_django
from django.template.defaultfilters import slugify

from django.conf import settings

def get_valid_filename(s):
"""
@@ -34,3 +34,21 @@ def namespace_is_apphooked(namespace):
except NoReverseMatch:
return False
return True


def SALUTATION_CHOICES():
SALUTATIONS = getattr(settings, "ALDRYN_JOBS_SALUTATIONS", None)
if SALUTATIONS:
return SALUTATIONS

return ((None,'---'),
('Mr','Mr'),
('Ms','Ms'),
('Mrs','Mrs'),
('Miss','Miss'),
('Dr','Dr'),
('Prof','Prof'),
('Rev','Rev'),
('Lady','Lady'),
('Sir','Sir'),
)