mirror of
				https://gitlab.com/animath/si/plateforme-corres2math.git
				synced 2025-11-04 01:32:12 +01:00 
			
		
		
		
	Compare commits
	
		
			7 Commits
		
	
	
		
			improvemen
			...
			01f6d74cae
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					01f6d74cae | ||
| 
						 | 
					a82c6b4673 | ||
| 
						 | 
					4ee5ac309d | ||
| 
						 | 
					24e1cf3845 | ||
| 
						 | 
					91640f8fb1 | ||
| 
						 | 
					ce048a30d6 | ||
| 
						 | 
					d104c2ff1f | 
@@ -88,5 +88,7 @@ class Command(BaseCommand):
 | 
			
		||||
                                        f"@{admin.matrix_username}:correspondances-maths.fr", 95)
 | 
			
		||||
            Matrix.set_room_power_level("#faq:correspondances-maths.fr",
 | 
			
		||||
                                        f"@{admin.matrix_username}:correspondances-maths.fr", 95)
 | 
			
		||||
            Matrix.set_room_power_level("#je-cherche-une-equipe:correspondances-maths.fr",
 | 
			
		||||
                                        f"@{admin.matrix_username}:correspondances-maths.fr", 95)
 | 
			
		||||
            Matrix.set_room_power_level("#flood:correspondances-maths.fr",
 | 
			
		||||
                                        f"@{admin.matrix_username}:correspondances-maths.fr", 95)
 | 
			
		||||
 
 | 
			
		||||
@@ -288,7 +288,7 @@ class Phase(models.Model):
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def current_phase(cls) -> "Phase":
 | 
			
		||||
    def current_phase(cls):
 | 
			
		||||
        """
 | 
			
		||||
        Retrieve the current phase of this day
 | 
			
		||||
        """
 | 
			
		||||
 
 | 
			
		||||
@@ -194,14 +194,13 @@
 | 
			
		||||
        {% trans "This video platform is not supported yet." as unsupported_platform %}
 | 
			
		||||
        {% include "base_modal.html" with modal_id="displayOtherSolution" modal_action="" modal_button="" modal_additional_class="modal-lg" modal_content=participation.received_participation.solution.as_iframe|default:unsupported_platform %}
 | 
			
		||||
    {% endif %}
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
    {% if current_phase.phase_number == 2 %}
 | 
			
		||||
{% if user.registration.participates and current_phase.phase_number == 2 %}
 | 
			
		||||
    {% trans "Add question" as modal_title %}
 | 
			
		||||
    {% trans "Add" as modal_button %}
 | 
			
		||||
    {% url "participation:add_question" pk=participation.pk as modal_action %}
 | 
			
		||||
    {% include "base_modal.html" with modal_id="addQuestion" modal_button_type="success" %}
 | 
			
		||||
    {% endif %}
 | 
			
		||||
 | 
			
		||||
    {% for question in participation.questions.all %}
 | 
			
		||||
        {% with number_str=forloop.counter|stringformat:"d"%}
 | 
			
		||||
            {% with modal_id="updateQuestion"|add:number_str %}
 | 
			
		||||
