Commit 1086d8f5 authored by Thom Wiggers's avatar Thom Wiggers

Merge branch 'committees/data' into 'master'

Extend committees with extra data

oprichtdatum
einddatum
contactadres

See #11 

See merge request !5
parents 78f2f657 434d2103
......@@ -6,6 +6,7 @@ skipsdist = True
changedir={toxinidir}/website
commands =
python manage.py check
python manage.py makemigrations --no-input --check
python -Wall manage.py test
deps = -r{toxinidir}/requirements.txt
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10b1 on 2016-07-13 13:58
from __future__ import unicode_literals
import datetime
from django.db import migrations, models
import django.db.models.manager
class Migration(migrations.Migration):
dependencies = [
('committees', '0001_squashed_0006_auto_20160707_1700'),
]
operations = [
migrations.AlterModelManagers(
name='committee',
managers=[
('active_committees', django.db.models.manager.Manager()),
],
),
migrations.AddField(
model_name='committee',
name='contact_email',
field=models.EmailField(default='commissie@thalia.nu', max_length=254, verbose_name='contact email address'),
preserve_default=False,
),
migrations.AddField(
model_name='committee',
name='since',
field=models.DateField(blank=True, null=True, verbose_name='founded in'),
),
migrations.AddField(
model_name='committee',
name='until',
field=models.DateField(blank=True, null=True, verbose_name='existed until'),
),
migrations.AlterField(
model_name='committeemembership',
name='since',
field=models.DateField(default=datetime.date.today, help_text='The date this member joined the committee in this role', verbose_name='Committee member since'),
),
]
import datetime
import logging
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
......@@ -12,9 +13,18 @@ from members.models import Member
logger = logging.getLogger(__name__)
class ActiveCommitteesManager(models.Manager):
"""Returns active committees only"""
def get_queryset(self):
return super().get_queryset().exclude(until__lt=timezone.now().date())
class Committee(models.Model):
"""A committee"""
active_committees = ActiveCommitteesManager()
objects = models.Manager()
name = models.CharField(
max_length=40,
verbose_name=_('Committee name'),
......@@ -40,6 +50,20 @@ class Committee(models.Model):
blank=True,
)
since = models.DateField(
_('founded in'),
null=True,
blank=True,
)
until = models.DateField(
_('existed until'),
null=True,
blank=True,
)
contact_email = models.EmailField(_('contact email address'))
def __str__(self):
return self.name
......@@ -74,7 +98,7 @@ class CommitteeMembership(models.Model):
since = models.DateField(
verbose_name=_('Committee member since'),
help_text=_('The date this member joined the committee in this role'),
auto_now_add=True,
default=datetime.date.today
)
until = models.DateField(
......
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