diff --git a/core/constants.py b/core/constants.py index fba4cbb3..5cf90e9e 100644 --- a/core/constants.py +++ b/core/constants.py @@ -74,6 +74,10 @@ (VALIDATION_STATUS_REMOVED, _("Removed")), ] VALIDATION_STATUS_CHOICE_LIST = [vs[0] for vs in VALIDATION_STATUS_CHOICES] +QUESTION_CREATE_VALIDATION_STATUS_CHOICES = [ + (VALIDATION_STATUS_DRAFT, _("Draft")), + (VALIDATION_STATUS_TO_VALIDATE, _("To validate")), +] COMMENT_TYPE_NEW_QUESTION = "NEW_QUESTION" COMMENT_TYPE_NEW_QUIZ = "NEW_QUIZ" diff --git a/questions/forms.py b/questions/forms.py index 6439f716..3e863464 100644 --- a/questions/forms.py +++ b/questions/forms.py @@ -6,7 +6,7 @@ from tags.models import Tag -QUESTION_READONLY_FORM_FIELDS = ["validation_status"] +QUESTION_READONLY_FORM_FIELDS = [] # "validation_status" QUESTION_HIDDEN_FORM_FIELDS = ["answer_image_url"] QUESTION_REQUIRED_FORM_FIELDS = [ "answer_choice_a", @@ -22,7 +22,7 @@ class QuestionCreateForm(forms.ModelForm): class Meta: model = Question - fields = QUESTION_FORM_FIELDS + QUESTION_READONLY_FORM_FIELDS + fields = QUESTION_FORM_FIELDS + QUESTION_READONLY_FORM_FIELDS + ["validation_status"] widgets = { "text": forms.Textarea(attrs={"rows": 1}), "hint": forms.Textarea(attrs={"rows": 1}), @@ -50,4 +50,3 @@ def __init__(self, *args, **kwargs): class QuestionEditForm(QuestionCreateForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields["validation_status"].disabled = False diff --git a/www/questions/views.py b/www/questions/views.py index bcb21357..733481d5 100644 --- a/www/questions/views.py +++ b/www/questions/views.py @@ -252,6 +252,14 @@ class QuestionCreateView(ContributorUserRequiredMixin, SuccessMessageMixin, Crea success_url = reverse_lazy("questions:list") # success_message = "" + def get_form(self, *args, **kwargs): + """ + Override some default form field behavior + """ + form = super().get_form(self.form_class) + form.fields["validation_status"].choices = constants.QUESTION_CREATE_VALIDATION_STATUS_CHOICES + return form + def form_valid(self, form): self.object = form.save(commit=False) self.object.author = self.request.user