Commit 211e361a authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'committees/boards' into 'master'

Add boards

Closes #11

See merge request !6
parents 41c943c8 458853df
......@@ -2,6 +2,21 @@ from django.contrib import admin
from . import models
admin.site.register(models.Committee)
admin.site.register(models.CommitteeMembership)
# Register your models here.
@admin.register(models.Committee)
class CommitteeAdmin(admin.ModelAdmin):
list_filter = ('until',)
def get_queryset(self, request):
qs = super().get_queryset(request)
return qs.exclude(board__is_board=True)
@admin.register(models.Board)
class BoardAdmin(admin.ModelAdmin):
exclude = ('is_board',)
@admin.register(models.CommitteeMembership)
class CommitteeMembershipAdmin(admin.ModelAdmin):
pass
# -*- coding: utf-8 -*-
# Generated by Django 1.10b1 on 2016-07-13 15:00
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('committees', '0002_auto_20160713_1558'),
]
operations = [
migrations.CreateModel(
name='Board',
fields=[
('committee_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='committees.Committee')),
('is_board', models.BooleanField(default=True, verbose_name='Is this a board')),
],
bases=('committees.committee',),
),
migrations.AddField(
model_name='committeemembership',
name='role',
field=models.CharField(blank=True, help_text='The role of this member', max_length=255, null=True, verbose_name='role'),
),
]
......@@ -13,17 +13,25 @@ from members.models import Member
logger = logging.getLogger(__name__)
class ActiveCommitteesManager(models.Manager):
class CommitteeManager(models.Manager):
"""Returns committees only"""
def get_queryset(self):
return (super().get_queryset()
.exclude(board__is_board=True))
class ActiveCommitteeManager(models.Manager):
"""Returns active committees only"""
def get_queryset(self):
return super().get_queryset().exclude(until__lt=timezone.now().date())
return (super().get_queryset()
.exclude(until__lt=timezone.now().date()))
class Committee(models.Model):
"""A committee"""
active_committees = ActiveCommitteesManager()
objects = models.Manager()
active_committees = ActiveCommitteeManager()
objects = CommitteeManager()
name = models.CharField(
max_length=40,
......@@ -72,6 +80,20 @@ class Committee(models.Model):
verbose_name_plural = _('committees')
class BoardManager(models.Manager):
def get_queryset(self):
return super().get_queryset().filter(is_board=True)
class Board(Committee):
objects = BoardManager()
is_board = models.BooleanField(
verbose_name=_('Is this a board'),
default=True,
)
class ActiveMembershipManager(models.Manager):
"""Get only active memberships"""
def get_queryset(self):
......@@ -115,6 +137,14 @@ class CommitteeMembership(models.Model):
default=False,
)
role = models.CharField(
_('role'),
help_text=_('The role of this member'),
max_length=255,
blank=True,
null=True,
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
......
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