2017-08-07 10:10:12 +00:00
|
|
|
import bleach
|
2012-08-14 07:54:45 +00:00
|
|
|
from django import forms
|
2015-06-26 03:46:09 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2012-08-14 07:54:45 +00:00
|
|
|
|
|
|
|
from symposion.reviews.models import Review, Comment, ProposalMessage, VOTES
|
|
|
|
|
|
|
|
|
|
|
|
class ReviewForm(forms.ModelForm):
|
2017-04-24 12:50:48 +00:00
|
|
|
|
|
|
|
required_css_class = 'label-required'
|
|
|
|
|
2012-08-14 07:54:45 +00:00
|
|
|
class Meta:
|
|
|
|
model = Review
|
|
|
|
fields = ["vote", "comment"]
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-08-14 07:54:45 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(ReviewForm, self).__init__(*args, **kwargs)
|
|
|
|
self.fields["vote"] = forms.ChoiceField(
|
2014-07-30 18:19:26 +00:00
|
|
|
widget=forms.RadioSelect(),
|
|
|
|
choices=VOTES.CHOICES
|
2012-08-14 07:54:45 +00:00
|
|
|
)
|
|
|
|
|
2017-08-07 10:10:12 +00:00
|
|
|
def clean_comment(self):
|
|
|
|
comment = self.cleaned_data.get('comment')
|
|
|
|
cleaned_comment = bleach.clean(comment)
|
|
|
|
return cleaned_comment
|
|
|
|
|
2012-08-14 07:54:45 +00:00
|
|
|
|
|
|
|
class ReviewCommentForm(forms.ModelForm):
|
2017-04-24 12:50:48 +00:00
|
|
|
|
|
|
|
required_css_class = 'label-required'
|
|
|
|
|
2012-08-14 07:54:45 +00:00
|
|
|
class Meta:
|
|
|
|
model = Comment
|
|
|
|
fields = ["text"]
|
|
|
|
|
2017-08-07 10:10:12 +00:00
|
|
|
def clean_text(self):
|
|
|
|
text = self.cleaned_data.get('text')
|
|
|
|
cleaned_text = bleach.clean(text)
|
|
|
|
return cleaned_text
|
|
|
|
|
2012-08-14 07:54:45 +00:00
|
|
|
|
|
|
|
class SpeakerCommentForm(forms.ModelForm):
|
2017-04-24 12:50:48 +00:00
|
|
|
|
|
|
|
required_css_class = 'label-required'
|
|
|
|
|
2012-08-14 07:54:45 +00:00
|
|
|
class Meta:
|
|
|
|
model = ProposalMessage
|
|
|
|
fields = ["message"]
|
|
|
|
|
2017-08-07 10:10:12 +00:00
|
|
|
def clean_message(self):
|
|
|
|
message = self.cleaned_data.get('message')
|
|
|
|
cleaned_message = bleach.clean(message)
|
|
|
|
return cleaned_message
|
|
|
|
|
2012-08-14 07:54:45 +00:00
|
|
|
|
|
|
|
class BulkPresentationForm(forms.Form):
|
2017-04-24 12:50:48 +00:00
|
|
|
|
|
|
|
required_css_class = 'label-required'
|
|
|
|
|
2017-09-17 02:49:28 +00:00
|
|
|
status = forms.ChoiceField(
|
|
|
|
choices=(
|
|
|
|
('accepted', 'accepted'),
|
|
|
|
('rejected', 'rejected'),
|
|
|
|
('undecided', 'undecided'),
|
|
|
|
('standby', 'standby')
|
|
|
|
),
|
|
|
|
label="Set status to:",
|
|
|
|
help_text="Status to apply to the listed talk ids"
|
|
|
|
)
|
2012-08-14 07:54:45 +00:00
|
|
|
talk_ids = forms.CharField(
|
2015-06-26 03:46:09 +00:00
|
|
|
label=_("Talk ids"),
|
2012-08-14 07:54:45 +00:00
|
|
|
max_length=500,
|
2017-09-17 02:49:28 +00:00
|
|
|
help_text=_("Provide a comma seperated list of talk ids to update.")
|
2012-08-14 07:54:45 +00:00
|
|
|
)
|