make it possible to overrule responsible on team level
This commit is contained in:
parent
c90837a8f0
commit
8ed58664f2
20
src/teams/migrations/0012_teammember_responsible.py
Normal file
20
src/teams/migrations/0012_teammember_responsible.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -57,11 +57,19 @@ class Team(CampRelatedModel):
|
|||
else:
|
||||
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):
|
||||
user = models.ForeignKey('auth.User')
|
||||
team = models.ForeignKey('teams.Team')
|
||||
approved = models.BooleanField(default=False)
|
||||
responsible = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return '{} is {} member of team {}'.format(self.user, '' if self.approved else 'an unapproved', self.team)
|
||||
|
|
|
@ -24,7 +24,7 @@ Team: {{ team.name }} | {{ block.super }}
|
|||
<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>
|
||||
<ul>
|
||||
{% for resp in team.area.responsible.all %}
|
||||
{% for resp in team.responsible.all %}
|
||||
<li><b>{{ resp.get_full_name|default:"Unnamed" }}</b></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
|
@ -37,7 +37,7 @@ Teams | {{ block.super }}
|
|||
{{ team.area.name }} Area
|
||||
</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>
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
|
Loading…
Reference in a new issue