2023-11-29 09:36:08 -08:00
|
|
|
from flask_wtf import FlaskForm
|
2023-12-13 00:04:11 -08:00
|
|
|
from wtforms import TextAreaField, SubmitField, BooleanField, StringField
|
2023-11-29 09:36:08 -08:00
|
|
|
from wtforms.validators import DataRequired, Length
|
|
|
|
from flask_babel import _, lazy_gettext as _l
|
|
|
|
|
2023-12-13 00:04:11 -08:00
|
|
|
from app.utils import MultiCheckboxField
|
|
|
|
|
2023-11-29 09:36:08 -08:00
|
|
|
|
|
|
|
class NewReplyForm(FlaskForm):
|
|
|
|
body = TextAreaField(_l('Body'), render_kw={'placeholder': 'What are your thoughts?', 'rows': 3}, validators={DataRequired(), Length(min=3, max=5000)})
|
2023-11-30 02:21:37 -08:00
|
|
|
notify_author = BooleanField(_l('Notify about replies'))
|
2023-12-13 00:04:11 -08:00
|
|
|
submit = SubmitField(_l('Comment'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ReportPostForm(FlaskForm):
|
|
|
|
reason_choices = [('1', _l('Breaks community rules')), ('7', _l('Spam')), ('2', _l('Harassment')),
|
|
|
|
('3', _l('Threatening violence')), ('4', _l('Hate / genocide')),
|
|
|
|
('6', _l('Sharing personal information')),
|
|
|
|
('5', _l('Minor abuse or sexualization')),
|
|
|
|
('8', _l('Non-consensual intimate media')),
|
|
|
|
('9', _l('Prohibited transaction')), ('10', _l('Impersonation')),
|
|
|
|
('11', _l('Copyright violation')), ('12', _l('Trademark violation')),
|
|
|
|
('13', _l('Self-harm or suicide')),
|
|
|
|
('14', _l('Other'))]
|
|
|
|
reasons = MultiCheckboxField(_l('Reason'), choices=reason_choices)
|
|
|
|
description = StringField(_l('More info'))
|
|
|
|
report_remote = BooleanField('Also send report to originating instance')
|
|
|
|
submit = SubmitField(_l('Report'))
|
|
|
|
|
|
|
|
def reasons_to_string(self, reason_data) -> str:
|
|
|
|
result = []
|
|
|
|
for reason_id in reason_data:
|
|
|
|
for choice in self.reason_choices:
|
|
|
|
if choice[0] == reason_id:
|
|
|
|
result.append(str(choice[1]))
|
|
|
|
return ', '.join(result)
|