1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-11-27 02:13:06 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Emmy D'Anello
44302a9ff4
Fix permission to access passage detail for an observer team
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-07-05 12:50:28 +02:00
Emmy D'Anello
8b3f3af2b9
Fix tests
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-07-05 12:48:47 +02:00
4 changed files with 17 additions and 17 deletions

View File

@ -71,7 +71,7 @@ class TestDraw(TestCase):
resp = await communicator.receive_json_from() resp = await communicator.receive_json_from()
self.assertEqual(resp['type'], 'alert') self.assertEqual(resp['type'], 'alert')
self.assertEqual(resp['alert_type'], 'danger') self.assertEqual(resp['alert_type'], 'danger')
self.assertEqual(resp['message'], "The sum must be equal to the number of teams: expected 12, got 3") self.assertEqual(resp['message'], "La somme doit être égale au nombre d'équipes : attendu 12, obtenu 3")
self.assertFalse(await Draw.objects.filter(tournament=self.tournament).aexists()) self.assertFalse(await Draw.objects.filter(tournament=self.tournament).aexists())
# Now start the draw # Now start the draw
@ -113,7 +113,7 @@ class TestDraw(TestCase):
resp = await communicator.receive_json_from() resp = await communicator.receive_json_from()
self.assertEqual(resp['type'], 'alert') self.assertEqual(resp['type'], 'alert')
self.assertEqual(resp['alert_type'], 'danger') self.assertEqual(resp['alert_type'], 'danger')
self.assertEqual(resp['message'], "The draw is already started.") self.assertEqual(resp['message'], "Le tirage a déjà commencé.")
draw: Draw = await Draw.objects.prefetch_related( draw: Draw = await Draw.objects.prefetch_related(
'current_round__current_pool__current_team__participation__team').aget(tournament=self.tournament) 'current_round__current_pool__current_team__participation__team').aget(tournament=self.tournament)
@ -135,7 +135,7 @@ class TestDraw(TestCase):
await communicator.send_json_to({'tid': tid, 'type': "dice", 'trigram': team.trigram}) await communicator.send_json_to({'tid': tid, 'type': "dice", 'trigram': team.trigram})
resp = await communicator.receive_json_from() resp = await communicator.receive_json_from()
self.assertEqual(resp['type'], 'alert') self.assertEqual(resp['type'], 'alert')
self.assertEqual(resp['message'], "You've already launched the dice.") self.assertEqual(resp['message'], "Vous avez déjà lancé le dé.")
# Force exactly one duplicate # Force exactly one duplicate
await td.arefresh_from_db() await td.arefresh_from_db()
@ -207,7 +207,7 @@ class TestDraw(TestCase):
await communicator.send_json_to({'tid': tid, 'type': "dice", 'trigram': trigram}) await communicator.send_json_to({'tid': tid, 'type': "dice", 'trigram': trigram})
resp = await communicator.receive_json_from() resp = await communicator.receive_json_from()
self.assertEqual(resp['type'], 'alert') self.assertEqual(resp['type'], 'alert')
self.assertEqual(resp['message'], "You've already launched the dice.") self.assertEqual(resp['message'], "Vous avez déjà lancé le dé.")
# Force exactly one duplicate # Force exactly one duplicate
await td.arefresh_from_db() await td.arefresh_from_db()
@ -254,7 +254,7 @@ class TestDraw(TestCase):
await communicator.send_json_to({'tid': tid, 'type': 'dice', 'trigram': None}) await communicator.send_json_to({'tid': tid, 'type': 'dice', 'trigram': None})
resp = await communicator.receive_json_from() resp = await communicator.receive_json_from()
self.assertEqual(resp['type'], 'alert') self.assertEqual(resp['type'], 'alert')
self.assertEqual(resp['message'], "This is not the time for this.") self.assertEqual(resp['message'], "Ce n'est pas le moment pour cela.")
# Draw a problem # Draw a problem
await communicator.send_json_to({'tid': tid, 'type': 'draw_problem'}) await communicator.send_json_to({'tid': tid, 'type': 'draw_problem'})
@ -277,7 +277,7 @@ class TestDraw(TestCase):
await communicator.send_json_to({'tid': tid, 'type': 'draw_problem'}) await communicator.send_json_to({'tid': tid, 'type': 'draw_problem'})
resp = await communicator.receive_json_from() resp = await communicator.receive_json_from()
self.assertEqual(resp['type'], 'alert') self.assertEqual(resp['type'], 'alert')
self.assertEqual(resp['message'], "This is not the time for this.") self.assertEqual(resp['message'], "Ce n'est pas le moment pour cela.")
# Reject the first problem # Reject the first problem
await communicator.send_json_to({'tid': tid, 'type': 'reject'}) await communicator.send_json_to({'tid': tid, 'type': 'reject'})

View File

