mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 11:12:18 +01:00 
			
		
		
		
	Display passages as a table
This commit is contained in:
		@@ -6,7 +6,7 @@ from django.utils.text import format_lazy
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
import django_tables2 as tables
 | 
			
		||||
 | 
			
		||||
from .models import Note, Pool, Team, Tournament
 | 
			
		||||
from .models import Note, Passage, Pool, Team, Tournament
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# noinspection PyTypeChecker
 | 
			
		||||
@@ -98,6 +98,31 @@ class PoolTable(tables.Table):
 | 
			
		||||
        template_name = 'django_tables2/bootstrap4.html'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PassageTable(tables.Table):
 | 
			
		||||
    defender = tables.LinkColumn(
 | 
			
		||||
        "participation:passage_detail",
 | 
			
		||||
        args=[tables.A("id")],
 | 
			
		||||
        verbose_name=_("defender").capitalize,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    def render_defender(self, value):
 | 
			
		||||
        return value.team
 | 
			
		||||
 | 
			
		||||
    def render_opponent(self, value):
 | 
			
		||||
        return value.team
 | 
			
		||||
 | 
			
		||||
    def render_reporter(self, value):
 | 
			
		||||
        return value.team
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        attrs = {
 | 
			
		||||
            'class': 'table table-condensed table-striped text-center',
 | 
			
		||||
        }
 | 
			
		||||
        model = Passage
 | 
			
		||||
        fields = ('defender', 'opponent', 'reporter', 'place',)
 | 
			
		||||
        template_name = 'django_tables2/bootstrap4.html'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class NoteTable(tables.Table):
 | 
			
		||||
    jury = tables.Column(
 | 
			
		||||
        attrs={
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
{% load django_tables2 i18n %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
    <div class="card bg-light shadow">
 | 
			
		||||
@@ -25,12 +25,6 @@
 | 
			
		||||
                <dt class="col-sm-3">{% trans "Juries:" %}</dt>
 | 
			
		||||
                <dd class="col-sm-9">{{ pool.juries.all|join:", " }}</dd>
 | 
			
		||||
 | 
			
		||||
                <dt class="col-sm-3">{% trans "Passages:" %}</dt>
 | 
			
		||||
                <dd class="col-sm-9">
 | 
			
		||||
                    {% for passage in pool.passages.all %}
 | 
			
		||||
                        <a href="{{ passage.get_absolute_url }}" data-turbolinks="false">{{ passage }}{% if not forloop.last %}, {% endif %}</a>
 | 
			
		||||
                    {% endfor %}
 | 
			
		||||
                </dd>
 | 
			
		||||
                <dt class="col-sm-3">{% trans "Defended solutions:" %}</dt>
 | 
			
		||||
                <dd class="col-sm-9">
 | 
			
		||||
                    {% for passage in pool.passages.all %}
 | 
			
		||||
@@ -61,6 +55,12 @@
 | 
			
		||||
        {% endif %}
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <hr>
 | 
			
		||||
 | 
			
		||||
    <h3>{% trans "Passages" %}</h3>
 | 
			
		||||
 | 
			
		||||
    {% render_table passages %}
 | 
			
		||||
 | 
			
		||||
    {% trans "Add passage" as modal_title %}
 | 
			
		||||
    {% trans "Add" as modal_button %}
 | 
			
		||||
    {% url "participation:passage_create" pk=pool.pk as modal_action %}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ from tfjm.views import AdminMixin
 | 
			
		||||
from .forms import JoinTeamForm, NoteForm, ParticipationForm, PassageForm, PoolForm, PoolTeamsForm, \
 | 
			
		||||
    RequestValidationForm, TeamForm, TournamentForm, ValidateParticipationForm, SolutionForm, SynthesisForm
 | 
			
		||||
from .models import Note, Participation, Passage, Pool, Team, Tournament, Solution, Synthesis
 | 
			
		||||
from .tables import TeamTable, TournamentTable, ParticipationTable, PoolTable, NoteTable
 | 
			
		||||
from .tables import NoteTable, PassageTable, PoolTable, TeamTable, TournamentTable, ParticipationTable
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateTeamView(LoginRequiredMixin, CreateView):
 | 
			
		||||
@@ -489,6 +489,8 @@ class PoolDetailView(LoginRequiredMixin, DetailView):
 | 
			
		||||
    def get_context_data(self, **kwargs):
 | 
			
		||||
        context = super().get_context_data(**kwargs)
 | 
			
		||||
 | 
			
		||||
        context["passages"] = PassageTable(self.object.passages.all())
 | 
			
		||||
 | 
			
		||||
        notes = dict()
 | 
			
		||||
        for participation in self.object.participations.all():
 | 
			
		||||
            notes[participation] = self.object.average(participation)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user