Unverified Commit 5c28c981 authored by Joost Rijneveld's avatar Joost Rijneveld
Browse files

Simply associationdocs while creating views

parent 20669eea
from django.contrib import admin
from documents.models import AssociationDocument
from documents.models import AssociationDocumentsYear
from documents.models import GenericDocument
from documents.models import GeneralMeeting, GeneralMeetingDocument
......@@ -15,4 +15,4 @@ class GeneralMeetingAdmin(admin.ModelAdmin):
admin.site.register(GenericDocument)
admin.site.register(AssociationDocument)
admin.site.register(AssociationDocumentsYear)
# -*- coding: utf-8 -*-
# Generated by Django 1.10b1 on 2016-07-23 10:47
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
import utils.validators
class Migration(migrations.Migration):
dependencies = [
('documents', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='AssociationDocumentsYear',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('year', models.IntegerField(unique=True, validators=[django.core.validators.MinValueValidator(1990)])),
('policy_document', models.FileField(blank=True, upload_to='documents/association/', validators=[utils.validators.validate_file_extension])),
('annual_report', models.FileField(blank=True, upload_to='documents/association/', validators=[utils.validators.validate_file_extension])),
('financial_report', models.FileField(blank=True, upload_to='documents/association/', validators=[utils.validators.validate_file_extension])),
],
),
migrations.DeleteModel(
name='AssociationDocument',
),
]
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.core.validators import MinValueValidator
from utils.validators import validate_file_extension
class AssociationDocument(models.Model):
year = models.IntegerField()
file = models.FileField(
class AssociationDocumentsYear(models.Model):
year = models.IntegerField(
unique=True,
validators=[MinValueValidator(1990)],
)
policy_document = models.FileField(
upload_to='documents/association/',
validators=[validate_file_extension],
blank=True,
)
FILETYPES = (
('policy-document', _("Policy document")),
('annual-report', _("Annual report")),
('financial-report', _("Financial report")),
annual_report = models.FileField(
upload_to='documents/association/',
validators=[validate_file_extension],
blank=True,
)
filetype = models.CharField(
max_length=16,
choices=FILETYPES,
financial_report = models.FileField(
upload_to='documents/association/',
validators=[validate_file_extension],
blank=True,
)
def __str__(self):
return "{}-{}".format(self.year, self.year + 1)
class GenericDocument(models.Model):
name = models.CharField(max_length=200)
......
.unknowncontainer .post-header {
text-align:center;
height:176px; /* 176 - padding */
width:220px;
font-size:64px;
line-height: 176px;
cursor:default;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.unknowncontainer {
background:none !important;
border:2px dashed #9C9C9C;
color:#9C9C9C;
}
.policywrapper {
overflow-x:hidden;
padding-top:20px;
}
.slider-control-prev,
.slider-control-next {
cursor:pointer;
}
.slider-control-prev {
display:none;
}
ul {
margin-bottom:0px !important;
}
$(function() {
function scrollSlider(slider, direction) {
var wrapper = slider.children('.policywrapper');
var delta = direction * (slider.width() + 20); // +20 for margin
if (wrapper.scrollLeft() + delta <= 0) {
slider.children('.slider-control-prev').fadeOut(200);
}
else {
slider.children('.slider-control-prev').fadeIn(200);
}
if (wrapper.scrollLeft() + 2*delta >= wrapper.children('ul').width()) {
slider.children('.slider-control-next').fadeOut(200);
}
else {
slider.children('.slider-control-next').fadeIn(200);
}
wrapper.animate({scrollLeft: wrapper.scrollLeft() + delta});
}
$('.slider-control-next').click(function() {
scrollSlider($(this).parent(), 1);
});
$('.slider-control-prev').click(function() {
scrollSlider($(this).parent(), -1);
});
});
<li class="post span3 has-overlay">
<div class="post-inner">
<div class="post-header">
<a href="portfolio-single-wide.html">
<!-- TODO create a more meaningful thumbnail -->
<img src="https://placehold.it/200x200" />
</a>
</div>
<div class="post-body">
<h2><a href="portfolio-single-wide.html">{{ document.name }}</a></h2>
</div>
<div class="post-overlay">
<div class="post-overlay-meta">
<h2>{{ document.name }}</h2>
</div>
<ul class="post-overlay-icons">
<li>
<span></span><a href="/nyi" class="overlay-icon-link" target="_blank"></a>
</li>
</ul>
</div>
</div>
</li>
\ No newline at end of file
{% extends 'base.html' %}
{% load staticfiles %}
{% load i18n %}
{% block page_title %}{% trans "Documents" %}{% endblock %}
{% block body %}
{% comment %}TODO move this to a more appropriate block than 'body'{% endcomment %}
<link href="{% static "documents/css/policydocuments.css" %}" rel="stylesheet" type="text/css">
<h1 class="main-title">Algemeen</h1>
<p class="text-center">7 november 1990 is Thalia officieel opgericht. De bijbehorende statuten en huisregels zijn hier opvraagbaar. De statuten zijn in september 2007 voor het laatst bijgewerkt; de huisregels zijn meerdere keren veranderd. Verder zijn hier diverse andere documenten te vinden, zoals het declaratieformulier en de kantinereglementen. Lees ze door zodat we allemaal op een fijne manier door kunnen borrelen in de kantine.</p>
<div class="portfolio">
<ul class="portfolio-posts row generalcontainer">
{% for generic_document in generic_documents %}
{% include 'documents/generic.html' with document=generic_document %}
{% endfor %}
</ul>
</div>
<h1 class="main-title">Beleidsplannen &amp; Jaarverslagen</h1>
<p class="text-center">
Een aankomend bestuur van Thalia stelt voor installatie een beleidsplan op waarin wordt aangegeven wat voor koers het als bestuur wil gaan varen. Daarnaast wordt een globale planning gegeven van alle activiteiten en wordt natuurlijk een jaarbegroting opgesteld. Verder is een studievereniging verplicht een jaarverslag te maken en hierbij onder andere een financieel overzicht te verschaffen. Hierin kan je vinden hoe het jaar financieel verlopen is, welke contacten Thalia heeft onderhouden en welke activiteiten er zijn georganiseerd. In het onderstaande overzicht zijn de afgelopen beleidsplannen en jaarverslagen terug te vinden.
</p>
<div class='portfolio slider'>
<div class='policywrapper'>
<ul class="portfolio-posts row" style='width:{{ assocation_docs_width }}px'>
{% for year, docs in association_documents_years %}
{% include 'documents/policydocument.html' with documents=docs.policy name=_("Policy") year=year %}
{% endfor %}
</ul>
<ul class="portfolio-posts row" style='width:{{ assocation_docs_width }}px'>
{% for year, docs in association_documents_years %}
{% include 'documents/policydocument.html' with documents=docs.report name=_("Annual report") year=year %}
{% endfor %}
</ul>
</div>
<a class="slider-control-prev"></a>
<a class="slider-control-next"></a>
</div>
<h1 class="main-title">Algemene Ledenvergaderingen</h1>
<p class="text-center">
De Algemene Ledenvergaderingen (ALVs) kunnen door alle leden, ereleden en begunstigers worden bijgewoond. Binnen Thalia wordt tenminste twee maal per jaar een ALV georganiseerd. Naar aanleiding van deze vergaderingen worden notulen gemaakt die hieronder zijn in te zien. Zo kunnen ook de (ere)leden en begunstigers die niet aanwezig waren teruglezen wat er allemaal besproken is.
</p>
{% comment %}TODO move this to a more appropriate block than 'body'{% endcomment %}
<script type="text/javascript" src="{% static "documents/js/policydocuments.js" %}"></script>
{% endblock %}
\ No newline at end of file
{% if documents %}
<li class="post span3 has-overlay">
<div class="post-inner">
<div class="post-header">
<a href="portfolio-single-wide.html">
<!-- TODO create a more meaningful thumbnail -->
<img src="https://placehold.it/200x200" />
</a>
</div>
<div class="post-body">
<h2><a href="portfolio-single-wide.html">{{ name }} {{ year|stringformat:"d"|slice:"2:4" }}-'{{ year | add:1 | stringformat:"d" | slice:"2:4" }}</a></h2>
</div>
<div class="post-overlay">
<div class="post-overlay-meta">
<h2>{{ name }}</h2>
{{ year }} - {{ year | add:1 }}
</div>
<ul class="post-overlay-icons">
{% for document in documents %}
<li>
<a target="_blank" href="/nyi"
{% if forloop.first %}
class="overlay-icon-link"
{% else %}
class="overlay-icon-euro"
{% endif %}
></a>
</li>
{% endfor %}
</ul>
</div>
</div>
</li>
{% else %}
<li class="post span3">
<div class="post-inner unknowncontainer">
<div class="post-header">
?
</div>
<div class="post-body">
<h2>{{ name }} '{{ year | stringformat:"d" | slice:"2:4" }}-'{{ year | add:1 | stringformat:"d" | slice:"2:4" }}</h2>
</div>
</div>
</li>
{% endif %}
\ No newline at end of file
from django.conf.urls import url
from . import views
urlpatterns = [
url('^', views.index),
]
# Create your views here.
from django.shortcuts import render
from django.utils import timezone
from documents.models import AssociationDocumentsYear, GenericDocument
def index(request):
years = {x: None for x in range(1990, timezone.now().year)}
for obj in AssociationDocumentsYear.objects.all():
years[obj.year] = {'policy': [obj.policy_document],
'report': [obj.annual_report, obj.financial_report],
}
for year_docs in years.values():
if year_docs is not None:
for docs in year_docs.values():
# Duplicate list to prevent disrupting iteration by removing
for doc in list(docs):
try:
doc.file
except ValueError:
docs.remove(doc)
context = {'generic_documents': GenericDocument.objects.all(),
'association_documents_years': sorted(years.items(),
reverse=True),
# TODO ideally we want to do this dynamically in CSS
'assocation_docs_width': (220 + 20) * len(years),
}
return render(request, 'documents/index.html', context)
......@@ -22,6 +22,7 @@ urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^members/', include('members.urls')),
url(r'^nyi$', TemplateView.as_view(template_name='status/nyi.html'), name='#'),
url(r'^documents/', include('documents.urls')),
# Default login helpers
url(r'^', include('django.contrib.auth.urls')),
]
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