Commit a3db4899 authored by Luuk Scholten's avatar Luuk Scholten

Add first version of partners app

Contains page with overview of partners
Contains admin of partners
parent 738af721
from django.contrib import admin
from partners.models import Partner, PartnerImage
class PartnerImageInline(admin.StackedInline):
model = PartnerImage
@admin.register(Partner)
class PartnerAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("name",)}
fieldsets = (
(None, {
'fields': (
'is_active', 'is_main_partner', 'name', 'slug', 'link',
'company_profile', 'logo', 'site_header'
)
}),
('Address', {
'fields': ('address', 'zip_code', 'city')
}),
)
inlines = (PartnerImageInline,)
from django.apps import AppConfig
class PartnersConfig(AppConfig):
name = 'partners'
This diff was suppressed by a .gitattributes entry.
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-03 21:28+0200\n"
"PO-Revision-Date: 2016-08-03 21:28+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.7.1\n"
#: templates/partners/index.html:6
msgid "Our partners"
msgstr "Onze partners"
#: templates/partners/index.html:8
msgid ""
"Als studievereniging doen we ontzettend ons best om leuke evenementen en "
"activiteiten te organiseren voor de studenten die lid zijn van Thalia. "
"Voorbeelden van deze evenementen en activiteiten zijn symposia, borrels en "
"programmeerwedstrijden. Verder organiseren wij ook lunchlezingen, workshops "
"en brengen we vijf keer per jaar de Thabloid uit (het studieblad van "
"Thalia). Voor financiering van deze activiteiten zijn wij afhankelijk van "
"het bedrijfsleven. Wij staat dan ook ten alle tijden open voor nieuwe "
"samenwerkingsmogelijkheden. Mocht u concrete interesse hebben om deze "
"bruisende studievereniging financieel te ondersteunen of bent u benieuwd "
"naar samenwerkingsmogelijkheden, dan kunt u een e-mail versturen naar de "
"commissaris externe betrekkingen, die te bereiken is via <a href=\"mailto:"
"samenwerking@thalia.nu\">samenwerking@thalia.nu</a>."
msgstr ""
"Als studievereniging doen we ontzettend ons best om leuke evenementen en "
"activiteiten te organiseren voor de studenten die lid zijn van Thalia. "
"Voorbeelden van deze evenementen en activiteiten zijn symposia, borrels en "
"programmeerwedstrijden. Verder organiseren wij ook lunchlezingen, workshops "
"en brengen we vijf keer per jaar de Thabloid uit (het studieblad van "
"Thalia). Voor financiering van deze activiteiten zijn wij afhankelijk van "
"het bedrijfsleven. Wij staat dan ook ten alle tijden open voor nieuwe "
"samenwerkingsmogelijkheden. Mocht u concrete interesse hebben om deze "
"bruisende studievereniging financieel te ondersteunen of bent u benieuwd "
"naar samenwerkingsmogelijkheden, dan kunt u een e-mail versturen naar de "
"commissaris externe betrekkingen, die te bereiken is via <a href=\"mailto:"
"samenwerking@thalia.nu\">samenwerking@thalia.nu</a>."
#: templates/partners/index.html:25
msgid "Main Partner"
msgstr "Hoofdsponsor"
#: templates/partners/index.html:35 templates/partners/index.html:60
msgid "Learn more"
msgstr "Lees meer"
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-06 18:42
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Partner',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('is_active', models.BooleanField(default=False)),
('is_main_partner', models.BooleanField(default=False)),
('name', models.CharField(max_length=255)),
('slug', models.SlugField()),
('link', models.CharField(blank=True, max_length=255, validators=[django.core.validators.URLValidator()])),
('company_profile', models.TextField(blank=True, max_length=3072)),
('logo', models.ImageField(upload_to='public/partners/logos/')),
('site_header', models.ImageField(blank=True, null=True, upload_to='public/partners/headers/')),
('address', models.CharField(max_length=100, validators=[django.core.validators.RegexValidator(message='Enter a valid address', regex='^([1-9][e][\\s])*([ëéÉËa-zA-Z]+(([\\.][\\s])|([\\s]))?)+[1-9][0-9]*(([-][1-9][0-9]*)|([\\s]?[ëéÉËa-zA-Z]+))?$')])),
('zip_code', models.CharField(max_length=12, validators=[django.core.validators.RegexValidator(message='Enter a valid zip code', regex='^[1-9][0-9]{3}[\\s]?[A-Za-z]{2}$')])),
('city', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='PartnerImage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('image', models.ImageField(upload_to='public/partners/images/')),
('partner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='partners.Partner')),
],
),
]
from django.db import models
from django.core.validators import RegexValidator, URLValidator
class Partner(models.Model):
is_active = models.BooleanField(default=False)
is_main_partner = models.BooleanField(default=False)
name = models.CharField(max_length=255)
slug = models.SlugField()
link = models.CharField(
max_length=255,
blank=True,
validators=[URLValidator()]
)
company_profile = models.TextField(max_length=3072, blank=True)
logo = models.ImageField(upload_to='public/partners/logos/')
site_header = models.ImageField(
upload_to='public/partners/headers/',
null=True,
blank=True
)
address = models.CharField(max_length=100, validators=[
RegexValidator(
regex=(r'^([1-9][e][\s])*([ëéÉËa-zA-Z]'
'+(([\.][\s])|([\s]))?)+[1-9][0-9]'
'*(([-][1-9][0-9]*)|([\s]?[ëéÉËa-zA-Z]+))?$'),
message='Enter a valid address')
])
zip_code = models.CharField(max_length=12, validators=[
RegexValidator(
regex=r'^[1-9][0-9]{3}[\s]?[A-Za-z]{2}$',
message='Enter a valid zip code'
)
])
city = models.CharField(max_length=100)
def save(self, *args, **kwargs):
if self.is_main_partner:
self._reset_main_partner()
super(Partner, self).save(*args, **kwargs)
def _reset_main_partner(self):
try:
current_main_partner = Partner.objects.get(is_main_partner=True)
if self != current_main_partner:
current_main_partner.is_main_partner = False
current_main_partner.save()
except Partner.DoesNotExist:
pass
def __str__(self):
return self.name
class PartnerImage(models.Model):
partner = models.ForeignKey(
Partner,
on_delete=models.CASCADE,
related_name="images"
)
image = models.ImageField(upload_to='partners/images/')
def __str__(self):
return 'image of {}'.format(self.partner.name)
{% extends 'base.html' %}
{% load i18n %}
{% block body %}
<h1>{% trans "Our partners" %}</h1>
<p class="tcenter">
{% blocktrans trimmed %}
Als studievereniging doen we ontzettend ons best om leuke evenementen en activiteiten te organiseren
voor de studenten die lid zijn van Thalia.
Voorbeelden van deze evenementen en activiteiten zijn symposia, borrels en programmeerwedstrijden.
Verder organiseren wij ook lunchlezingen, workshops en brengen we vijf keer per jaar de Thabloid
uit (het studieblad van Thalia).
Voor financiering van deze activiteiten zijn wij afhankelijk van het bedrijfsleven.
Wij staat dan ook ten alle tijden open voor nieuwe samenwerkingsmogelijkheden.
Mocht u concrete interesse hebben om deze bruisende studievereniging financieel te ondersteunen of
bent u benieuwd naar samenwerkingsmogelijkheden, dan kunt u een e-mail versturen naar de commissaris
externe betrekkingen, die te bereiken is via
<a href="mailto:samenwerking@thalia.nu">samenwerking@thalia.nu</a>.
{% endblocktrans %}
</p>
<div id="careerpage">
<div>
<h3>{% trans "Main Partner" %}</h3>
{% if main_partner %}
<div class="th_hoofdpartner_wrapper">
<div class="th_hoofdpartner_logo alignleft">
<img src="{{ main_partner.logo.url }}" />
</div>
<h4>{{ main_partner.name }}</h4>
<p>{{ main_partner.company_profile|truncatechars:425 }}</p>
<p><a href="{% url "#" %}" class="link-style3">{% trans "Learn more" %} &raquo;</a></p>
</div>
{% endif %}
</div>
<?php endif; ?>
<!-- .portfolio-posts -->
<div class="portfolio portfolio-isotope">
<ul class="portfolio-posts row">
{% for partner in partners %}
<li class="post span4 has-overlay">
<div class="post-inner">
<div class="th_partner_logo">
{% if partner.logo %}
<img src="{{ partner.logo.url }}" alt="Logo {{ partner.name }}"/>
{% else %}
<h2>{{ partner.name }}</h2>
{% endif %}
</div>
<div class="post-body"></div>
<div class="post-overlay">
<a href="{% url "#" %}">
<div class="post-overlay-meta">
<h2>{{ partner.name }}</h2>
<p>{{ partner.company_profile|truncatechars:180 }}</p>
<span class="partner-logo-overlay-readmore">{% trans "Learn more" %} &raquo; </span>
</div>
<div class="klikbaar"></div>
</a>
</div>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endblock body %}
\ No newline at end of file
from django.conf.urls import url
from . import views
app_name = "partners"
urlpatterns = [
url('^', views.index, name='index'),
]
from django.shortcuts import render
from partners.models import Partner
from random import random
def index(request):
partners = Partner.objects.filter(is_active=True, is_main_partner=False)
context = {
'main_partner': Partner.objects.get(
is_active=True,
is_main_partner=True
),
'partners': sorted(partners, key=lambda x: random()),
}
return render(request, 'partners/index.html', context)
......@@ -21,8 +21,8 @@ main = [
{'title': _('Wiki'), 'name': '#'},
]},
{'title': _('Calendar'), 'name': '#'},
{'title': _('Career'), 'name': '#', 'submenu': [
{'title': _('Partners'), 'name': '#'},
{'title': _('Career'), 'name': 'partners:index', 'submenu': [
{'title': _('Partners'), 'name': 'partners:index'},
{'title': _('Vacancies'), 'name': '#'},
]},
{'title': _('Education'), 'name': '#', 'submenu': [
......
......@@ -52,6 +52,7 @@ INSTALLED_APPS = [
'merchandise',
'django_template_check', # This is only necessary in development
'thabloid',
'partners',
]
MIDDLEWARE = [
......
......@@ -42,6 +42,7 @@ urlpatterns = [
url(r'^become-active', TemplateView.as_view(template_name='singlepages/become_active.html'), name='become-active'),
url(r'^photos/', include('photos.urls', namespace='photos')),
])),
url(r'^career/', include('partners.urls', namespace='partners')),
url(r'^contact$', TemplateView.as_view(template_name='singlepages/contact.html'), name='contact'),
url(r'^private-thumbnails/(?P<size_fit>\d+x\d+_[01])/(?P<path>.*)', private_thumbnails, name='private-thumbnails'),
# Default login helpers
......
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