mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-07-05 18:03:57 +02:00
Don't access to team participation if the team is not validated
This commit is contained in:
@ -80,6 +80,13 @@ class Participation(models.Model):
|
||||
verbose_name=_("problem number"),
|
||||
)
|
||||
|
||||
valid = models.BooleanField(
|
||||
null=True,
|
||||
default=None,
|
||||
verbose_name=_("valid"),
|
||||
help_text=_("The video got the validation of the administrators."),
|
||||
)
|
||||
|
||||
solution = models.OneToOneField(
|
||||
"participation.Video",
|
||||
on_delete=models.SET_NULL,
|
||||
|
@ -61,13 +61,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
{% if team.participation.valid %}
|
||||
<hr>
|
||||
|
||||
<div class="text-center">
|
||||
<a class="btn btn-info" href="{% url "participation:participation_detail" pk=team.participation.pk %}">
|
||||
<i class="fas fa-video"></i> {% trans "Access to team participation" %} <i class="fas fa-video"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<a class="btn btn-info" href="{% url "participation:participation_detail" pk=team.participation.pk %}">
|
||||
<i class="fas fa-video"></i> {% trans "Access to team participation" %} <i class="fas fa-video"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% else %}
|
||||
{# TODO Validate team #}
|
||||
{% endif %}
|
||||
|
||||
{% trans "Update team" as modal_title %}
|
||||
{% trans "Update" as modal_button %}
|
||||
|
@ -170,6 +170,8 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
user = request.user
|
||||
if not self.get_object().valid:
|
||||
raise PermissionDenied(_("The team is not validated yet."))
|
||||
if user.registration.is_admin or user.registration.participates\
|
||||
and user.registration.team.participation.pk == kwargs["pk"]:
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
Reference in New Issue
Block a user