diff --git a/symposion/teams/templatetags/__init__.py b/symposion/teams/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/symposion/teams/templatetags/teams_tags.py b/symposion/teams/templatetags/teams_tags.py new file mode 100644 index 00000000..253da49a --- /dev/null +++ b/symposion/teams/templatetags/teams_tags.py @@ -0,0 +1,45 @@ +from django import template + +from symposion.teams.models import Team + +register = template.Library() + + +class AvailableTeamsNode(template.Node): + + @classmethod + def handle_token(cls, parser, token): + bits = token.split_contents() + if len(bits) == 3 and bits[1] == "as": + return cls(bits[2]) + else: + raise template.TemplateSyntaxError("%r takes 'as var'" % bits[0]) + + def __init__(self, context_var): + self.context_var = context_var + + def render(self, context): + request = context["request"] + teams = [] + for team in Team.objects.all(): + print team + state = team.get_state_for_user(request.user) + if team.access == "open": + if state in [None, "invited"]: + teams.append(team) + elif team.access == "application": + if state in [None, "invited", "applied"]: + teams.append(team) + elif team.access == "invitation": + if state == "invited": + teams.append(team) + context[self.context_var] = teams + return u"" + + +@register.tag +def available_teams(parser, token): + """ + {% available_teams as available_teams %} + """ + return AvailableTeamsNode.handle_token(parser, token) diff --git a/symposion/teams/views.py b/symposion/teams/views.py index 5b2622e7..de657b31 100644 --- a/symposion/teams/views.py +++ b/symposion/teams/views.py @@ -11,6 +11,7 @@ def team_detail(request, slug): team = get_object_or_404(Team, slug=slug) if team.get_state_for_user(request.user) != "manager": raise Http404() - + return render(request, "teams/team_detail.html", { + "team": team, }) diff --git a/symposion_project/templates/dashboard.html b/symposion_project/templates/dashboard.html index 15624294..5d8ba586 100644 --- a/symposion_project/templates/dashboard.html +++ b/symposion_project/templates/dashboard.html @@ -2,6 +2,7 @@ {% load i18n %} {% load proposal_tags %} +{% load teams_tags %} {% block head_title %}Dashboard{% endblock %} @@ -144,6 +145,10 @@ {% endfor %} {% endif %} + {% available_teams as available_teams %} + {% for team in available_team %} + {{ team }} + {% endfor %} {% endblock %} diff --git a/symposion_project/templates/teams/team_detail.html b/symposion_project/templates/teams/team_detail.html new file mode 100644 index 00000000..c0723be6 --- /dev/null +++ b/symposion_project/templates/teams/team_detail.html @@ -0,0 +1,8 @@ +{% extends "site_base.html" %} + +{% block head_title %}{{ team.name }}{% endblock %} + +{% block body %} +

{{ team.name }}

+ +{% endblock %}