summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askbot/forms.py8
-rw-r--r--askbot/views/writers.py17
2 files changed, 19 insertions, 6 deletions
diff --git a/askbot/forms.py b/askbot/forms.py
index 4b72180c..8c5fd082 100644
--- a/askbot/forms.py
+++ b/askbot/forms.py
@@ -106,6 +106,8 @@ class TitleField(forms.CharField):
self.initial = ''
def clean(self, value):
+ if value is None:
+ value = ''
if len(value) < askbot_settings.MIN_TITLE_LENGTH:
msg = ungettext_lazy(
'title must be > %d character',
@@ -149,6 +151,8 @@ class EditorField(forms.CharField):
self.initial = ''
def clean(self, value):
+ if value is None:
+ value = ''
if len(value) < self.min_length:
msg = ungettext_lazy(
self.length_error_template_singular,
@@ -248,7 +252,9 @@ class TagNamesField(forms.CharField):
#todo - this needs to come from settings
tagname_re = re.compile(const.TAG_REGEX, re.UNICODE)
if not tagname_re.search(tag):
- raise forms.ValidationError(_('use-these-chars-in-tags'))
+ raise forms.ValidationError(_(
+ 'In tags, please use letters, numbers and characters "-+.#"'
+ ))
#only keep unique tags
if tag not in entered_tags:
entered_tags.append(tag)
diff --git a/askbot/views/writers.py b/askbot/views/writers.py
index ab7f581e..0ee4b7ef 100644
--- a/askbot/views/writers.py
+++ b/askbot/views/writers.py
@@ -216,8 +216,8 @@ def ask(request):#view used to ask a new question
user can start posting a question anonymously but then
must login/register in order for the question go be shown
"""
- if request.method == "POST":
- form = forms.AskForm(request.POST)
+ form = forms.AskForm(request.REQUEST)
+ if request.method == 'POST':
if form.is_valid():
timestamp = datetime.datetime.now()
title = form.cleaned_data['title']
@@ -257,10 +257,17 @@ def ask(request):#view used to ask a new question
ip_addr = request.META['REMOTE_ADDR'],
)
return HttpResponseRedirect(url_utils.get_login_url())
- else:
+
+ if request.method == 'GET':
form = forms.AskForm()
- if 'title' in request.GET: # prepopulate title (usually from search query on main page)
- form.initial['title'] = request.GET['title']
+
+ form.initial = {
+ 'title': request.REQUEST.get('title', ''),
+ 'text': request.REQUEST.get('text', ''),
+ 'tags': request.REQUEST.get('tags', ''),
+ 'wiki': request.REQUEST.get('wiki', False),
+ 'is_anonymous': request.REQUEST.get('is_anonymous', False),
+ }
data = {
'active_tab': 'ask',