@ -891,8 +891,8 @@ class Participation(models.Model):
if observer_passage: if observer_passage:
observer_text = _("<p>You will observe the solution of the team {observer} on the " observer_text = _("<p>You will observe the solution of the team {observer} on the "
"<a href='{solution_url}'>problem {problem}. " "<a href='{solution_url}'>problem {problem}. "
"You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>") "You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>")
solution_url = observer_passage.defended_solution.file.url solution_url = observer_passage.defended_solution.file.url
passage_url = reverse_lazy("participation:passage_detail", args=(observer_passage.pk,)) passage_url = reverse_lazy("participation:passage_detail", args=(observer_passage.pk,))
observer_content = format_lazy(observer_text, observer_content = format_lazy(observer_text,
@ -908,7 +908,7 @@ class Participation(models.Model):
syntheses_templates_content = f"<p>{_('Templates:')} {syntheses_templates}</p>" syntheses_templates_content = f"<p>{_('Templates:')} {syntheses_templates}</p>"
content = defender_content + opponent_content + reviewer_content + observer_content \ content = defender_content + opponent_content + reviewer_content + observer_content \
+ syntheses_templates_content + syntheses_templates_content
informations.append({ informations.append({
'title': _("First round"), 'title': _("First round"),
'type': "info", 'type': "info",
@ -949,8 +949,8 @@ class Participation(models.Model):
if observer_passage: if observer_passage:
observer_text = _("<p>You will observe the solution of the team {observer} on the " observer_text = _("<p>You will observe the solution of the team {observer} on the "
"<a href='{solution_url}'>problem {problem}. " "<a href='{solution_url}'>problem {problem}. "
"You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>") "You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>")
solution_url = observer_passage.defended_solution.file.url solution_url = observer_passage.defended_solution.file.url
passage_url = reverse_lazy("participation:passage_detail", args=(observer_passage.pk,)) passage_url = reverse_lazy("participation:passage_detail", args=(observer_passage.pk,))
observer_content = format_lazy(observer_text, observer_content = format_lazy(observer_text,
@ -966,7 +966,7 @@ class Participation(models.Model):
syntheses_templates_content = f"<p>{_('Templates:')} {syntheses_templates}</p>" syntheses_templates_content = f"<p>{_('Templates:')} {syntheses_templates}</p>"
content = defender_content + opponent_content + reviewer_content + observer_content \ content = defender_content + opponent_content + reviewer_content + observer_content \
+ syntheses_templates_content + syntheses_templates_content
informations.append({ informations.append({
'title': _("Second round"), 'title': _("Second round"),
'type': "info", 'type': "info",
@ -1008,8 +1008,8 @@ class Participation(models.Model):
if observer_passage: if observer_passage:
observer_text = _("<p>You will observe the solution of the team {observer} on the " observer_text = _("<p>You will observe the solution of the team {observer} on the "
"<a href='{solution_url}'>problem {problem}. " "<a href='{solution_url}'>problem {problem}. "
"You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>") "You can upload your synthesis sheet on <a href='{passage_url}'>this page</a>.</p>")
solution_url = observer_passage.defended_solution.file.url solution_url = observer_passage.defended_solution.file.url
passage_url = reverse_lazy("participation:passage_detail", args=(observer_passage.pk,)) passage_url = reverse_lazy("participation:passage_detail", args=(observer_passage.pk,))
observer_content = format_lazy(observer_text, observer_content = format_lazy(observer_text,
@ -1025,7 +1025,7 @@ class Participation(models.Model):
syntheses_templates_content = f"<p>{_('Templates:')} {syntheses_templates}</p>" syntheses_templates_content = f"<p>{_('Templates:')} {syntheses_templates}</p>"
content = defender_content + opponent_content + reviewer_content + observer_content \ content = defender_content + opponent_content + reviewer_content + observer_content \
+ syntheses_templates_content + syntheses_templates_content
informations.append({ informations.append({
'title': _("Second round"), 'title': _("Second round"),
'type': "info", 'type': "info",

View File

@ -1931,7 +1931,7 @@ class PassageDetailView(LoginRequiredMixin, DetailView):
or reg in passage.pool.juries.all() or reg in passage.pool.juries.all()
or reg.pools_presided.filter(tournament=passage.pool.tournament).exists()) \ or reg.pools_presided.filter(tournament=passage.pool.tournament).exists()) \
or reg.participates and reg.team \ or reg.participates and reg.team \
and reg.team.participation in [passage.defender, passage.opponent, passage.reviewer]: and reg.team.participation in [passage.defender, passage.opponent, passage.reviewer, passage.observer]:
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
return self.handle_no_permission() return self.handle_no_permission()

View File

@ -18,8 +18,8 @@ Including another URLconf
""" """
from django.conf import settings from django.conf import settings
from django.contrib import admin from django.contrib import admin
from django.utils.translation import gettext_lazy as _
from django.urls import include, path from django.urls import include, path
from django.utils.translation import gettext_lazy as _
from django.views.defaults import bad_request, page_not_found, permission_denied, server_error from django.views.defaults import bad_request, page_not_found, permission_denied, server_error
from django.views.generic import TemplateView from django.views.generic import TemplateView
from participation.views import MotivationLetterView from participation.views import MotivationLetterView