diff --git a/src/teams/migrations/0003_auto_20170401_2227.py b/src/teams/migrations/0003_auto_20170401_2227.py new file mode 100644 index 00000000..996bc866 --- /dev/null +++ b/src/teams/migrations/0003_auto_20170401_2227.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-04-01 20:27 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('teams', '0002_auto_20170327_2208'), + ] + + operations = [ + migrations.RenameField( + model_name='teammember', + old_name='leader', + new_name='responsible', + ), + ] diff --git a/src/teams/migrations/0004_team_sub_team_of.py b/src/teams/migrations/0004_team_sub_team_of.py new file mode 100644 index 00000000..a15e336e --- /dev/null +++ b/src/teams/migrations/0004_team_sub_team_of.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-04-01 20:32 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('teams', '0003_auto_20170401_2227'), + ] + + operations = [ + migrations.AddField( + model_name='team', + name='sub_team_of', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='teams.Team'), + ), + ] diff --git a/src/teams/models.py b/src/teams/models.py index 440a1d76..57b47c3c 100644 --- a/src/teams/models.py +++ b/src/teams/models.py @@ -15,6 +15,7 @@ class Team(CampRelatedModel): camp = models.ForeignKey('camps.Camp') description = models.TextField() members = models.ManyToManyField('auth.User', through='teams.TeamMember') + sub_team_of = models.ForeignKey('self', null=True, blank=True, related_name="sub_teams") def __str__(self): return '{} ({})'.format(self.name, self.camp) @@ -32,7 +33,7 @@ class Team(CampRelatedModel): class TeamMember(models.Model): user = models.ForeignKey('auth.User') team = models.ForeignKey('teams.Team') - leader = models.BooleanField(default=False) + responsible = models.BooleanField(default=False) def __str__(self): return '{} ({})'.format(self.user, self.team) diff --git a/src/teams/templates/team_detail.html b/src/teams/templates/team_detail.html index 71c252c8..3d7b186f 100644 --- a/src/teams/templates/team_detail.html +++ b/src/teams/templates/team_detail.html @@ -11,4 +11,15 @@ Team: {{ team.name }} | {{ block.super }} {{ team.description|unsafecommonmark }} + +{% if team.sub_teams.exists %} +
+

Subteams:

+ +{% endif %} + {% endblock %} diff --git a/src/teams/templates/team_list.html b/src/teams/templates/team_list.html index e76fe746..596423a4 100644 --- a/src/teams/templates/team_list.html +++ b/src/teams/templates/team_list.html @@ -8,7 +8,7 @@ Teams | {{ block.super }} {% block content %} {% if teams %} - +
@@ -24,7 +24,27 @@ Teams | {{ block.super }} {% endfor %} diff --git a/src/teams/views.py b/src/teams/views.py index 700ae1ba..a89661d9 100644 --- a/src/teams/views.py +++ b/src/teams/views.py @@ -7,7 +7,7 @@ from .models import Team class TeamListView(CampViewMixin, ListView): template_name = "team_list.html" - model = Team + queryset = Team.objects.filter(sub_team_of=None) context_object_name = 'teams'
Name + {% if team.sub_teams.exists %} +
+ {% endif %} {{ team.description|unsafecommonmark|truncatewords:50 }} + + {% if team.sub_teams.exists %} +
+ Subteams: +
    + {% for sub_team in team.sub_teams.all %} +
  • {{ sub_team.name }}
  • + {% endfor %} +
+
+ +
+ + + {% endif %}