2024-02-17 20:05:57 +13:00
|
|
|
from flask import request, g
|
|
|
|
from flask_login import current_user
|
|
|
|
from flask_wtf import FlaskForm
|
|
|
|
from wtforms import StringField, SubmitField, TextAreaField, BooleanField, HiddenField, SelectField, FileField
|
|
|
|
from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length, Optional
|
|
|
|
from flask_babel import _, lazy_gettext as _l
|
|
|
|
|
|
|
|
from app import db
|
2024-02-19 15:01:53 +13:00
|
|
|
from app.utils import MultiCheckboxField
|
2024-02-17 20:05:57 +13:00
|
|
|
|
|
|
|
|
|
|
|
class AddReply(FlaskForm):
|
|
|
|
message = TextAreaField(_l('Message'), validators=[DataRequired(), Length(min=1, max=5000)], render_kw={'placeholder': 'Type a reply here...'})
|
|
|
|
submit = SubmitField(_l('Reply'))
|
2024-02-19 15:01:53 +13:00
|
|
|
|
|
|
|
|
|
|
|
class ReportConversationForm(FlaskForm):
|
|
|
|
reason_choices = [('7', _l('Spam')),
|
|
|
|
('2', _l('Harassment')),
|
|
|
|
('3', _l('Threatening violence')),
|
|
|
|
('4', _l('Promoting hate / genocide')),
|
|
|
|
('15', _l('Misinformation / disinformation')),
|
|
|
|
('16', _l('Racism, sexism, transphobia')),
|
|
|
|
('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)
|