Commit 4f154408 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Merge branch 'master' into hotfix/remove_basetitle

parents a59478b3 32edc69d
......@@ -3,7 +3,8 @@ django-localflavor==1.3
Pillow
django-static-precompiler>=1.4,<2
django-sendfile==0.3.10
django-template-check # This should be in dev-requirements somehow
django-template-check>=0.3.0 # This should be in dev-requirements somehow
bleach==1.4.3
django-tinymce==2.3.0
pytz
djangorestframework==3.4.4
......@@ -6,7 +6,7 @@ skipsdist = True
changedir={toxinidir}/website
commands =
python manage.py check
python manage.py templatecheck
python manage.py templatecheck --project-only
python manage.py makemigrations --no-input --check --dry-run
python -Wall manage.py test
deps = -r{toxinidir}/requirements.txt
......
from django.utils import timezone
from django.urls import reverse
from rest_framework import serializers
from events.models import Event
class CalenderJSSerializer(serializers.ModelSerializer):
class Meta:
fields = (
'start', 'end', 'all_day', 'is_birthday',
'url', 'title', 'description',
'background_color', 'text_color', 'target_blank'
)
start = serializers.SerializerMethodField('_start')
end = serializers.SerializerMethodField('_end')
all_day = serializers.SerializerMethodField('_all_day')
is_birthday = serializers.SerializerMethodField('_is_birthday')
url = serializers.SerializerMethodField('_url')
title = serializers.SerializerMethodField('_title')
description = serializers.SerializerMethodField('_description')
background_color = serializers.SerializerMethodField('_background_color')
text_color = serializers.SerializerMethodField('_text_color')
target_blank = serializers.SerializerMethodField('_target_blank')
def _start(self, instance):
return timezone.localtime(instance.start)
def _end(self, instance):
return timezone.localtime(instance.end)
def _all_day(self, instance):
return False
def _is_birthday(self, instance):
return False
def _url(self, instance):
raise NotImplementedError
def _title(self, instance):
return instance.title
def _description(self, instance):
return instance.description
def _background_color(self, instance):
pass
def _text_color(self, instance):
pass
def _target_blank(self, instance):
return False
class EventSerializer(CalenderJSSerializer):
class Meta(CalenderJSSerializer.Meta):
model = Event
def _url(self, instance):
return reverse('#')
from rest_framework import routers
from events.api import viewsets
router = routers.SimpleRouter()
router.register(r'events', viewsets.EventViewset)
urlpatterns = router.urls
from rest_framework import viewsets
from rest_framework.exceptions import ParseError
from rest_framework.response import Response
from django.utils import timezone
from datetime import datetime
from events.api.serializers import EventSerializer
from events.models import Event
class EventViewset(viewsets.ViewSet):
queryset = Event.objects.all()
def list(self, request):
try:
start = timezone.make_aware(
datetime.strptime(request.query_params['start'], '%Y-%m-%d')
)
end = timezone.make_aware(
datetime.strptime(request.query_params['end'], '%Y-%m-%d')
)
except:
raise ParseError(detail='start or end query parameters invalid')
queryset = self.queryset.filter(
end__gte=start,
start__lte=end,
published=True
)
serializer = EventSerializer(queryset, many=True)
return Response(serializer.data)
from django.urls import reverse
from events.api.serializers import CalenderJSSerializer
from members.models import Member
class MemberBirthdaySerializer(CalenderJSSerializer):
class Meta(CalenderJSSerializer.Meta):
model = Member
def _start(self, instance):
return instance.birthday
def _end(self, instance):
pass
def _all_day(self, instance):
return True
def _is_birthday(self, instance):
return True
def _url(self, instance):
return reverse('#')
def _title(self, instance):
return instance.display_name()
def _description(self, instance):
membership = instance.current_membership
if membership and membership.type == 'honorary':
return instance.membership.get_type_display()
return ''
def _background_color(self, instance):
membership = instance.current_membership
if membership and membership.type == 'honorary':
return '#E62272'
return 'black'
def _text_color(self, instance):
return 'white'
from rest_framework import routers
from members.api import viewsets
router = routers.SimpleRouter()
router.register(r'members', viewsets.MemberViewset)
urlpatterns = router.urls
from django.utils import timezone
from rest_framework import viewsets
from rest_framework.decorators import list_route
from datetime import datetime
import copy
from rest_framework.exceptions import ParseError
from rest_framework.response import Response
from members.api.serializers import MemberBirthdaySerializer
from members.models import Member
class MemberViewset(viewsets.ViewSet):
queryset = Member.objects.all()
def _get_birthdays(self, member, start, end):
birthdays = []
start_year = max(start.year, member.birthday.year)
for year in range(start_year, end.year + 1):
bday = copy.deepcopy(member)
bday.birthday = bday.birthday.replace(year=year)
if start.date() <= bday.birthday <= end.date():
birthdays.append(bday)
return birthdays
@list_route()
def birthdays(self, request):
try:
start = timezone.make_aware(
datetime.strptime(request.query_params['start'], '%Y-%m-%d')
)
end = timezone.make_aware(
datetime.strptime(request.query_params['end'], '%Y-%m-%d')
)
except:
raise ParseError(detail='start or end query parameters invalid')
queryset = (
Member
.active_members
.with_birthdays_in_range(start, end)
.filter(show_birthday=True)
)
queryset.prefetch_related('membership_get')
all_birthdays = [
self._get_birthdays(m, start, end)
for m in queryset.all()
]
birthdays = [x for sublist in all_birthdays for x in sublist]
serializer = MemberBirthdaySerializer(birthdays, many=True)
return Response(serializer.data)
......@@ -130,5 +130,15 @@
"direct_debit_authorized": false,
"bank_account": ""
}
},
{
"model": "members.membership",
"pk": 1,
"fields": {
"type": "member",
"user": 1,
"since": "1980-01-01",
"until": null
}
}
]
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-06 20:46+0200\n"
"PO-Revision-Date: 2016-07-06 20:47+0200\n"
"POT-Creation-Date: 2016-08-24 20:42+0200\n"
"PO-Revision-Date: 2016-08-24 20:42+0200\n"
"Last-Translator: Thom Wiggers <thom@thomwiggers.nl>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -16,178 +16,166 @@ 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 1.8.7.1\n"
"X-Generator: Poedit 1.8.8\n"
#: members/models.py:17
msgid "Benefactor"
msgstr "Begunstiger"
#: members/models.py:18
msgid "Member"
msgstr "Lid"
#: members/models.py:19
msgid "Honorary Member"
msgstr "Erelid"
#: admin.py:24
msgid "membership type"
msgstr "lidtype"
#: members/models.py:22
#: models.py:30
msgid "Computing Science"
msgstr "Informatica"
#: members/models.py:23
#: models.py:31
msgid "Information Sciences"
msgstr "Informatiekunde"
#: members/models.py:35
#: models.py:43
msgid "Study programme"
msgstr "Studie"
#: members/models.py:44
msgid "Enter a valid student- of e/z/u-number."
#: models.py:52
msgid "Enter a valid student- or e/z/u-number."
msgstr "Voer een geldig student- of e/z/u-nummer in."
#: members/models.py:52
msgid "Membership type"
msgstr "Lidtype"
#: members/models.py:56
msgid "Registration year"
#: models.py:58
msgid "Starting year"
msgstr "Eerste lidmaatschapsjaar"
#: members/models.py:57
msgid "The year this member first became a part of Thalia"
msgstr "Het jaar waarin dit lid voor het eerst lid werd"
#: models.py:59
msgid "The year this member started studying."
msgstr "Het jaar waarop dit lid begon met studeren."
#: members/models.py:61
msgid "Expiration date of membership"
msgstr "Verloopdatum van lidmaatschap"
#: members/models.py:62
msgid "Let the membership expire after this time"
msgstr "Laat het lidmaatschap na deze datum verlopen"
#: models.py:89
msgid "Is this user currently active"
msgstr "Is deze user op dit moment actief"
#: members/models.py:73
#: models.py:103
msgid "Include the house number"
msgstr "Inclusief huisnummer"
#: members/models.py:75
#: models.py:105
msgid "Street and house number"
msgstr "Straat en huisnummer"
#: members/models.py:81
#: models.py:111
msgid "Second address line"
msgstr "Tweede adresregel"
#: members/models.py:88
#: models.py:118
msgid "Postal code"
msgstr "Postcode"
#: members/models.py:94
#: models.py:124
msgid "City"
msgstr "Woonplaats"
#: members/models.py:100
#: models.py:130
msgid "Phone number"
msgstr "Telefoonnummer"
#: members/models.py:101
#: models.py:131
msgid "Enter a phone number so Thalia may reach you"
msgstr "Voer een telefoonnummer in zodat Thalia je kan bereiken"
#: members/models.py:104 members/models.py:126
#: models.py:134 models.py:156
msgid "Please enter a valid phone number"
msgstr "Voer svp een geldig telefoonnummer in"
#: members/models.py:114
#: models.py:144
msgid "Emergency contact name"
msgstr "Contact voor noodgevallen"
#: members/models.py:115
#: models.py:145
msgid "Who should we contact in case of emergencies"
msgstr "Wie Thalia moet bereiken in bij noodgevallen"
#: members/models.py:122
#: models.py:152
msgid "Emergency contact phone number"
msgstr "Telefoonnummer noodcontact"
#: members/models.py:123
#: models.py:153
msgid "The phone number for the emergency contact"
msgstr "Het telefoonummer van de noodcontact"
#: members/models.py:135
#: models.py:165
msgid "Birthday"
msgstr "Verjaardag"
#: members/models.py:140
#: models.py:170
msgid "Display birthday"
msgstr "Laat verjaardag zien"
#: members/models.py:142
#: models.py:172
msgid "Show the birthday on your profile page and in the birthday calendar"
msgstr ""
"Laat de verjaardag op je profielpagina en in de verjaardagskalender zien"
#: members/models.py:149
#: models.py:179
msgid "Website"
msgstr "Website"
#: members/models.py:150
#: models.py:180
msgid "Website to display on your profile page"
msgstr "Website om op je profiel te linken"
#: members/models.py:156
#: models.py:186
msgid "Profile text"
msgstr "Profieltekst"
#: members/models.py:157
#: models.py:187
msgid "Text to display on your profile"
msgstr "Tekst om te laten zien op je profielpagina"
#: members/models.py:163
#: models.py:193
msgid "Nickname"
msgstr "Bijnaam"
#: members/models.py:170
#: models.py:200
msgid "How to display name"
msgstr "Weergave naam"
#: members/models.py:171
#: models.py:201
msgid "Show full name"
msgstr "Volledige naam"
#: members/models.py:172
#: models.py:202
msgid "Show only nickname"
msgstr "Alleen initialen"
#: members/models.py:173
#: models.py:203
msgid "Show initials and last name"
msgstr "Alleen initialen en achternaam"
#: members/models.py:174
#: models.py:204
msgid "Show name like \"John 'nickname' Doe\""
msgstr "Laat zien als \"John 'bijnaam' Doe\""
#: members/models.py:175
#: models.py:205
msgid "Show nickname and last name"
msgstr "Laat bijnaam en achternaam zien"
#: members/models.py:182
#: models.py:210
msgid "Photo"
msgstr "Foto"
#: models.py:219
msgid "Preferred language"
msgstr "Voorkeurstaal"
#: members/models.py:183
#: models.py:220
msgid "Preferred language for e.g. news letters"
msgstr "Voorkeurstaal voor b.v.b. nieuwsbrieven"
#: members/models.py:190
#: models.py:227
msgid "Receive opt-in mailings"
msgstr "Ontvang opt-in mailings"
#: members/models.py:191
#: models.py:228
msgid "Receive mailings about vacancies and events from Thalia's sponsors."
msgstr "Ontvang mailings over vacatures en evenmenten van Thalia's sponsoren"
#: members/models.py:199
#: models.py:236
msgid ""
"Yes, I want Thalia to take the membership fees from my bank account through "
"direct debit for each year."
......@@ -195,43 +183,87 @@ msgstr ""
"Ja, ik wil dat Thalia verschuldigde lidmaatschapsgelden elk jaar van mijn "
"bankrekening afschrijft."
#: members/models.py:202
#: models.py:239
msgid "No, I will pay the contribution myself"
msgstr "Nee, ik zal de contributie zelf betalen"
#: members/models.py:203
#: models.py:240
msgid "Direct debit"
msgstr "Automatische afschijving"
#: members/models.py:204
#: models.py:241
msgid "Each year, have Thalia take the membership fees from my bank account"
msgstr ""
"Laat Thalia elk jaar het lidmaatschapsgeld van mijn bankrekening afschrijven"
#: members/models.py:210
#: models.py:247
msgid "Bank account"
msgstr "Bankrekening"
#: members/models.py:211
#: models.py:248
msgid "Bank account for direct debit"
msgstr "Bankrekening voor automatische afschrijving"
#: members/models.py:224
msgid "Is this user currently active"
msgstr "Is deze user op dit moment actief"
#: members/models.py:241
#: models.py:268
msgid "Display name"
msgstr "Weergavenaam"
#: members/templates/members/index.html:8
#: models.py:280
msgid "Member"
msgstr "Lid"
#: models.py:281
msgid "Supporter"
msgstr "Begunstiger"
#: models.py:282
msgid "Honorary Member"
msgstr "Erelid"
#: models.py:287
msgid "Membership type"
msgstr "Lidtype"
#: models.py:296
msgid "User"
msgstr "Gebruiker"
#: models.py:300
msgid "Membership since"
msgstr "Lid sinds"
#: models.py:301
msgid "The date the member started holding this membership."
msgstr "De datum waarop het lid dit lidmaatschap is begonnen."
#: models.py:306
msgid "Membership until"
msgstr "Lid tot"
#: models.py:307
msgid "The date the member stops holding this membership."
msgstr "De datum waarop het lid dit lidmaatschap beëindigd."
#: templates/members/index.html:9
msgid "These are the current members:"
msgstr "Dit zijn de huidige leden:"
#: members/templates/members/index.html:13
#: templates/members/index.html:14
msgid "Er zijn geen leden"
msgstr "Er zijn geen leden"
#~ msgid "Foto"
#~ msgstr "Foto"
#~ msgid "Benefactor"
#~ msgstr "Begunstiger"
#~ msgid "Expiration date of membership"
#~ msgstr "Verloopdatum van lidmaatschap"
#~ msgid "Let the membership expire after this time"
#~ msgstr "Laat het lidmaatschap na deze datum verlopen"
#~ msgid "English"
#~ msgstr "Engels"
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-24 18:24
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('members', '0004_auto_20160805_1435'),
]
operations = [
migrations.AlterField(
model_name='member',
name='student_number',
field=models.CharField(blank=True, max_length=8, null=True, validators=[django.core.validators.RegexValidator(message='Enter a valid student- or e/z/u-number.', regex='(s\\d{7}|[ezu]\\d{6,7})')]),
),
]