diff options
-rwxr-xr-x | forum/models/question.py | 11 | ||||
-rw-r--r-- | forum/skins/default/templates/base.html | 29 | ||||
-rw-r--r-- | forum/skins/default/templates/questions.html | 35 | ||||
-rwxr-xr-x | forum/templatetags/extra_tags.py | 7 | ||||
-rw-r--r-- | forum/views/readers.py | 4 |
5 files changed, 61 insertions, 25 deletions
diff --git a/forum/models/question.py b/forum/models/question.py index 683f7a3c..8c9d7cc9 100755 --- a/forum/models/question.py +++ b/forum/models/question.py @@ -169,6 +169,17 @@ class QuestionManager(models.Manager): qs = qs.distinct() return qs, meta_data + def get_question_and_answer_contributors(self, question_list): + answer_list = [] + question_list = list(question_list)#important for MySQL, b/c it does not support + #the query in return statement below + for q in question_list: + answer_list.extend(list(q.answers.all())) + return User.objects.filter( + Q(questions__in=question_list) \ + | Q(answers__in=answer_list) + ).distinct() + def update_tags(self, question, tagnames, user): """ Updates Tag associations for a question to match the given diff --git a/forum/skins/default/templates/base.html b/forum/skins/default/templates/base.html index 0b85e7fb..ed674fef 100644 --- a/forum/skins/default/templates/base.html +++ b/forum/skins/default/templates/base.html @@ -39,16 +39,27 @@ {% endif %} {% if active_tab != "tags" and active_tab != "users" %} <script type="text/javascript"> - $('#nav_ask').click( - function(){ - alert('hullo'); - var starting_title = $('#keywords').attr('value'); - alert('tittle is ' + starting_title); - window.location.href = $(this).attr('href') + '?' - + starting_title; - } - ); + $(document).ready(function(){ + $('#nav_ask').click( + function(){ + var starting_title = $('#keywords').attr('value'); + var new_url = $(this).attr('href') + '?title=' + starting_title; + window.location.href = new_url; + return false; + } + ); + }); </script> + <script type="text/javascript"> + $(document).ready(function() { + {% if active_tab != "ask" %} + $('#keywords').focus(); + {% else %} + $('#id_title').focus(); + {% endif %} + }); + </script> + {% endif %} {% block forejs %} {% endblock %} diff --git a/forum/skins/default/templates/questions.html b/forum/skins/default/templates/questions.html index f864180f..8e09b185 100644 --- a/forum/skins/default/templates/questions.html +++ b/forum/skins/default/templates/questions.html @@ -236,19 +236,30 @@ {% endblock %}
{% block sidebar %}
-{% if request.user.is_authenticated %}
-{% include "tag_selector.html" %}
-{% endif %}
-<div class="boxC">
- <h3 class="subtitle">{% trans "Related tags" %}</h3>
- <div class="tags">
- {% for tag in tags %}
- <a rel="tag" title="{% blocktrans with tag.name as tag_name %}see questions tagged '{{ tag_name }}'{% endblocktrans %}" href="{% url questions %}?tags={{tag.name|urlencode}}">{{ tag.name }}</a>
- <span class="tag-number">× {{ tag.used_count|intcomma }}</span>
- <br />
+ {% if contributors %}
+ <div class="boxC">
+ <h3 class="subtitle">{% trans "Contributors" %}</h3>
+ {% for person in contributors %}
+ {% gravatar person 48 %}
{% endfor %}
- </div>
-</div>
+ </div>
+ {% endif %}
+ {% if request.user.is_authenticated %}
+ {% include "tag_selector.html" %}
+ {% endif %}
+
+ {% if tags %}
+ <div class="boxC">
+ <h3 class="subtitle">{% trans "Related tags" %}</h3>
+ <div class="tags">
+ {% for tag in tags %}
+ <a rel="tag" title="{% blocktrans with tag.name as tag_name %}see questions tagged '{{ tag_name }}'{% endblocktrans %}" href="{% url questions %}?tags={{tag.name|urlencode}}">{{ tag.name }}</a>
+ <span class="tag-number">× {{ tag.used_count|intcomma }}</span>
+ <br />
+ {% endfor %}
+ </div>
+ </div>
+ {% endif %}
{% endblock %}
<!-- end questions.html -->
diff --git a/forum/templatetags/extra_tags.py b/forum/templatetags/extra_tags.py index 22dafe5a..86f2e9df 100755 --- a/forum/templatetags/extra_tags.py +++ b/forum/templatetags/extra_tags.py @@ -28,7 +28,8 @@ GRAVATAR_TEMPLATE = ( 'width="%(size)s" height="%(size)s" ' 'src="http://www.gravatar.com/avatar/%(gravatar_hash)s' '?s=%(size)s&d=identicon&r=PG" ' - 'alt="%(username)s\'s gravatar image" /></a>') + 'title="%(username)s" ' + 'alt="%(alt_text)s" /></a>') @register.simple_tag def gravatar(user, size): @@ -44,11 +45,13 @@ def gravatar(user, size): user_id = get_from_dict_or_object(user, 'id') slug = slugify(username) user_profile_url = reverse('user_profile', kwargs={'id':user_id,'slug':slug}) + #safe_username = template.defaultfilters.urlencode(username) return mark_safe(GRAVATAR_TEMPLATE % { 'user_profile_url': user_profile_url, 'size': size, 'gravatar_hash': gravatar, - 'username': template.defaultfilters.urlencode(username), + 'alt_text': _('%(username)s gravatar image') % {'username': username}, + 'username': username, }) MAX_FONTSIZE = 18 diff --git a/forum/views/readers.py b/forum/views/readers.py index 5b1de34c..677cbd67 100644 --- a/forum/views/readers.py +++ b/forum/views/readers.py @@ -130,12 +130,12 @@ def questions(request):#a view generating listing of questions, used by 'unanswe tags_autocomplete = _get_tags_cache_json() - #todo!!!! - #contributors = #User.objects.get_related_to_questions + contributors = Question.objects.get_question_and_answer_contributors(questions.object_list) #todo: organize variables by type return render_to_response('questions.html', { 'questions' : questions, + 'contributors' : contributors, 'author_name' : meta_data.get('author_name',None), 'tab_id' : search_state.sort, 'questions_count' : objects_list.count, |