Commit c3ce8af6 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Merge branch '641-lecture-year' into 'master'

Resolve "It is unclear if the year field on documents in the backend refers to the first or last year of the academic year."

Closes #641

See merge request !838
parents 0629c95c a8e901a0
"""Registers admin interfaces for the documents module"""
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from documents.forms import GeneralMeetingForm
from documents.forms import AnnualDocumentForm, GeneralMeetingForm
from documents.models import (AnnualDocument, AssociationDocument,
GeneralMeeting, Minutes,
MiscellaneousDocument)
......@@ -24,11 +25,33 @@ class GeneralMeetingAdmin(TranslatedModelAdmin):
list_filter = ('datetime',)
class LectureYearFilter(admin.SimpleListFilter):
"""Filter the memberships on those started or ended in a lecture year"""
title = _('lecture year')
parameter_name = 'lecture_year'
def lookups(self, request, model_admin):
first_year = AnnualDocument.objects.order_by('year').first().year
last_year = AnnualDocument.objects.order_by('year').last().year
return [(year, '{}-{}'.format(year, year+1))
for year in range(last_year, first_year-1, -1)]
def queryset(self, request, queryset):
if not self.value():
return queryset
year = int(self.value())
return queryset.filter(year=year)
@admin.register(AnnualDocument)
class AnnualDocument(TranslatedModelAdmin):
class AnnualDocumentAdmin(TranslatedModelAdmin):
"""Manage the annual documents"""
form = AnnualDocumentForm
fields = ('file', 'subcategory', 'year', 'members_only',)
list_filter = ('year', 'created', 'last_updated',)
list_filter = (LectureYearFilter, 'created', 'last_updated',)
@admin.register(AssociationDocument)
......
"""The forms defined by the documents package"""
from django import forms
from django.contrib import admin
from django.utils import timezone
from documents.models import GeneralMeeting
from documents.models import AnnualDocument, GeneralMeeting
from utils.snippets import datetime_to_lectureyear
class AnnualDocumentForm(forms.ModelForm):
class Meta:
model = AnnualDocument
exclude = ()
widgets = {
'year': forms.Select
}
def current_year():
return datetime_to_lectureyear(timezone.now())
def year_choices():
current = datetime_to_lectureyear(timezone.now())
return [
(year, "{}-{}".format(year, year+1))
for year in range(current + 1, 1989, -1)
]
year = forms.TypedChoiceField(coerce=int, choices=year_choices,
initial=current_year)
class GeneralMeetingForm(forms.ModelForm):
......
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-07 16:24+0200\n"
"PO-Revision-Date: 2018-06-07 16:25+0200\n"
"POT-Creation-Date: 2018-06-13 21:48+0200\n"
"PO-Revision-Date: 2018-06-13 21:48+0200\n"
"Last-Translator: Joost Rijneveld <joost@joostrijneveld.nl>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -16,109 +16,111 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.0.7\n"
"X-Generator: Poedit 2.0.6\n"
#: apps.py:7 models.py:13 templates/documents/index.html:6
#: admin.py:30
msgid "lecture year"
msgstr "college jaar"
#: apps.py:7 models.py:14 templates/documents/index.html:6
#: templates/documents/index.html:7
msgid "Documents"
msgstr "Documenten"
#: models.py:12
#: models.py:13
msgid "Document"
msgstr "Document"
#: models.py:16 models.py:63
#: models.py:17 models.py:65
msgid "Annual document"
msgstr "Jaarlijks document"
#: models.py:17
#: models.py:18
msgid "Association document"
msgstr "Verenigingsdocument"
#: models.py:18 models.py:163 models.py:164
#: models.py:19 models.py:171 models.py:172
#: templates/documents/meetingyear.html:38
msgid "Minutes"
msgstr "Notulen"
#: models.py:19 models.py:124
#: models.py:20 models.py:130
msgid "Miscellaneous document"
msgstr "Overig document"
#: models.py:24
#: models.py:25
msgid "name"
msgstr "naam"
#: models.py:29
#: models.py:30
msgid "created"
msgstr "aangemaakt op"
#: models.py:34
#: models.py:35
msgid "last updated"
msgstr "laatst aangemaakt op"
#: models.py:41 models.py:76
#: models.py:42 models.py:78
msgid "category"
msgstr "categorie"
#: models.py:47
#: models.py:48
msgid "file"
msgstr "bestand"
#: models.py:53
#: models.py:54
msgid "members only"
msgstr "alleen voor leden"
#: models.py:64
#: models.py:66
msgid "Annual documents"
msgstr "Jaarlijkse documenten"
#: models.py:68 templates/documents/index.html:50
#: models.py:70 templates/documents/index.html:50
msgid "Annual report"
msgstr "Jaarverslag"
#: models.py:69
#: models.py:71
msgid "Financial report"
msgstr "Financieel jaarverslag"
#: models.py:70
#: models.py:72
msgid "Policy document"
msgstr "Beleidsdocument"
#: models.py:81
#: models.py:83
msgid "year"
msgstr "jaar"
#: models.py:106
#: models.py:110
msgid "Miscellaneous association document"
msgstr "Overig verenigingsdocument"
#: models.py:107
#: models.py:111
msgid "Miscellaneous association documents"
msgstr "Overige verenigingsdocumenten"
#: models.py:125
#: models.py:131
msgid "Miscellaneous documents"
msgstr "Overig documenten"
#: models.py:137
#: models.py:144
msgid "General meeting"
msgstr "Algemene ledenvergadering"
#: models.py:138
#: models.py:145
msgid "General meetings"
msgstr "Algemene ledenvergaderingen"
#: models.py:143
#, fuzzy
#| msgid "Documents"
#: models.py:150
msgid "documents"
msgstr "Documenten"
msgstr "documenten"
#: models.py:148
#: models.py:155
msgid "datetime"
msgstr "tijdstip"
#: models.py:153
#: models.py:160
msgid "location"
msgstr "locatie"
......
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