mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 13:52:17 +01:00 
			
		
		
		
	Display teams
This commit is contained in:
		@@ -126,23 +126,23 @@ class Team(models.Model):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def valid(self):
 | 
					    def valid(self):
 | 
				
			||||||
        return self.validation_status == "valid"
 | 
					        return self.validation_status == "2valid"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def waiting(self):
 | 
					    def waiting(self):
 | 
				
			||||||
        return self.validation_status == "waiting"
 | 
					        return self.validation_status == "1waiting"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def invalid(self):
 | 
					    def invalid(self):
 | 
				
			||||||
        return self.validation_status == "invalid"
 | 
					        return self.validation_status == "0invalid"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def encadrants(self):
 | 
					    def encadrants(self):
 | 
				
			||||||
        return self.users.filter(role="encadrant")
 | 
					        return self.users.all().filter(role="2coach")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def participants(self):
 | 
					    def participants(self):
 | 
				
			||||||
        return self.users.filter(role="participant")
 | 
					        return self.users.all().filter(role="3participant")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class Meta:
 | 
					    class Meta:
 | 
				
			||||||
        verbose_name = _("team")
 | 
					        verbose_name = _("team")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,6 +27,11 @@ class TournamentTable(tables.Table):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TeamTable(tables.Table):
 | 
					class TeamTable(tables.Table):
 | 
				
			||||||
 | 
					    name = tables.LinkColumn(
 | 
				
			||||||
 | 
					        "tournament:team_detail",
 | 
				
			||||||
 | 
					        args=[A("pk")],
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class Meta:
 | 
					    class Meta:
 | 
				
			||||||
        model = Team
 | 
					        model = Team
 | 
				
			||||||
        fields = ("name", "trigram", "validation_status", )
 | 
					        fields = ("name", "trigram", "validation_status", )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,11 @@
 | 
				
			|||||||
from django.urls import path
 | 
					from django.urls import path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .views import TournamentListView, TournamentDetailView
 | 
					from .views import TournamentListView, TournamentDetailView, TeamDetailView
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app_name = "tournament"
 | 
					app_name = "tournament"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
urlpatterns = [
 | 
					urlpatterns = [
 | 
				
			||||||
    path('list/', TournamentListView.as_view(), name="list"),
 | 
					    path('list/', TournamentListView.as_view(), name="list"),
 | 
				
			||||||
    path('<int:pk>/', TournamentDetailView.as_view(), name="detail"),
 | 
					    path('<int:pk>/', TournamentDetailView.as_view(), name="detail"),
 | 
				
			||||||
 | 
					    path('team/<int:pk>/', TeamDetailView.as_view(), name="team_detail"),
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,11 @@
 | 
				
			|||||||
 | 
					from django.contrib.auth.mixins import LoginRequiredMixin
 | 
				
			||||||
from django.db.models import Q
 | 
					from django.db.models import Q
 | 
				
			||||||
from django.utils.translation import gettext_lazy as _
 | 
					from django.utils.translation import gettext_lazy as _
 | 
				
			||||||
from django.views.generic import DetailView
 | 
					from django.views.generic import DetailView
 | 
				
			||||||
from django_tables2.views import SingleTableView
 | 
					from django_tables2.views import SingleTableView
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from member.models import TFJMUser
 | 
					from member.models import TFJMUser
 | 
				
			||||||
from .models import Tournament
 | 
					from .models import Tournament, Team
 | 
				
			||||||
from .tables import TournamentTable, TeamTable
 | 
					from .tables import TournamentTable, TeamTable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -49,3 +50,14 @@ class TournamentDetailView(DetailView):
 | 
				
			|||||||
        context["teams"] = TeamTable(self.object.teams.all())
 | 
					        context["teams"] = TeamTable(self.object.teams.all())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return context
 | 
					        return context
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TeamDetailView(LoginRequiredMixin, DetailView):
 | 
				
			||||||
 | 
					    model = Team
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_context_data(self, **kwargs):
 | 
				
			||||||
 | 
					        context = super().get_context_data(**kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        context["title"] = _("Information about team")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return context
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										49
									
								
								templates/tournament/team_detail.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								templates/tournament/team_detail.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					{% extends "base.html" %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% load getconfig i18n django_tables2 static %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% block content %}
 | 
				
			||||||
 | 
					    <div class="card bg-light shadow">
 | 
				
			||||||
 | 
					        <div class="card-header text-center">
 | 
				
			||||||
 | 
					            <h4>{% trans "Team" %} {{ team.name }}</h4>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div class="card-body">
 | 
				
			||||||
 | 
					            <dl class="row">
 | 
				
			||||||
 | 
					                <dt class="col-xl-6 text-right">{% trans 'name'|capfirst %}</dt>
 | 
				
			||||||
 | 
					                <dd class="col-xl-6">{{ team.name }}</dd>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <dt class="col-xl-6 text-right">{% trans 'trigram'|capfirst %}</dt>
 | 
				
			||||||
 | 
					                <dd class="col-xl-6">{{ team.trigram }}</dd>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <dt class="col-xl-6 text-right">{% trans 'tournament'|capfirst %}</dt>
 | 
				
			||||||
 | 
					                <dd class="col-xl-6">{{ team.tournament }}</dd>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <dt class="col-xl-6 text-right">{% trans 'coachs'|capfirst %}</dt>
 | 
				
			||||||
 | 
					                <dd class="col-xl-6">{{ team.encadrants.all|join:", " }}</dd>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <dt class="col-xl-6 text-right">{% trans 'participants'|capfirst %}</dt>
 | 
				
			||||||
 | 
					                <dd class="col-xl-6">{{ team.participants.all|join:", " }}</dd>
 | 
				
			||||||
 | 
					            </dl>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        {% if user.admin or user in team.tournament.organizers.all %}
 | 
				
			||||||
 | 
					            <div class="card-footer text-center">
 | 
				
			||||||
 | 
					                <button class="btn btn-secondary">{% trans "Edit team" %}</button>
 | 
				
			||||||
 | 
					                {% if user.admin and team.invalid %}
 | 
				
			||||||
 | 
					                    <button class="btn btn-danger">{% trans "Delete team" %}</button>
 | 
				
			||||||
 | 
					                {% endif %}
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					        {% endif %}
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <hr>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <h4>{% trans "Documents" %}</h4>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    {% if team.motivation_letters %}
 | 
				
			||||||
 | 
					        <div class="alert alert-info">
 | 
				
			||||||
 | 
					            {% blocktrans with version=team.motivation_letters.count %}Motivation letter (version {{ version }}):{% endblocktrans %}
 | 
				
			||||||
 | 
					            <a href="{{ team.motivation_letters.last.file.url }}">{% trans "Download" %}</a>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    {% endif %}
 | 
				
			||||||
 | 
					{% endblock %}
 | 
				
			||||||
@@ -54,6 +54,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    <hr>
 | 
					    <hr>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <h3>{% trans "Teams" %}</h3>
 | 
				
			||||||
    <div id="teams_table">
 | 
					    <div id="teams_table">
 | 
				
			||||||
        {% render_table teams %}
 | 
					        {% render_table teams %}
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user