From 534082ff4c052dca8145717330ee17431bf25a94 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Mon, 5 Mar 2012 17:33:08 -0300 Subject: fixed the answer count in the question page --- askbot/skins/default/templates/question/answer_tab_bar.html | 2 +- askbot/views/readers.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/askbot/skins/default/templates/question/answer_tab_bar.html b/askbot/skins/default/templates/question/answer_tab_bar.html index 632c0cf2..bebf68b8 100644 --- a/askbot/skins/default/templates/question/answer_tab_bar.html +++ b/askbot/skins/default/templates/question/answer_tab_bar.html @@ -1,6 +1,6 @@

- {% trans counter=answers|length %} + {% trans counter=answer_count %} {{counter}} Answer {% pluralize %} {{counter}} Answers diff --git a/askbot/views/readers.py b/askbot/views/readers.py index 6ad69aa3..5ff7889d 100644 --- a/askbot/views/readers.py +++ b/askbot/views/readers.py @@ -533,6 +533,7 @@ def question(request, id):#refactor - long subroutine. display question body, an 'thread': thread, 'answer' : answer_form, 'answers' : page_objects.object_list, + 'answer_count': len(answers), 'user_votes': user_votes, 'user_post_id_list': user_post_id_list, 'user_can_post_comment': user_can_post_comment,#in general -- cgit v1.2.3-1-g7c22 From 408153397de074b7fc7f13e14468559016877160 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Mon, 5 Mar 2012 21:56:31 -0300 Subject: fixed the disappearing form field values when tags are invalid, also removed the silly use-these-chars-in-tags phrase --- askbot/forms.py | 8 +++++++- askbot/views/writers.py | 17 ++++++++++++----- 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', -- cgit v1.2.3-1-g7c22