diff options
author | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-08-29 16:39:40 -0600 |
---|---|---|
committer | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-08-29 16:39:40 -0600 |
commit | 34f21ec2519a819d865583f046235366300176f9 (patch) | |
tree | ed1fd35cdbf53fb155eef5cb61c6ae179979eb40 /askbot/forms.py | |
parent | e00b048a7f850f1b7dfa25988db1fd48cba8b637 (diff) | |
download | askbot-34f21ec2519a819d865583f046235366300176f9.tar.gz askbot-34f21ec2519a819d865583f046235366300176f9.tar.bz2 askbot-34f21ec2519a819d865583f046235366300176f9.zip |
moved forms, partially broken due to Tag/Group model migration
Diffstat (limited to 'askbot/forms.py')
-rw-r--r-- | askbot/forms.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/askbot/forms.py b/askbot/forms.py index 2711d9fa..70d70448 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -12,6 +12,7 @@ from django.contrib.auth.models import User from django_countries import countries from askbot.utils.forms import NextUrlField, UserNameField from askbot.mail import extract_first_email_address +from askbot.models.tag import get_groups from recaptcha_works.fields import RecaptchaField from askbot.conf import settings as askbot_settings from askbot.conf import get_tag_display_filter_strategy_choices @@ -896,6 +897,7 @@ ASK_BY_EMAIL_SUBJECT_HELP = _( '[tag1, tag2, tag3,...] question title' ) +#widgetforms class AskWidgetForm(forms.Form, FormWithHideableFields): '''Simple form with just the title to ask a question''' @@ -921,6 +923,45 @@ class AskWidgetForm(forms.Form, FormWithHideableFields): else: self.fields['text'].min_length = askbot_settings.MIN_QUESTION_BODY_LENGTH +class CreateAskWidgetForm(forms.Form, FormWithHideableFields): + title = forms.CharField(max_length=100) + + inner_style = forms.CharField( + widget=forms.Textarea, + required=False + ) + outer_style = forms.CharField( + widget=forms.Textarea, + required=False + ) + + def __init__(self, *args, **kwargs): + from askbot.models import Tag + super(CreateAskWidgetForm, self).__init__(*args, **kwargs) + self.fields['group'] = forms.ModelChoiceField(queryset=get_groups().exclude( + name__startswith='_internal'), required=False) + self.fields['tag'] = forms.ModelChoiceField(queryset=Tag.objects.get_content_tags(), + required=False) + if not askbot_settings.GROUPS_ENABLED: + self.hide_field('group') + +class CreateQuestionWidgetForm(forms.Form, FormWithHideableFields): + title = forms.CharField(max_length=100) + question_number = forms.CharField(initial='7') + tagnames = forms.CharField(label=_('tags'), max_length=50) + search_query = forms.CharField(max_length=50, required=False) + order_by = forms.ChoiceField(choices=const.SEARCH_ORDER_BY, + initial='-addet_at') + style = forms.CharField(widget=forms.Textarea, + initial=const.DEFAULT_QUESTION_STYLE, + required=False) + + def __init__(self, *args, **kwargs): + super(CreateQuestionWidgetForm, self).__init__(*args, **kwargs) + self.fields['tagnames'] = TagNamesField() + self.fields['group'] = forms.ModelChoiceField(queryset=get_groups().exclude(name__startswith='_internal'), + required=False) + class AskByEmailForm(forms.Form): """:class:`~askbot.forms.AskByEmailForm` validates question data, where question was posted |