Commit 28777ac0 authored by Luko van der Maas's avatar Luko van der Maas

Merge branch 'tc/remove-unused-vacancy-functionality' into 'master'

Remove unused features from partners package

Closes #877

See merge request !1318
parents 078bde11 7a26ce27
......@@ -25,14 +25,6 @@ partners.apps module
:undoc-members:
:show-inheritance:
partners.emails module
----------------------
.. automodule:: partners.emails
:members:
:undoc-members:
:show-inheritance:
partners.models module
----------------------
......
from django.contrib import admin
from django.utils.translation import gettext_lazy as _
from partners.models import (Partner, PartnerEvent, PartnerImage,
Vacancy, VacancyCategory)
......@@ -15,7 +16,7 @@ class PartnerImageInline(admin.StackedInline):
class PartnerAdmin(admin.ModelAdmin):
"""Class to show partners in the admin."""
prepopulated_fields = {"slug": ("name",)}
prepopulated_fields = {'slug': ('name',)}
list_display = ('name', 'is_active', 'is_main_partner',
'is_local_partner')
search_fields = ('name', 'city')
......@@ -30,7 +31,7 @@ class PartnerAdmin(admin.ModelAdmin):
'is_active', 'is_main_partner', 'is_local_partner',
)
}),
('Address', {
(_('Address'), {
'fields': ('address', 'zip_code', 'city')
}),
......@@ -41,7 +42,7 @@ class PartnerAdmin(admin.ModelAdmin):
class VacancyCategoryAdmin(TranslatedModelAdmin):
"""Class to show vacancy categories in the admin."""
prepopulated_fields = {"slug": ("name_en",)}
prepopulated_fields = {'slug': ('name_en',)}
fields = ['name', 'slug']
......@@ -49,23 +50,20 @@ class VacancyCategoryAdmin(TranslatedModelAdmin):
class VacancyAdmin(admin.ModelAdmin):
"""Class to show vacancies in the admin."""
list_display = ('title', 'partner', 'company_name', 'expiration_date')
list_display = ('title', 'partner', 'company_name')
search_fields = ('title', 'partner__name', 'company_name',)
fieldsets = (
(None, {
'fields': ('title', 'description', 'link',)
}),
('Existing Partner', {
(_('Existing partner'), {
'fields': ('partner',)
}),
('Other Partner', {
(_('Other partner'), {
'fields': ('company_name', 'company_logo',)
}),
('Categories', {
(_('Categories'), {
'fields': ('categories',)
}),
('Other', {
'fields': ('remarks', 'expiration_date')
})
)
......
import datetime
from django.conf import settings
from django.core.mail import EmailMessage
from django.utils import timezone
from partners.models import Vacancy
def send_vacancy_expiration_notifications(dry_run=False):
"""Send a notification about expiring vacancies."""
# Select vacencies that expire in roughly a month, wherefor
# a mail hasn't been sent yet to Mr/Mrs Extern
expired_vacancies = Vacancy.objects.filter(
expiration_mail_sent=False,
expiration_date__lt=timezone.now().date() + datetime.timedelta(days=30)
)
for exp_vacancy in expired_vacancies:
# Create Message
subject = ('[WEBSITE] Vacancy \'{}\' by {} will soon expire'
.format(exp_vacancy.title, exp_vacancy.get_company_name()))
text_message = ('Hello!\n\nA vacancy of {}, \'{}\' will '
'expire within the next 30 days.'
'\n\nKind regards,\nThe website'
.format(exp_vacancy.title,
exp_vacancy.get_company_name()))
if not dry_run:
# Send Mail
EmailMessage(
subject,
text_message,
to=[settings.PARTNER_NOTIFICATION_ADDRESS]
).send()
# Save that mail has been sent into database
exp_vacancy.expiration_mail_sent = True
exp_vacancy.save()
This diff was suppressed by a .gitattributes entry.
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-20 16:40+0200\n"
"PO-Revision-Date: 2019-06-20 16:41+0200\n"
"POT-Creation-Date: 2019-08-03 18:47+0200\n"
"PO-Revision-Date: 2019-08-03 18:47+0200\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -18,6 +18,22 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.2.3\n"
#: admin.py templates/partners/partner.html
msgid "Address"
msgstr "Adres"
#: admin.py
msgid "Existing partner"
msgstr "Bestaande partner"
#: admin.py
msgid "Other partner"
msgstr "Andere partner"
#: admin.py
msgid "Categories"
msgstr "Categorieën"
#: apps.py templates/partners/index.html templates/partners/partner.html
msgid "Partners"
msgstr "Partners"
......@@ -38,6 +54,22 @@ msgstr "plaatje van {}"
msgid "Vacancy Categories"
msgstr "Vacaturecategorieën"
#: models.py
msgid "title"
msgstr "titel"
#: models.py
msgid "description"
msgstr "beschrijving"
#: models.py
msgid "link"
msgstr "link"
#: models.py
msgid "partner"
msgstr "partner"
#: models.py
msgid ""
"When you use a partner, the company name and logo below will not be used."
......@@ -46,8 +78,12 @@ msgstr ""
"niet gebruikt worden."
#: models.py
msgid "not shown on the page"
msgstr "wordt niet getoond op de vacaturepagina"
msgid "company name"
msgstr "bedrijfsnaam"
#: models.py
msgid "company logo"
msgstr "bedrijfslogo"
#: models.py
msgid "If no partner is used then both a company name and logo are required."
......@@ -62,14 +98,6 @@ msgstr "Selecteer of een partner of geef een bedrijfsnaam en logo."
msgid "Vacancies"
msgstr "Vacatures"
#: models.py
msgid "title"
msgstr "titel"
#: models.py
msgid "description"
msgstr "beschrijving"
#: models.py
msgid "location"
msgstr "locatie"
......@@ -140,10 +168,6 @@ msgstr "Lees meer"
msgid "our local partner"
msgstr "onze localpartner"
#: templates/partners/partner.html
msgid "Address"
msgstr "Adres"
#: templates/partners/partner.html
msgid "Website"
msgstr "Website"
......
from django.core.management.base import BaseCommand
from partners import emails
class Command(BaseCommand):
"""Command class for sendvacancyexpirationnotification command."""
def add_arguments(self, parser):
"""Add --dry-run argument to command."""
parser.add_argument(
'--dry-run',
action='store_true',
dest='dry-run',
default=False,
help='Dry run instead of sending e-mail',
)
def handle(self, *args, **options):
"""Call the function to handle the sending of emails."""
emails.send_vacancy_expiration_notifications(
bool(options['dry-run']))
# Generated by Django 2.2.1 on 2019-08-03 16:46
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import tinymce.models
class Migration(migrations.Migration):
dependencies = [
('partners', '0014_partner_is_local_partner'),
]
operations = [
migrations.RemoveField(
model_name='vacancy',
name='expiration_date',
),
migrations.RemoveField(
model_name='vacancy',
name='expiration_mail_sent',
),
migrations.RemoveField(
model_name='vacancy',
name='remarks',
),
migrations.AlterField(
model_name='partnerevent',
name='partner',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='events', to='partners.Partner', verbose_name='partner'),
),
migrations.AlterField(
model_name='vacancy',
name='company_logo',
field=models.ImageField(blank=True, null=True, upload_to='public/partners/vacancy-logos/', verbose_name='company logo'),
),
migrations.AlterField(
model_name='vacancy',
name='company_name',
field=models.CharField(blank=True, max_length=255, verbose_name='company name'),
),
migrations.AlterField(
model_name='vacancy',
name='description',
field=tinymce.models.HTMLField(verbose_name='description'),
),
migrations.AlterField(
model_name='vacancy',
name='link',
field=models.CharField(blank=True, max_length=255, validators=[django.core.validators.URLValidator()], verbose_name='link'),
),
migrations.AlterField(
model_name='vacancy',
name='partner',
field=models.ForeignKey(blank=True, help_text='When you use a partner, the company name and logo below will not be used.', null=True, on_delete=django.db.models.deletion.PROTECT, to='partners.Partner', verbose_name='partner'),
),
migrations.AlterField(
model_name='vacancy',
name='title',
field=models.CharField(max_length=255, verbose_name='title'),
),
]
......@@ -132,9 +132,15 @@ class VacancyCategory(models.Model, metaclass=ModelTranslateMeta):
class Vacancy(models.Model):
"""Model describing vacancies."""
title = models.CharField(max_length=255)
description = HTMLField()
title = models.CharField(
_("title"),
max_length=255
)
description = HTMLField(
_("description")
)
link = models.CharField(
_("link"),
max_length=255,
blank=True,
validators=[URLValidator()]
......@@ -142,6 +148,7 @@ class Vacancy(models.Model):
partner = models.ForeignKey(
Partner,
verbose_name=_("partner"),
on_delete=models.PROTECT,
null=True,
blank=True,
......@@ -149,8 +156,13 @@ class Vacancy(models.Model):
"below will not be used.")
)
company_name = models.CharField(max_length=255, blank=True)
company_name = models.CharField(
_("company name"),
max_length=255,
blank=True
)
company_logo = models.ImageField(
_("company logo"),
upload_to='public/partners/vacancy-logos/',
null=True,
blank=True
......@@ -158,11 +170,6 @@ class Vacancy(models.Model):
categories = models.ManyToManyField(VacancyCategory, blank=True)
expiration_date = models.DateField(null=True, blank=True)
expiration_mail_sent = models.BooleanField(default=False)
remarks = HTMLField(blank=True, help_text=_('not shown on the page'))
def get_company_name(self):
"""Return company or partner name."""
if self.partner:
......@@ -227,6 +234,7 @@ class PartnerEvent(models.Model, metaclass=ModelTranslateMeta):
partner = models.ForeignKey(
Partner,
verbose_name=_("partner"),
on_delete=models.CASCADE,
related_name="events",
blank=True,
......
......@@ -409,9 +409,6 @@ class Command(BaseCommand):
vacancy.company_logo.save(vacancy.company_name + '.jpeg',
ContentFile(icon))
if random.random() < 0.5:
vacancy.expiration_date = _faker.date_time_between("-1y", "+1y")
vacancy.save()
vacancy.categories.set(random.sample(list(categories),
......
Markdown is supported
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