Commit 7ca4a4de authored by Tom van Bussel's avatar Tom van Bussel Committed by Sébastiaan Versteeg
Browse files

Improve vacancy validation

parent eda83c33
...@@ -7,8 +7,8 @@ msgid "" ...@@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-07 20:41+0100\n" "POT-Creation-Date: 2018-11-07 20:54+0100\n"
"PO-Revision-Date: 2018-11-07 20:42+0100\n" "PO-Revision-Date: 2018-11-07 20:56+0100\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n" "Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n" "Language-Team: \n"
"Language: nl\n" "Language: nl\n"
...@@ -16,7 +16,7 @@ msgstr "" ...@@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.2\n" "X-Generator: Poedit 2.0.6\n"
#: apps.py templates/partners/index.html templates/partners/partner.html #: apps.py templates/partners/index.html templates/partners/partner.html
msgid "Partners" msgid "Partners"
...@@ -53,6 +53,15 @@ msgstr "wordt niet getoond op de vacaturepagina" ...@@ -53,6 +53,15 @@ msgstr "wordt niet getoond op de vacaturepagina"
msgid "Vacancies" msgid "Vacancies"
msgstr "Vacatures" msgstr "Vacatures"
#: models.py
msgid "If no partner is used then both a company name and logo are required."
msgstr ""
"Wanneer je geen partner aangeeft, zijn de bedrijfsnaam en logo verplicht."
#: models.py
msgid "Either select a partner or provide a company name and logo."
msgstr "Selecteer of een partner of geef een bedrijfsnaam en logo."
#: models.py #: models.py
msgid "title" msgid "title"
msgstr "titel" msgstr "titel"
......
# Generated by Django 2.0.8 on 2018-11-07 19:10
from django.db import migrations
import tinymce.models
class Migration(migrations.Migration):
dependencies = [
('partners', '0012_auto_20180112_1005'),
]
operations = [
migrations.AlterField(
model_name='vacancy',
name='description',
field=tinymce.models.HTMLField(),
),
]
...@@ -91,7 +91,7 @@ class VacancyCategory(models.Model, metaclass=ModelTranslateMeta): ...@@ -91,7 +91,7 @@ class VacancyCategory(models.Model, metaclass=ModelTranslateMeta):
class Vacancy(models.Model): class Vacancy(models.Model):
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
description = HTMLField(blank=True) description = HTMLField()
link = models.CharField( link = models.CharField(
max_length=255, max_length=255,
blank=True, blank=True,
...@@ -143,6 +143,35 @@ class Vacancy(models.Model): ...@@ -143,6 +143,35 @@ class Vacancy(models.Model):
url = reverse('partners:partner', args=(self.partner.slug,)) url = reverse('partners:partner', args=(self.partner.slug,))
return '{}#vacancy-{}'.format(url, self.pk) return '{}#vacancy-{}'.format(url, self.pk)
def clean(self):
super().clean()
errors = {}
msg = _('If no partner is used then both a company name and logo are '
'required.')
if not self.partner and self.company_name and not self.company_logo:
errors.update({'company_logo': msg})
if not self.partner and not self.company_name and self.company_logo:
errors.update({'company_name': msg})
msg = _('Either select a partner or provide a company name and logo.')
if self.partner and (self.company_name or self.company_logo):
errors.update({'partner': msg})
if self.company_name:
errors.update({'company_name': msg})
if self.company_logo:
errors.update({'company_logo': msg})
if (not self.partner and not self.company_name and
not self.company_logo):
errors.update({
'partner': msg,
'company_name': msg,
'company_logo': msg,
})
if errors:
raise ValidationError(errors)
class PartnerEvent(models.Model, metaclass=ModelTranslateMeta): class PartnerEvent(models.Model, metaclass=ModelTranslateMeta):
partner = models.ForeignKey( partner = models.ForeignKey(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment