From 033ec1b8b5d63cf6c4ab2d11ee8d1b525acfeb61 Mon Sep 17 00:00:00 2001 From: Stephan Telling Date: Fri, 14 Apr 2017 16:13:17 +0200 Subject: [PATCH] add membership status on team detail and list view --- src/teams/templates/team_detail.html | 5 +++++ src/teams/templates/team_list.html | 16 +++++++++++++++- src/teams/templatetags/__init__.py | 0 src/teams/templatetags/teams_tags.py | 8 ++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/teams/templatetags/__init__.py create mode 100644 src/teams/templatetags/teams_tags.py diff --git a/src/teams/templates/team_detail.html b/src/teams/templates/team_detail.html index c1c0b776..c71994cb 100644 --- a/src/teams/templates/team_detail.html +++ b/src/teams/templates/team_detail.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} {% load commonmark %} +{% load teams_tags %} {% block title %} Team: {{ team.name }} | {{ block.super }} @@ -12,6 +13,10 @@ Team: {{ team.name }} | {{ block.super }} {{ team.description|unsafecommonmark }}

Currently {{ team.members.count }} people are members of this team{% if request.user in team.members.all %} (including you){% endif %}.

+{% if request.user in team.members.all %} +

Your team status: {% membershipstatus request.user team %}

+{% endif %} + {% if request.user in team.members.all %} Leave Team {% else %} diff --git a/src/teams/templates/team_list.html b/src/teams/templates/team_list.html index 6e6080e3..b9ee90c7 100644 --- a/src/teams/templates/team_list.html +++ b/src/teams/templates/team_list.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} {% load commonmark %} +{% load teams_tags %} {% block title %} Teams | {{ block.super }} @@ -21,6 +22,7 @@ Teams | {{ block.super }} Description Responsible Members + Member Actions @@ -44,9 +46,21 @@ Teams | {{ block.super }} {{ team.members.count }} {% if request.user.is_authenticated %} + {% membershipstatus request.user team as membership_status %} + + {% if membership_status == 'Membership Pending' %} + + {% else %} + {% if membership_status == 'Member' %} + + {% else %} + + {% endif %} + {% endif %} + {% if request.user in team.members.all %} - Leave + Leave {% else %} {% if team.needs_members %} Join diff --git a/src/teams/templatetags/__init__.py b/src/teams/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/teams/templatetags/teams_tags.py b/src/teams/templatetags/teams_tags.py new file mode 100644 index 00000000..090d3d66 --- /dev/null +++ b/src/teams/templatetags/teams_tags.py @@ -0,0 +1,8 @@ +from django import template + +register = template.Library() + + +@register.simple_tag +def membershipstatus(user, team): + return team.memberstatus(user)