Add "My Team" link to tournament navigation for authenticated users

main^2
Razmig Sarkissian 2 weeks ago
parent 174c2988b2
commit e215ca7e1d
  1. 10
      tournaments/templates/tournaments/navigation_tournament.html
  2. 5
      tournaments/templatetags/tournament_tags.py

@ -1,3 +1,5 @@
{% load tournament_tags %}
<nav class="margin10"> <nav class="margin10">
<a href="{% url 'index' %}" class="topmargin5 orange">Accueil</a> <a href="{% url 'index' %}" class="topmargin5 orange">Accueil</a>
@ -9,6 +11,14 @@
<a href="{% url 'tournament-live' tournament.id %}" class="topmargin5 orange">Live</a> <a href="{% url 'tournament-live' tournament.id %}" class="topmargin5 orange">Live</a>
{% endif %} {% endif %}
{% if tournament.will_start_soon and request.user.is_authenticated %}
{% with user_team=tournament|get_user_team:request.user %}
{% if user_team %}
<a href="{% url 'team-details' tournament.id user_team.id %}" class="topmargin5 orange">Mon équipe</a>
{% endif %}
{% endwith %}
{% endif %}
{% if tournament.display_prog %} {% if tournament.display_prog %}
<a href="{% url 'tournament-prog' tournament.id %}" class="topmargin5 orange">Programmation</a> <a href="{% url 'tournament-prog' tournament.id %}" class="topmargin5 orange">Programmation</a>
{% endif %} {% endif %}

@ -6,6 +6,11 @@ register = template.Library()
def get_player_status(tournament, user): def get_player_status(tournament, user):
return tournament.get_player_registration_status_by_licence(user) return tournament.get_player_registration_status_by_licence(user)
@register.filter
def get_user_team(tournament, user):
"""Get the team registration for a user in a tournament"""
return tournament.get_user_team_registration(user)
@register.filter @register.filter
def lookup(dictionary, key): def lookup(dictionary, key):
"""Template filter to lookup dictionary values by key""" """Template filter to lookup dictionary values by key"""

Loading…
Cancel
Save