serializers.py 1.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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):
Wietse Kuipers's avatar
Wietse Kuipers committed
24
        return reverse('members:profile', kwargs={'pk': instance.pk})
25
26
27
28
29
30
31

    def _title(self, instance):
        return instance.display_name()

    def _description(self, instance):
        membership = instance.current_membership
        if membership and membership.type == 'honorary':
Thom Wiggers's avatar
Thom Wiggers committed
32
            return membership.get_type_display()
33
34
35
36
37
38
39
40
41
42
        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'