Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Jun 9, 2024
1 parent a2328e0 commit 9415f90
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions questions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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}),
Expand Down Expand Up @@ -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
8 changes: 8 additions & 0 deletions www/questions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9415f90

Please sign in to comment.