make it possible to overrule responsible on team level

This commit is contained in:
Thomas Steen Rasmussen 2017-04-02 23:33:55 +02:00
parent c90837a8f0
commit 8ed58664f2
4 changed files with 30 additions and 2 deletions

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-04-02 21:26
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('teams', '0011_auto_20170402_1608'),
]
operations = [
migrations.AddField(
model_name='teammember',
name='responsible',
field=models.BooleanField(default=False),
),
]

View file

@ -57,11 +57,19 @@ class Team(CampRelatedModel):
else: else:
return "Membership Pending" return "Membership Pending"
@property
def responsible(self):
if TeamMember.objects.filter(team=self, responsible=True).exists():
return TeamMember.objects.filter(team=self, responsible=True)
else:
return self.area.responsible.all()
class TeamMember(models.Model): class TeamMember(models.Model):
user = models.ForeignKey('auth.User') user = models.ForeignKey('auth.User')
team = models.ForeignKey('teams.Team') team = models.ForeignKey('teams.Team')
approved = models.BooleanField(default=False) approved = models.BooleanField(default=False)
responsible = models.BooleanField(default=False)
def __str__(self): def __str__(self):
return '{} is {} member of team {}'.format(self.user, '' if self.approved else 'an unapproved', self.team) return '{} is {} member of team {}'.format(self.user, '' if self.approved else 'an unapproved', self.team)

View file

@ -24,7 +24,7 @@ Team: {{ team.name }} | {{ block.super }}
<h3>{{ team.area.name }} Area:</h3> <h3>{{ team.area.name }} Area:</h3>
<p>This team is under the <b>{{ team.area.name }} area</b>. The following people are responsible for the <b>{{ team.area.name }} area</b>:</p> <p>This team is under the <b>{{ team.area.name }} area</b>. The following people are responsible for the <b>{{ team.area.name }} area</b>:</p>
<ul> <ul>
{% for resp in team.area.responsible.all %} {% for resp in team.responsible.all %}
<li><b>{{ resp.get_full_name|default:"Unnamed" }}</b></li> <li><b>{{ resp.get_full_name|default:"Unnamed" }}</b></li>
{% endfor %} {% endfor %}
</ul> </ul>

View file

@ -37,7 +37,7 @@ Teams | {{ block.super }}
{{ team.area.name }} Area {{ team.area.name }} Area
</td> </td>
<td> <td>
{% for resp in team.area.responsible.all %} {% for resp in team.responsible.all %}
{{ resp.get_full_name|default:"Unnamed" }}{% if not forloop.last %},{% endif %}<br> {{ resp.get_full_name|default:"Unnamed" }}{% if not forloop.last %},{% endif %}<br>
{% endfor %} {% endfor %}
</td> </td>