Coverage for baibu/staff/forms.py: 100%
14 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-10-06 13:07 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-10-06 13:07 +0000
1from django import forms
2from django.utils.translation import gettext_lazy as _
4from baibu.chat.models import ChatFlag
6SUBMISSION_DECISIONS = [
7 ("verified", _("Accept")),
8 ("rejected", _("Reject")),
9 ("pending", _("Clean again")),
10]
13class SubmissionDecisionForm(forms.Form):
14 decision = forms.ChoiceField(label=_("Decision"), choices=SUBMISSION_DECISIONS, widget=forms.RadioSelect)
15 staff_notes = forms.CharField(
16 label=_("Notes for staff (not shown to the contributor)"),
17 required=False,
18 widget=forms.Textarea(attrs={"rows": 3}),
19 )
21 def __init__(self, *args, allowed=None, **kwargs):
22 super().__init__(*args, **kwargs)
23 if allowed is not None:
24 self.fields["decision"].choices = [c for c in SUBMISSION_DECISIONS if c[0] in allowed]
27class FlagDecisionForm(forms.Form):
28 decision = forms.ChoiceField(
29 label=_("Decision"),
30 choices=[(ChatFlag.Status.CONFIRMED, _("Problem confirmed")), (ChatFlag.Status.DISMISSED, _("No problem"))],
31 widget=forms.RadioSelect,
32 )
33 note = forms.CharField(label=_("Notes for staff"), required=False, widget=forms.Textarea(attrs={"rows": 3}))