Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
225a9533
Commit
225a9533
authored
Aug 16, 2017
by
Luuk Scholten
Browse files
Merge branch 'feature/einddatum_vacature' into 'master'
Voeg einddatum toe aan vacatures Closes
#170
See merge request
!476
parents
18dbb918
c7ccf3ef
Changes
7
Hide whitespace changes
Inline
Side-by-side
website/partners/admin.py
View file @
225a9533
...
...
@@ -37,11 +37,11 @@ class VacancyCategoryAdmin(TranslatedModelAdmin):
@
admin
.
register
(
Vacancy
)
class
VacancyAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'title'
,
'partner'
,
'company_name'
,)
list_display
=
(
'title'
,
'partner'
,
'company_name'
,
'expiration_date'
)
fieldsets
=
(
(
None
,
{
'fields'
:
(
'title'
,
'description'
,
'link'
)
'fields'
:
(
'title'
,
'description'
,
'link'
,
)
}),
(
'Existing Partner'
,
{
'fields'
:
(
'partner'
,)
...
...
@@ -50,10 +50,10 @@ class VacancyAdmin(admin.ModelAdmin):
'fields'
:
(
'company_name'
,
'company_logo'
,)
}),
(
'Categories'
,
{
'fields'
:
(
'categories'
,
)
'fields'
:
(
'categories'
,)
}),
(
'Other'
,
{
'fields'
:
(
'remarks'
,
)
'fields'
:
(
'remarks'
,
'expiration_date'
)
})
)
...
...
website/partners/migrations/0009_vacancy_expiration_date.py
0 → 100644
View file @
225a9533
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-05-03 19:04
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'partners'
,
'0008_auto_20170120_0837'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'vacancy'
,
name
=
'expiration_date'
,
field
=
models
.
DateField
(
blank
=
True
,
null
=
True
),
),
]
website/partners/migrations/0010_vacancy_expiration_mail_sent.py
0 → 100644
View file @
225a9533
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-05-10 17:20
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'partners'
,
'0009_vacancy_expiration_date'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'vacancy'
,
name
=
'expiration_mail_sent'
,
field
=
models
.
BooleanField
(
default
=
0
),
preserve_default
=
False
,
),
]
website/partners/models.py
View file @
225a9533
...
...
@@ -62,7 +62,7 @@ class Partner(models.Model):
return
reverse
(
'partners:partner'
,
args
=
(
self
.
slug
,))
class
Meta
:
ordering
=
(
'name'
,
)
ordering
=
(
'name'
,)
class
PartnerImage
(
models
.
Model
):
...
...
@@ -115,6 +115,9 @@ class Vacancy(models.Model):
categories
=
models
.
ManyToManyField
(
VacancyCategory
,
blank
=
True
)
expiration_date
=
models
.
DateField
(
null
=
True
,
blank
=
True
)
expiration_mail_sent
=
models
.
BooleanField
()
remarks
=
HTMLField
(
blank
=
True
,
help_text
=
_
(
'not shown on the page'
))
def
get_company_name
(
self
):
...
...
website/partners/urls.py
View file @
225a9533
...
...
@@ -7,5 +7,6 @@ app_name = "partners"
urlpatterns
=
[
url
(
r
'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r
'^partners/(?P<slug>[-\w]+)$'
,
views
.
partner
,
name
=
'partner'
),
url
(
r
'^vacancies$'
,
views
.
vacancies
,
name
=
'vacancies'
)
url
(
r
'^vacancies$'
,
views
.
vacancies
,
name
=
'vacancies'
),
url
(
r
'^vacancies/send-expiration-mails$'
,
views
.
send_vacancy_expiration_mails
,
name
=
'send-expiration-mails'
)
]
website/partners/views.py
View file @
225a9533
from
random
import
random
import
datetime
from
django.http
import
HttpResponse
from
django.shortcuts
import
get_object_or_404
,
render
from
django.utils
import
timezone
from
django.core.mail
import
EmailMessage
from
partners.models
import
Partner
,
Vacancy
,
VacancyCategory
from
thaliawebsite.settings
import
settings
def
index
(
request
):
...
...
@@ -33,8 +39,42 @@ def partner(request, slug):
def
vacancies
(
request
):
context
=
{
'vacancies'
:
Vacancy
.
objects
.
all
().
order_by
(
'?'
),
'vacancies'
:
Vacancy
.
objects
.
exclude
(
expiration_date__lte
=
timezone
.
now
().
date
()).
order_by
(
'?'
),
'categories'
:
VacancyCategory
.
objects
.
all
(),
}
return
render
(
request
,
'partners/vacancies.html'
,
context
)
def
send_vacancy_expiration_mails
():
# 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
=
(
"[THALIA][SPONSOR] Vacature '{}' van {} loopt af"
.
format
(
exp_vacancy
.
title
,
exp_vacancy
.
get_company_name
()))
text_message
=
(
"Hallo Extern,
\n\n
de vacature van {}, '{}' loopt "
"over circa een maand af. Misschien wil "
"je ze contacteren om een nieuwe deal "
"te sluiten.
\n\n
Groetjes,
\n
De Website"
.
format
(
exp_vacancy
.
title
,
exp_vacancy
.
get_company_name
()))
recipient
=
settings
.
PARTNER_EMAIL
# Send Mail
EmailMessage
(
subject
,
text_message
,
to
=
recipient
).
send
()
# Save that mail has been sent into database
exp_vacancy
.
expiration_mail_sent
=
True
exp_vacancy
.
save
()
return
HttpResponse
(
status
=
200
)
website/thaliawebsite/settings/settings.py
View file @
225a9533
...
...
@@ -232,6 +232,9 @@ SERVER_EMAIL = DEFAULT_FROM_EMAIL
# Newsletter settings
NEWSLETTER_FROM_ADDRESS
=
'nieuwsbrief@thalia.nu'
# Partners notification email
PARTNER_EMAIL
=
"samenwerking@thalia.nu"
# Website FROM address
WEBSITE_FROM_ADDRESS
=
'info@thalia.nu'
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment