diff options
Diffstat (limited to 'forum')
-rw-r--r-- | forum/skins/default/templates/badge.html | 4 | ||||
-rw-r--r-- | forum/skins/default/templates/base.html | 3 | ||||
-rw-r--r-- | forum/skins/default/templates/user.html | 6 | ||||
-rw-r--r-- | forum/skins/default/templates/user_recent.html | 3 | ||||
-rwxr-xr-x | forum/views/meta.py | 8 | ||||
-rw-r--r-- | forum/views/readers.py | 33 | ||||
-rwxr-xr-x | forum/views/users.py | 12 | ||||
-rwxr-xr-x | forum/views/writers.py | 14 |
8 files changed, 56 insertions, 27 deletions
diff --git a/forum/skins/default/templates/badge.html b/forum/skins/default/templates/badge.html index 12a12512..99d74e1b 100644 --- a/forum/skins/default/templates/badge.html +++ b/forum/skins/default/templates/badge.html @@ -1,4 +1,4 @@ -{% extends "base_content.html" %} +{% extends "base.html" %} <!-- template badge.html --> {% load i18n %} {% load extra_tags %} @@ -23,7 +23,7 @@ <div> {% if badge.awarded_count %} <p style="float:left"><span class="count">{{ awards|length|intcomma }}</span> - <strong>{% trans "The users have been awarded with badges:" %}</strong></p> + <strong>{% blocktrans count awards|length as num_awardees %}user received this badge:{% plural %}users received this badge:{% endblocktrans %}</strong></p> {% endif %} </div> <div id="award-list" style="clear:both;margin-left:20px;line-height:25px;"> diff --git a/forum/skins/default/templates/base.html b/forum/skins/default/templates/base.html index ed674fef..a4e4ceed 100644 --- a/forum/skins/default/templates/base.html +++ b/forum/skins/default/templates/base.html @@ -38,6 +38,7 @@ </script> {% endif %} {% if active_tab != "tags" and active_tab != "users" %} + {% comment %}start asking question with title from search query{% endcomment %} <script type="text/javascript"> $(document).ready(function(){ $('#nav_ask').click( @@ -50,6 +51,7 @@ ); }); </script> + {% comment %}focus input on the search bar{% endcomment %} <script type="text/javascript"> $(document).ready(function() { {% if active_tab != "ask" %} @@ -59,7 +61,6 @@ {% endif %} }); </script> - {% endif %} {% block forejs %} {% endblock %} diff --git a/forum/skins/default/templates/user.html b/forum/skins/default/templates/user.html index 8fd9e267..833c2058 100644 --- a/forum/skins/default/templates/user.html +++ b/forum/skins/default/templates/user.html @@ -18,11 +18,7 @@ <script type="text/javascript"> var viewUserID = {{view_user.id}}; $().ready(function(){ - {% ifequal view_user request.user%} - $("#nav_profile").attr('className',"on"); - {% else %} - $("#nav_users").attr('className',"on"); - {% endifequal %} + $("#nav_users").attr('className',"on"); }); </script> {% block userjs %} diff --git a/forum/skins/default/templates/user_recent.html b/forum/skins/default/templates/user_recent.html index 85957599..78347993 100644 --- a/forum/skins/default/templates/user_recent.html +++ b/forum/skins/default/templates/user_recent.html @@ -2,6 +2,7 @@ <!-- user_recent.html --> {% load extra_tags %} {% load humanize %} +{% load i18n %} {% block usercontent %} <div style="padding-top:5px;font-size:13px;"> {% for act in activities %} @@ -12,7 +13,7 @@ </div> <div style="float:left;overflow:hidden;"> {% ifequal act.type_id 7 %} - <a href="{{act.badge.get_absolute_url}}" title="{{ act.badge.get_type_display }} : {% act.badge.description %}" class="medal"><span class="badge{{ act.badge.type }}">●</span> {% trans act.badge.name %}</a> + <a href="{{act.badge.get_absolute_url}}" title="{{ act.badge.get_type_display }} : {% trans act.badge.description %}" class="medal"><span class="badge{{ act.badge.type }}">●</span> {% trans act.badge.name %}</a> {% else %} <span class="post-type-{{ act.type_id }}"><a href="{{ act.title_link }}">{{ act.title }}</a></span> {% if act.summary %}<span class="revision-summary">{{ act.summary }}</span>{% endif %} diff --git a/forum/views/meta.py b/forum/views/meta.py index 40f3d394..af5fe6df 100755 --- a/forum/views/meta.py +++ b/forum/views/meta.py @@ -14,6 +14,7 @@ def about(request): def faq(request): data = { + 'view_name':'faq', 'gravatar_faq_url': reverse('faq') + '#gravatar', #'send_email_key_url': reverse('send_email_key'), 'ask_question_url': reverse('ask'), @@ -21,7 +22,7 @@ def faq(request): return render_to_response('faq.html', data, context_instance=RequestContext(request)) def feedback(request): - data = {} + data = {'view_name':'feedback'} form = None if request.method == "POST": form = FeedbackForm(request.POST) @@ -43,7 +44,7 @@ def feedback(request): feedback.CANCEL_MESSAGE=_('We look forward to hearing your feedback! Please, give it next time :)') def privacy(request): - return render_to_response('privacy.html', context_instance=RequestContext(request)) + return render_to_response('privacy.html', {'view_name':'privacy'}, context_instance=RequestContext(request)) def logout(request):#refactor/change behavior? #currently you click logout and you get @@ -54,6 +55,7 @@ def logout(request):#refactor/change behavior? #why not just show a message: you are logged out of askbot, but #if you really want to log out -> go to your openid provider return render_to_response('logout.html', { + 'view_name':'logout', 'next' : get_next_url(request), }, context_instance=RequestContext(request)) @@ -66,6 +68,7 @@ def badges(request):#user status/reputation system return render_to_response('badges.html', { 'badges' : badges, + 'view_name': 'badges', 'mybadges' : my_badges, 'feedback_faq_url' : reverse('feedback'), }, context_instance=RequestContext(request)) @@ -85,6 +88,7 @@ def badge(request, id): ).distinct('id') return render_to_response('badge.html', { + 'view_name': badge, 'awards' : awards, 'badge' : badge, }, context_instance=RequestContext(request)) diff --git a/forum/views/readers.py b/forum/views/readers.py index 677cbd67..338da62b 100644 --- a/forum/views/readers.py +++ b/forum/views/readers.py @@ -134,6 +134,8 @@ def questions(request):#a view generating listing of questions, used by 'unanswe #todo: organize variables by type return render_to_response('questions.html', { + 'view_name': 'questions', + 'active_tab': 'questions', 'questions' : questions, 'contributors' : contributors, 'author_name' : meta_data.get('author_name',None), @@ -182,6 +184,8 @@ def search(request): #generates listing of questions matching a search query - i else: raise Http404 +#todo: eliminate this - need to go through templates to make sure +#that there are no urls pointing here def tag(request, tag):#stub generates listing of questions tagged with a single tag return questions(request, tagname=tag) @@ -210,6 +214,7 @@ def tags(request):#view showing a listing of available tags - plain list tags = objects_list.page(objects_list.num_pages) return render_to_response('tags.html', { + "view_name":"tags", "active_tab": "tags", "tags" : tags, "stag" : stag, @@ -341,17 +346,19 @@ def question(request, id):#refactor - long subroutine. display question body, an question_view.save() return render_to_response('question.html', { - "question" : question, - "question_vote" : question_vote, - "question_comment_count":question.comments.count(), - "answer" : answer_form, - "answers" : page_objects.object_list, - "user_answer_votes": user_answer_votes, - "tags" : question.tags.all(), - "tab_id" : view_id, - "favorited" : favorited, - "similar_questions" : Question.objects.get_similar_questions(question), - "context" : { + 'view_name': 'question', + 'active_tab': 'questions', + 'question' : question, + 'question_vote' : question_vote, + 'question_comment_count':question.comments.count(), + 'answer' : answer_form, + 'answers' : page_objects.object_list, + 'user_answer_votes': user_answer_votes, + 'tags' : question.tags.all(), + 'tab_id' : view_id, + 'favorited' : favorited, + 'similar_questions' : Question.objects.get_similar_questions(question), + 'context' : { 'is_paginated' : True, 'pages': objects_list.num_pages, 'page': page, @@ -389,6 +396,8 @@ def question_revisions(request, id): } revisions[i].summary = _('initial version') return render_to_response('revisions_question.html', { + 'view_name':'question_revisions', + 'active_tab':'questions', 'post': post, 'revisions': revisions, }, context_instance=RequestContext(request)) @@ -408,6 +417,8 @@ def answer_revisions(request, id): revisions[i].diff = revisions[i].text revisions[i].summary = _('initial version') return render_to_response('revisions_answer.html', { + 'view_name':'answer_revisions', + 'active_tab':'questions', 'post': post, 'revisions': revisions, }, context_instance=RequestContext(request)) diff --git a/forum/views/users.py b/forum/views/users.py index 113c46e6..76e41008 100755 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -102,6 +102,7 @@ def moderate_user(request, id): response = HttpResponseForbidden(mimetype="application/json") return response +#non-view function def set_new_email(user, new_email, nomessage=False): if new_email != user.email: user.email = new_email @@ -142,6 +143,7 @@ def edit_user(request, id): else: form = EditUserForm(user) return render_to_response('user_edit.html', { + 'active_tab': 'users', 'form' : form, 'gravatar_faq_url' : reverse('faq') + '#gravatar', }, context_instance=RequestContext(request)) @@ -268,6 +270,7 @@ def user_stats(request, user_id, user_view): moderate_user_form = None return render_to_response(user_view.template_file,{ + 'active_tab':'users', 'moderate_user_form': moderate_user_form, "tab_name" : user_view.id, "tab_description" : user_view.tab_description, @@ -533,6 +536,7 @@ def user_recent(request, user_id, user_view): activities.sort(lambda x,y: cmp(y.time, x.time)) return render_to_response(user_view.template_file,{ + 'active_tab':'users', "tab_name" : user_view.id, "tab_description" : user_view.tab_description, "page_title" : user_view.page_title, @@ -686,6 +690,7 @@ def user_responses(request, user_id, user_view): responses.sort(lambda x,y: cmp(y.time, x.time)) return render_to_response(user_view.template_file,{ + 'active_tab':'users', "tab_name" : user_view.id, "tab_description" : user_view.tab_description, "page_title" : user_view.page_title, @@ -748,6 +753,7 @@ def user_votes(request, user_id, user_view): votes.extend(answer_votes) votes.sort(lambda x,y: cmp(y['voted_at'], x['voted_at'])) return render_to_response(user_view.template_file,{ + 'active_tab':'users', "tab_name" : user_view.id, "tab_description" : user_view.tab_description, "page_title" : user_view.page_title, @@ -788,6 +794,7 @@ def user_reputation(request, user_id, user_view): reps = '[%s]' % reps return render_to_response(user_view.template_file, { + 'active_tab':'users', "tab_name": user_view.id, "tab_description": user_view.tab_description, "page_title": user_view.page_title, @@ -839,6 +846,7 @@ def user_favorites(request, user_id, user_view): 'la_user_bronze', 'la_user_reputation') return render_to_response(user_view.template_file,{ + 'active_tab':'users', "tab_name" : user_view.id, "tab_description" : user_view.tab_description, "page_title" : user_view.page_title, @@ -873,6 +881,7 @@ def user_email_subscriptions(request, user_id, user_view): tag_filter_form = TagFilterSelectionForm(instance=user) action_status = None return render_to_response(user_view.template_file,{ + 'active_tab':'users', 'tab_name':user_view.id, 'tab_description':user_view.tab_description, 'page_title':user_view.page_title, @@ -963,7 +972,7 @@ def user(request, id, slug=None): return func(request, id, user_view) @login_required -def account_settings(request): +def account_settings(request):#todo: is this actually used? """ index pages to changes some basic account settings : - change password @@ -980,6 +989,7 @@ def account_settings(request): is_openid = False return render_to_response('account_settings.html', { + 'active_tab':'users', 'msg': msg, 'is_openid': is_openid }, context_instance=RequestContext(request)) diff --git a/forum/views/writers.py b/forum/views/writers.py index 57c8e043..86831ba3 100755 --- a/forum/views/writers.py +++ b/forum/views/writers.py @@ -7,7 +7,7 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.contrib.auth.decorators import login_required from django.http import HttpResponseRedirect, HttpResponse, HttpResponseForbidden, Http404 from django.template import RequestContext -from django.utils.html import * +from django.utils.html import * #todo: remove import * in favor of explicit imports from django.utils import simplejson from django.utils.translation import ugettext as _ from django.core.urlresolvers import reverse @@ -91,7 +91,7 @@ def ask(request):#view used to ask a new question added_at = datetime.datetime.now() #todo: move this to clean_title - title = strip_tags(form.cleaned_data['title'].strip()) + title = form.cleaned_data['title'].strip() wiki = form.cleaned_data['wiki'] #todo: move this to clean_tagnames tagnames = form.cleaned_data['tags'].strip() @@ -131,11 +131,14 @@ def ask(request):#view used to ask a new question question.save() return HttpResponseRedirect(reverse('user_signin_new_question')) else: + #this branch is for the initial load of ask form form = AskForm() if 'title' in request.GET: - raw_title = request.GET['title'] - form.initial['title'] = strip_tags(strip_entities(raw_title)) + #normally this title is inherited from search query + #but it is possible to ask with a parameter title in the url query + form.initial['title'] = request.GET['title'] else: + #attempt to extract title from previous search query search_state = request.session.get('search_state',None) if search_state: query = search_state.query @@ -180,6 +183,7 @@ def _retag_question(request, question):#non-url subview of edit question - just else: form = RetagQuestionForm(question) return render_to_response('question_retag.html', { + 'active_tab': 'questions', 'question': question, 'form' : form, 'tags' : _get_tags_cache_json(), @@ -222,6 +226,7 @@ def _edit_question(request, question):#non-url subview of edit_question - just e revision_form = RevisionForm(question, latest_revision) form = EditQuestionForm(question, latest_revision) return render_to_response('question_edit.html', { + 'active_tab': 'questions', 'question': question, 'revision_form': revision_form, 'form' : form, @@ -265,6 +270,7 @@ def edit_answer(request, id): revision_form = RevisionForm(answer, latest_revision) form = EditAnswerForm(answer, latest_revision) return render_to_response('answer_edit.html', { + 'active_tab': 'questions', 'answer': answer, 'revision_form': revision_form, 'form': form, |