X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/3d835e01926aeec21f78df2012567cdd2f2f7f07..c32f404cd51bb4032a5b28474a4004ddc76c558d:/forum/forms/qanda.py diff --git a/forum/forms/qanda.py b/forum/forms/qanda.py index d482d01..b499cbd 100644 --- a/forum/forms/qanda.py +++ b/forum/forms/qanda.py @@ -42,7 +42,7 @@ class QuestionEditorField(EditorField): def clean(self, value): - if self.required and (len(re.sub('[ ]{2,}', ' ', value)) < settings.FORM_MIN_QUESTION_BODY): + if not bool(settings.FORM_EMPTY_QUESTION_BODY) and (len(re.sub('[ ]{2,}', ' ', value)) < settings.FORM_MIN_QUESTION_BODY): raise forms.ValidationError(_('question content must be at least %s characters') % settings.FORM_MIN_QUESTION_BODY) return value @@ -135,11 +135,17 @@ class SummaryField(forms.CharField): class FeedbackForm(forms.Form): - name = forms.CharField(label=_('Your name:'), required=False) - email = forms.EmailField(label=_('Email (not shared with anyone):'), required=True) message = forms.CharField(label=_('Your message:'), max_length=800,widget=forms.Textarea(attrs={'cols':60})) next = NextUrlField() + def __init__(self, user, *args, **kwargs): + super(FeedbackForm, self).__init__(*args, **kwargs) + if not user.is_authenticated(): + self.fields['name'] = forms.CharField(label=_('Your name:'), required=False) + self.fields['email'] = forms.EmailField(label=_('Email (not shared with anyone):'), required=True) + + + class AskForm(forms.Form): title = TitleField() text = QuestionEditorField() @@ -162,8 +168,8 @@ class AnswerForm(forms.Form): if settings.WIKI_ON: self.fields['wiki'] = WikiField() - if question.nis.wiki: - self.fields['wiki'].initial = True + #if question.nis.wiki: + # self.fields['wiki'].initial = True class RetagQuestionForm(forms.Form): @@ -276,7 +282,7 @@ NOTIFICATION_CHOICES = ( ) class SubscriptionSettingsForm(forms.ModelForm): - user = forms.IntegerField(widget=forms.HiddenInput) + enable_notifications = forms.BooleanField(widget=forms.HiddenInput, required=False) member_joins = forms.ChoiceField(widget=forms.RadioSelect, choices=NOTIFICATION_CHOICES) new_question = forms.ChoiceField(widget=forms.RadioSelect, choices=NOTIFICATION_CHOICES) new_question_watched_tags = forms.ChoiceField(widget=forms.RadioSelect, choices=NOTIFICATION_CHOICES) @@ -285,4 +291,8 @@ class SubscriptionSettingsForm(forms.ModelForm): class Meta: model = SubscriptionSettings +class UserPreferencesForm(forms.Form): + sticky_sorts = forms.BooleanField(required=False, initial=False) + +