@@ -261,13 +260,12 @@
 | 
			
		||||
                });
 | 
			
		||||
            {% endif %}
 | 
			
		||||
 | 
			
		||||
            {% if current_phase.phase_number == 2 %}
 | 
			
		||||
            {% if user.registration.participates and current_phase.phase_number == 2 %}
 | 
			
		||||
                $('button[data-target="#addQuestionModal"]').click(function() {
 | 
			
		||||
                    let modalBody = $("#addQuestionModal div.modal-body");
 | 
			
		||||
                    if (!modalBody.html().trim())
 | 
			
		||||
                        modalBody.load("{% url "participation:add_question" pk=participation.pk %} #form-content");
 | 
			
		||||
                });
 | 
			
		||||
            {% endif %}
 | 
			
		||||
 | 
			
		||||
                {% for question in participation.questions.all %}
 | 
			
		||||
                    $('button[data-target="#updateQuestion{{ forloop.counter }}Modal"]').click(function() {
 | 
			
		||||
@@ -276,14 +274,13 @@
 | 
			
		||||
                            modalBody.load("{% url "participation:update_question" pk=question.pk %} #form-content");
 | 
			
		||||
                    });
 | 
			
		||||
 | 
			
		||||
                {% if current_phase.phase_number == 2 %}
 | 
			
		||||
                    $('button[data-target="#deleteQuestion{{ forloop.counter }}Modal"]').click(function() {
 | 
			
		||||
                        let modalBody = $("#deleteQuestion{{ forloop.counter }}Modal div.modal-body");
 | 
			
		||||
                        if (!modalBody.html().trim())
 | 
			
		||||
                            modalBody.load("{% url "participation:delete_question" pk=question.pk %} #form-content");
 | 
			
		||||
                    });
 | 
			
		||||
                {% endif %}
 | 
			
		||||
                {% endfor %}
 | 
			
		||||
            {% endif %}
 | 
			
		||||
 | 
			
		||||
            $('button[data-target="#uploadSolutionModal"]').click(function() {
 | 
			
		||||
                let modalBody = $("#uploadSolutionModal div.modal-body");
 | 
			
		||||
 
 | 
			
		||||
@@ -477,12 +477,6 @@ class UpdateQuestionView(LoginRequiredMixin, UpdateView):
 | 
			
		||||
            return super().dispatch(request, *args, **kwargs)
 | 
			
		||||
        raise PermissionDenied
 | 
			
		||||
 | 
			
		||||
    def form_valid(self, form):
 | 
			
		||||
        if not self.request.user.registration.is_admin and Phase.current_phase().phase_number != 2:
 | 
			
		||||
            form.add_error(None, _("You can update your questions now."))
 | 
			
		||||
            return self.form_invalid(form)
 | 
			
		||||
        return super().form_valid(form)
 | 
			
		||||
 | 
			
		||||
    def get_success_url(self):
 | 
			
		||||
        return reverse_lazy("participation:participation_detail", args=(self.object.participation.pk,))
 | 
			
		||||
 | 
			
		||||
@@ -505,11 +499,6 @@ class DeleteQuestionView(LoginRequiredMixin, DeleteView):
 | 
			
		||||
            return super().dispatch(request, *args, **kwargs)
 | 
			
		||||
        raise PermissionDenied
 | 
			
		||||
 | 
			
		||||
    def delete(self, request, *args, **kwargs):
 | 
			
		||||
        if not request.user.registration.is_admin and Phase.current_phase().phase_number != 2:
 | 
			
		||||
            raise PermissionDenied(_("You can update your questions now."))
 | 
			
		||||
        return super().delete(request, *args, **kwargs)
 | 
			
		||||
 | 
			
		||||
    def get_success_url(self):
 | 
			
		||||
        return reverse_lazy("participation:participation_detail", args=(self.object.participation.pk,))
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -48,9 +48,9 @@ def invite_to_public_rooms(instance: Registration, created: bool, **_):
 | 
			
		||||
    """
 | 
			
		||||
    When a user got registered, automatically invite the Matrix user into public rooms.
 | 
			
		||||
    """
 | 
			
		||||
    if not created:
 | 
			
		||||
    if created:
 | 
			
		||||
        Matrix.invite("#annonces:correspondances-maths.fr", f"@{instance.matrix_username}:correspondances-maths.fr")
 | 
			
		||||
        Matrix.invite("#faq:correspondances-maths.fr", f"@{instance.matrix_username}:correspondances-maths.fr")
 | 
			
		||||
        Matrix.invite("#je-cherche-une-equip:correspondances-maths.fr",
 | 
			
		||||
        Matrix.invite("#je-cherche-une-equipe:correspondances-maths.fr",
 | 
			
		||||
                      f"@{instance.matrix_username}:correspondances-maths.fr")
 | 
			
		||||
        Matrix.invite("#flood:correspondances-maths.fr", f"@{instance.matrix_username}:correspondances-maths.fr")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user