Commit 6cfa2491 authored by Luuk Scholten's avatar Luuk Scholten
Browse files

Add implementation of vacancies

Vacancies can be added for both existing partners and other companies.
parent a0d22bdc
......@@ -6,6 +6,7 @@ from partners.models import (
Partner,
PartnerImage,
VacancyCategory,
Vacancy,
)
......@@ -37,3 +38,21 @@ class PartnerAdmin(admin.ModelAdmin):
class VacancyCategoryAdmin(TranslatedModelAdmin):
prepopulated_fields = {"slug": ("name_en",)}
fields = ['name', 'slug']
@admin.register(Vacancy)
class VacancyAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
'fields': ('title', 'description', 'link')
}),
('Existing Partner', {
'fields': ('partner',)
}),
('Other Partner', {
'fields': ('company_name', 'company_logo',)
}),
('Categories', {
'fields': ('categories', )
}),
)
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-13 11:58+0200\n"
"PO-Revision-Date: 2016-08-13 12:00+0200\n"
"POT-Creation-Date: 2016-08-13 12:02+0200\n"
"PO-Revision-Date: 2016-08-13 12:03+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: nl\n"
......@@ -55,6 +55,8 @@ msgid "Main Partner"
msgstr "Hoofdsponsor"
#: templates/partners/index.html:38 templates/partners/index.html:65
#: templates/partners/partner.html:81 templates/partners/vacancies.html:53
#: templates/partners/vacancies.html:58 templates/partners/vacancies.html:89
msgid "Learn more"
msgstr "Lees meer"
......@@ -82,3 +84,35 @@ msgstr "Plaatsnaam"
#: templates/partners/partner.html:55
msgid "Website"
msgstr "Website"
#: templates/partners/partner.html:67 templates/partners/vacancies.html:5
msgid "Vacancies"
msgstr "Vacatures"
#: templates/partners/vacancies.html:7
msgid ""
"Je bent student en je hebt het maar krap. De politiek wil de studenten ook "
"al niet een handje toesteken. Gelukkig hebben we bedrijven die bij ons "
"vacatures aanbieden. Dus zit je krap en wil je wat bijverdienen, of ben je "
"(bijna) afgestudeerd en wil je eens wat rondkijken, op deze pagina staan al "
"onze openstaande vacatures. Wil je als bedrijf een vacature plaatsen op onze "
"website, dan kun je contact opnemen met de voorzitter van onze "
"sponsorcommissie via <a href=\"mailto:sponsor@thalia.nu\" target=\"_blank"
"\">sponsor@thalia.nu</a>."
msgstr ""
"Je bent student en je hebt het maar krap. De politiek wil de studenten ook "
"al niet een handje toesteken. Gelukkig hebben we bedrijven die bij ons "
"vacatures aanbieden. Dus zit je krap en wil je wat bijverdienen, of ben je "
"(bijna) afgestudeerd en wil je eens wat rondkijken, op deze pagina staan al "
"onze openstaande vacatures. Wil je als bedrijf een vacature plaatsen op onze "
"website, dan kun je contact opnemen met de voorzitter van onze "
"sponsorcommissie via <a href=\"mailto:sponsor@thalia.nu\" target=\"_blank"
"\">sponsor@thalia.nu</a>."
#: templates/partners/vacancies.html:22
msgid "Everything"
msgstr "Alles"
#: templates/partners/vacancies.html:69
msgid "All vacancies"
msgstr "Alle vacatures"
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-13 08:47
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('partners', '0002_vacancycategory'),
]
operations = [
migrations.CreateModel(
name='Vacancy',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=255)),
('description', models.TextField(max_length=3072)),
('link', models.CharField(blank=True, max_length=255, validators=[django.core.validators.URLValidator()])),
('company_name', models.CharField(blank=True, max_length=255)),
('company_logo', models.ImageField(blank=True, null=True, upload_to='public/partners/vacancy-logos/')),
('categories', models.ManyToManyField(blank=True, to='partners.VacancyCategory')),
('partner', 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')),
],
options={
'verbose_name_plural': 'Vacancies',
},
),
]
......@@ -77,3 +77,47 @@ class VacancyCategory(models.Model, metaclass=ModelTranslateMeta):
class Meta:
verbose_name_plural = 'Vanancy Categories'
class Vacancy(models.Model):
title = models.CharField(max_length=255)
description = models.TextField(max_length=3072)
link = models.CharField(
max_length=255,
blank=True,
validators=[URLValidator()]
)
partner = models.ForeignKey(
Partner,
on_delete=models.PROTECT,
null=True,
blank=True,
help_text="When you use a partner, the company name and logo " +
"below will not be used."
)
company_name = models.CharField(max_length=255, blank=True)
company_logo = models.ImageField(
upload_to='public/partners/vacancy-logos/',
null=True,
blank=True
)
categories = models.ManyToManyField(VacancyCategory, blank=True)
def get_company_name(self):
if self.partner:
return self.partner.name
return self.company_name
def get_company_logo(self):
if self.partner:
return self.partner.logo
return self.company_logo
def __str__(self):
return self.get_company_name() + ' - ' + self.title
class Meta:
verbose_name_plural = 'Vacancies'
......@@ -62,45 +62,38 @@
</div>
</div>
{# todo vacancies #}
{% if partner.vacancies.all|length > 0 %}
<div id="partner_vacatures">
<h3>Vacatures</h3>
{% if vacancies.all|length > 0 %}
<div id="partner_vacatures">
<h3>{% trans "Vacancies" %}</h3>
<div class="row">
<div class="span12">
<ul class="toggles">
<?php foreach($partner->getVacancies() as $vacancy): ?>
<li id="vacancy-<?php echo $vacancy->id; ?>">
<div class="toggle-title"><a href="#"><span></span><?php echo $vacancy->title ?></a></div>
<div class="toggle-content">
<?php echo $vacancy->description ?>
<div class="row">
<div class="span12">
<ul class="toggles">
{% for vacancy in vacancies %}
<li id="vacancy-{{ vacancy.id }}">
<div class="toggle-title"><a href="#"><span></span>{{ vacancy.title }}</a></div>
<div class="toggle-content">
{{ vacancy.description }}
<?php if ($vacancy->link !== ''): ?>
<?php if (preg_match('/http(s?)/', $vacancy->link)): ?>
<?php $link = $vacancy->link; ?>
<?php else: ?>
<?php $link = sprintf("http://%s", $vacancy->link); ?>
<?php endif; ?>
<br /><br />
<a href="<?php echo $link; ?>" target="_blank" rel="noopener">
<button type="button" class="btn-large btn-style2">Ontdek meer</button>
</a>
<?php endif; ?>
</div>
</li>
<?php endforeach; ?>
</ul>
{% if vacancy.link %}
<br /><br />
<a href="{{ vacancy.link }}" target="_blank" rel="noopener">
<button type="button" class="btn-large btn-style2">{% trans "Learn more" %}</button>
</a>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
var windowhash = window.location.hash;
$(windowhash).children('.toggle-title').click();
});
</script>
<script type="text/javascript">
$(document).ready(function(){
var windowhash = window.location.hash;
$(windowhash).children('.toggle-title').click();
});
</script>
{% endif %}
{# todo vacancies #}
{% endblock body %}
{% extends 'base.html' %}
{% load i18n %}
{% block body %}
<h1>{% trans "Vacancies" %}</h1>
<p class="tcenter">
{% blocktrans trimmed %}
Je bent student en je hebt het maar krap. De politiek wil de studenten ook al niet een handje toesteken. Gelukkig
hebben we bedrijven die bij ons vacatures aanbieden. Dus zit je krap en wil je wat bijverdienen, of ben je (bijna)
afgestudeerd en wil je eens wat rondkijken, op deze pagina staan al onze openstaande vacatures.
Wil je als bedrijf een vacature plaatsen op onze website, dan kun je contact opnemen met de voorzitter van onze
sponsorcommissie via <a href="mailto:sponsor@thalia.nu" target="_blank">sponsor@thalia.nu</a>.
{% endblocktrans %}
</p>
<div class="isotope" id="vacanciespage">
<!-- .portfolio-filter -->
<div class="isotope-filter tabs-wrapper tabs-centered clearfix">
<ul class="tabs">
<li class="{% if not preselected_category %}current{% endif %}">
<a href="#">{% trans "Everything" %}</a>
</li>
{% for category in categories %}
<li
data-filter="category-{{ category.id }}"
class="{% if preselected_category and preselected_category.id == category.id %}current{% endif %}">
<a href="#">{{ category.name }}</a>
</li>
{% endfor %}
</ul>
</div>
<!-- /.portfolio-filter -->
<div class="row isotope-items">
{% for vacancy in vacancies %}
<div class="team span4 clearfix isotope-item"
data-filter="{% for cat in vacancy.categories.all %}category-{{ cat.id }} {% endfor %}">
<div class="team-header">
{% if vacancy.get_company_logo %}
<img src="{{ vacancy.get_company_logo.url }}" alt="">
{% endif %}
</div>
<div class="team-content">
<h5 class="tcenter">
{{ vacancy.get_company_name }}
<small>{{ vacancy.title }}</small>
</h5>
<p>{{ vacancy.description|truncatechars:150 }}</p>
<div class="team-readmore">
{% if vacancy.partner %}
<a href="{% url 'partners:partner' slug=vacancy.partner.slug %}#vacancy-{{ vacancy.id }}">
{% trans "Learn more" %}
</a>
{% else %}
<a href="#vacancy-{{ vacancy.id }}"
class="vacancy-external" data-vacancy="{{ vacancy.id }}">
{% trans "Learn more" %}
</a>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
{% if vacancies|length > 0 %}
<div id="sponsor_vacatures">
<h3>{% trans "All vacancies" %}</h3>
<div class="row">
<div class="span12">
<ul class="toggles">
{% for vacancy in vacancies %}
<li id="vacancy-{{ vacancy.id }}">
<div class="toggle-title">
<a href="#">
<span></span>
{{ vacancy.get_company_name }} | {{ vacancy.title }}
</a>
</div>
<div class="toggle-content">
{{ vacancy.description }}
{% if vacancy.link %}
<br /><br />
<a href="{{ vacancy.link }}" target="_blank" rel="noopener">
<button type="button" class="btn-large btn-style2">
{% trans "Learn more" %}
</button>
</a>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
{% endif %}
</div>
<script type="text/javascript">
$(document).ready(function(){
var body = $('body');
var isotope = body.find('.isotope'),
isotopeFilter = isotope.find('.isotope-filter'),
isotopePosts = isotope.find('.isotope-items');
if (jQuery().isotope) {
isotopeFilter.delegate('li', 'click', function(e) {
var filter;
if ($(this).data('filter')==undefined) {
filter='*';
} else {
filter='[data-filter*="' + $(this).data('filter') + '"]';
}
setTimeout(function() {
isotopePosts.isotope({ filter: filter });
}, 100);
});
}
$(window).resize(function() {
if (isotopeFilter.find('li.current').length) {
isotopeFilter.find('li.current').trigger('click');
} else {
isotopeFilter.find('li:first').trigger('click');
}
});
$('.vacancy-external').click(function() {
var id = $(this).attr('data-vacancy');
$('#vacancy-' + id).children('.toggle-title').click();
});
});
</script>
{% endblock body %}
\ No newline at end of file
......@@ -6,4 +6,5 @@ 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')
]
from django.shortcuts import get_object_or_404, render
from partners.models import Partner
from partners.models import Partner, Vacancy, VacancyCategory
from random import random
......@@ -19,8 +19,17 @@ def index(request):
def partner(request, slug):
partner = get_object_or_404(Partner, slug=slug)
return render(
request,
'partners/partner.html',
{'partner': partner}
)
context = {
'partner': partner,
'vacancies': Vacancy.objects.filter(partner=partner),
}
return render(request, 'partners/partner.html', context)
def vacancies(request):
context = {
'vacancies': Vacancy.objects.all(),
'categories': VacancyCategory.objects.all(),
}
return render(request, 'partners/vacancies.html', context)
......@@ -23,7 +23,7 @@ main = [
{'title': _('Calendar'), 'name': '#'},
{'title': _('Career'), 'name': 'partners:index', 'submenu': [
{'title': _('Partners'), 'name': 'partners:index'},
{'title': _('Vacancies'), 'name': '#'},
{'title': _('Vacancies'), 'name': 'partners:vacancies'},
]},
{'title': _('Education'), 'name': '#', 'submenu': [
{'title': _('Book Sale'), 'name': '#'},
......
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