mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 04:22:14 +01:00 
			
		
		
		
	Display notes iff results are public
This commit is contained in:
		
							
								
								
									
										18
									
								
								apps/participation/migrations/0005_pool_results_available.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								apps/participation/migrations/0005_pool_results_available.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
# Generated by Django 3.1.7 on 2021-04-10 07:57
 | 
			
		||||
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ('participation', '0004_passage_defender_penalties'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='pool',
 | 
			
		||||
            name='results_available',
 | 
			
		||||
            field=models.BooleanField(default=False, help_text='Check this case when results become accessible to teams. They stay accessible to you. Only averages are given.', verbose_name='results available'),
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -368,6 +368,13 @@ class Pool(models.Model):
 | 
			
		||||
        help_text=_("The link of the BBB visio for this pool."),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    results_available = models.BooleanField(
 | 
			
		||||
        default=False,
 | 
			
		||||
        verbose_name=_("results available"),
 | 
			
		||||
        help_text=_("Check this case when results become accessible to teams. "
 | 
			
		||||
                    "They stay accessible to you. Only averages are given."),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def solutions(self):
 | 
			
		||||
        return Solution.objects.filter(participation__in=self.participations, final_solution=self.tournament.final)
 | 
			
		||||
 
 | 
			
		||||
@@ -539,7 +539,8 @@ class TournamentDetailView(DetailView):
 | 
			
		||||
        notes = dict()
 | 
			
		||||
        for participation in self.object.participations.all():
 | 
			
		||||
            note = sum(pool.average(participation)
 | 
			
		||||
                       for pool in self.object.pools.filter(participations=participation).all())
 | 
			
		||||
                       for pool in self.object.pools.filter(participations=participation).all()
 | 
			
		||||
                       if pool.results_available or self.request.user.registration.is_volunteer)
 | 
			
		||||
            if note:
 | 
			
		||||
                notes[participation] = note
 | 
			
		||||
        context["notes"] = sorted(notes.items(), key=lambda x: x[1], reverse=True)
 | 
			
		||||
@@ -616,12 +617,14 @@ class PoolDetailView(LoginRequiredMixin, DetailView):
 | 
			
		||||
 | 
			
		||||
        context["passages"] = PassageTable(self.object.passages.all())
 | 
			
		||||
 | 
			
		||||
        notes = dict()
 | 
			
		||||
        for participation in self.object.participations.all():
 | 
			
		||||
            note = self.object.average(participation)
 | 
			
		||||
            if note:
 | 
			
		||||
                notes[participation] = note
 | 
			
		||||
        context["notes"] = sorted(notes.items(), key=lambda x: x[1], reverse=True)
 | 
			
		||||
        if self.object.results_available or self.request.user.registration.is_volunteer:
 | 
			
		||||
            # Hide notes before the end of the turn
 | 
			
		||||
            notes = dict()
 | 
			
		||||
            for participation in self.object.participations.all():
 | 
			
		||||
                note = self.object.average(participation)
 | 
			
		||||
                if note:
 | 
			
		||||
                    notes[participation] = note
 | 
			
		||||
            context["notes"] = sorted(notes.items(), key=lambda x: x[1], reverse=True)
 | 
			
		||||
 | 
			
		||||
        return context
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user