mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-07-08 14:50:19 +02:00
Test questions, 100% coverage
This commit is contained in:
@ -2,7 +2,7 @@ import re
|
||||
|
||||
from bootstrap_datepicker_plus import DateTimePickerInput
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.exceptions import ObjectDoesNotExist, ValidationError
|
||||
from django.db.models import Q
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
@ -128,7 +128,7 @@ class SendParticipationForm(forms.ModelForm):
|
||||
super().__init__(*args, **kwargs)
|
||||
try:
|
||||
self.fields["sent_participation"].initial = self.instance.sent_participation
|
||||
except: # No sent participation
|
||||
except ObjectDoesNotExist: # No sent participation
|
||||
pass
|
||||
self.fields["sent_participation"].queryset = Participation.objects.filter(
|
||||
~Q(pk=self.instance.pk) & Q(problem=self.instance.problem, valid=True)
|
||||
@ -155,6 +155,11 @@ class QuestionForm(forms.ModelForm):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["question"].widget.attrs.update({"placeholder": _("How did you get the idea to ...?")})
|
||||
|
||||
def clean(self):
|
||||
if Phase.current_phase().phase_number != 2:
|
||||
self.add_error(None, _("You can only create or update a question during the second phase."))
|
||||
return super().clean()
|
||||
|
||||
class Meta:
|
||||
model = Question
|
||||
fields = ('question',)
|
||||
|
Reference in New Issue
Block a user