Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Implemented questions template (bug 565367)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlr committed Jun 10, 2010
1 parent e291839 commit 8eb19c6
Show file tree
Hide file tree
Showing 22 changed files with 662 additions and 31 deletions.
5 changes: 5 additions & 0 deletions apps/questions/__init__.py
@@ -0,0 +1,5 @@
# The number of answers per page.
ANSWERS_PER_PAGE = 20

# The number of questions per page.
QUESTIONS_PER_PAGE = 20
8 changes: 3 additions & 5 deletions apps/questions/templates/questions/answers.html
@@ -1,15 +1,13 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "common/base.html" %}
{% extends "questions/base.html" %}
{# L10n: {q} is the title of the question. {f} is the name of the question forum. #}
{% set title = _('{q} | {f} | Questions')|f(q=question.title, f=forum.name) %}
{% set crumbs = [(url('questions.question_forums'), _('Questions')),
(url('questions.questions', forum_slug=forum.slug), forum.name),
(None, question.title)] %}
{% set classes = 'answers' %}

{% block content %}
<h2>{{ question.title }}</h2>

{% if answers %}
{% if answers.object_list %}
<ol class="answers">
{% for answer in answers.object_list %}
<li id="answer-{{ answer.id }}">
Expand Down
88 changes: 88 additions & 0 deletions apps/questions/templates/questions/base.html
@@ -0,0 +1,88 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "layout/base.html" %}
{% set styles = ('questions',) %}
{% set scripts = ('questions',) %}

{% block content_area %}

<div id="main-hdr">
<hgroup>
<h1><a href="{{ url('questions.questions', forum_slug=forum.slug) }}">{{ _('Firefox Support Forum') }}</a></h1>
<h2>{{ _('The Official Community-Driven Support Web Site for Firefox') }}</h2>
</hgroup>

<div id="support-search" role="search">
<form action="#{# TODO #}" method="get">
<div class="wrap">
<input type="text" class="text" name="q" placeholder="{{ _('Search Mozilla Support') }}" required="required" />
</div>
<noscript>
<input type="submit" class="submit" value="{{ _('Search') }}" />
</noscript>
</form>
</div>

<div id="greeting">
{% if user.is_authenticated() %}
{{ _('Welcome, <span class="user">{user}</span>.')|fe(user=user) }}
<nav>
<a href="{{ profile_url(user) }}">{{ _('Profile') }}</a>
&bull;
<a href="{{ settings.LOGOUT_URL }}">{{ _('Sign Out') }}</a>
</nav>
{% else %}
<p>
{% trans login_url=settings.LOGIN_URL, register_url=settings.REGISTER_URL %}
Want to contribute? <a href="{{ login_url }}">Sign In</a> or <a href="{{ register_url }}">Register</a>
{% endtrans %}
{% endif %}
</div>
</div>

{% block filter %}
{% endblock %}

<div id="main-content">
{% block content %}
{% endblock %}
</div>

<div id="main-sd">
{% block side %}
<div class="sd-module" id="ask-question">
<h3>{{ _("Can't Find an Answer?") }}</h3>
<p>{{ _('Post your question to the support forum. The Firefox community is here to help!') }}</p>
<div class="ask-question">
<a href="{{ url('questions.new_question', forum_slug=forum.slug) }}">
<span class="q">?</span>
{{ _('Ask a Question') }}
</a>
</div>
</div>
<div class="sd-module" id="top-contributors">
<h3>{{ _('Top Contributors') }}</h3>
<h4>{{ _('Most Solutions this Week') }}</h4>
<ol>
{# TODO #}
<li>Lorem Ipsum</li>
<li>Dolor sit Amet</li>
<li>Consectetur Adipisicing</li>
<li>Sed do Eiusmod</li>
<li>Tempor Incididunt</li>
<li>Labore Dolore</li>
<li>Magna Aliqua</li>
<li>Enim Minim</li>
<li>Veniam Nostrud</li>
<li>Exercitation Ullamco</li>
</ol>
</div>
{% endblock %}
</div>

{% endblock %}

{% block breadcrumbs %}
{% endblock %}

{% block sidebar %}
{% endblock %}
154 changes: 142 additions & 12 deletions apps/questions/templates/questions/questions.html
@@ -1,22 +1,152 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "common/base.html" %}
{% extends "questions/base.html" %}
{% set title = _('{f} | Questions')|f(f=forum.name) %}
{% set crumbs = [(url('questions.question_forums'), _('Questions')),
(None, forum.name)] %}
{% set classes = 'questions' %}

{% block filter %}
<div id="filter">
<label>{{ _('Posts:') }}</label>
<ul>
{% if user.is_authenticated() %}
<li>
<a href="#{# TODO #}">{{ _('My Contributions') }}</a>
</li>
{% endif %}
<li>
<a href="#{# TODO #}">{{ _('Most Recent') }}</a>
</li>
<li class="active {# TODO: conditional logic #}">
<a href="#{# TODO #}">{{ _('Most Requested') }}</a>
</li>
<li>
<a href="#{# TODO #}">{{ _('Unsolved') }}</a>
</li>
<li>
<a href="#{# TODO #}">{{ _('Solved') }}</a>
</li>
<li>
<a href="#{# TODO #}">{{ _('No Replies') }}</a>
</li>
</ul>
</div>
{% endblock %}

{% block content %}
<h2>{{ forum.name }}</h2>

{% if threads %}
<ul>
{% for question in questions %}
<li><a href="{{ url('questions.answers', forum_slug=forum.slug, question_id=question.id) }}">{{ question.title }}</a><br/>
Answers: {{ question.answers }} | Last answer by {{ question.last_answer.creator.username }}</li>
{% if questions.object_list %}
<ol class="questions">
{% for question in questions.object_list %}
<li>
<div class="people just-one {# possible classes are: just-one (==1), less-ten (<10), more-ten (>=10) #}">
{% trans %}{# TODO #}<strong>1 person</strong> <span>has this problem</span>{% endtrans %}
</div>
<div class="title">
<h2><a href="{{ url('questions.answers', forum_slug=forum.slug, question_id=question.id) }}">{{ question.title }}</a></h2>
</div>
<div class="asked-by">
{% trans creator=question.creator%}Asked by <span class="user">{{ creator }}</span>{% endtrans %}
<time>{{ datetimeformat(question.created, format='longdatetime') }}</time>
</div>
<p>{{ question.content|striptags()|truncate(170) }}</p>
<div class="meta">
<span>{# TODO #}Firefox Mobile 1.0</span>
&bull;
<span>{# TODO #}Mac OS X 10.6</span>
&bull;
<span>{{ _('Tagged') }} {# TODO #}lorem, ipsum, dolor, sit amet</span>
</div>
</li>
{% endfor %}
</ul>


{# Some extra static questions with different variations #}
<li>
<div class="people less-ten">
{% trans %}{# TODO #}<strong>9 people</strong> <span>have this problem</span>{% endtrans %}
</div>
<div class="title">
<h2><a href="#">Lorem ipsum dolor sit amet, conectetur adipisicing elit, sed do eiusmod tempor</a></h2>
<span class="badge replies">12 replies</span>
</div>
<div class="asked-by">
Asked by <span class="user">Noob</span>
<time>today at 10:41am</time>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation...</p>
<div class="meta">
<span>Firefox Mobile 1.0</span>
&bull;
<span>Mac OS X 10.6</span>
&bull;
<span>{{ _('Tagged') }} lorem, ipsum, dolor, sit amet</span>
</div>
</li>
<li>
<div class="people more-ten">
{% trans %}{# TODO #}<strong>25 people</strong> <span>have this problem</span>{% endtrans %}
</div>
<div class="title">
<h2><a href="#">Lorem ipsum dolor sit amet, conectetur adipisicing elit, sed do eiusmod tempor</a></h2>
<span class="badge solutions">3 solutions</span>
</div>
<div class="asked-by">
Asked by <span class="user">Noob</span>
<time>today at 10:41am</time>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation...</p>
<div class="meta">
<span>Firefox Mobile 1.0</span>
&bull;
<span>Mac OS X 10.6</span>
&bull;
<span>{{ _('Tagged') }} lorem, ipsum, dolor, sit amet</span>
</div>
</li>
<li>
<div class="people more-ten">
{% trans %}{# TODO #}<strong>35 people</strong> <span>have this problem</span>{% endtrans %}
</div>
<div class="title">
<h2><a href="#">Lorem ipsum dolor sit amet, conectetur adipisicing elit, sed do eiusmod tempor</a></h2>
<span class="badge solved">solved</span>
</div>
<div class="asked-by">
Asked by <span class="user">Noob</span>
<time>today at 10:41am</time>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation...</p>
<div class="meta">
<span>Firefox Mobile 1.0</span>
&bull;
<span>Mac OS X 10.6</span>
&bull;
<span>{{ _('Tagged') }} lorem, ipsum, dolor, sit amet</span>
</div>
</li>
<li>
<div class="people more-ten">
{% trans %}{# TODO #}<strong>35 people</strong> <span>have this problem</span>{% endtrans %}
</div>
<div class="title">
<h2><a href="#">Lorem ipsum dolor sit amet, conectetur adipisicing elit, sed do eiusmod tempor</a></h2>
<span class="badge contributed">contributed</span>
</div>
<div class="asked-by">
Asked by <span class="user">Noob</span>
<time>today at 10:41am</time>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation...</p>
<div class="meta">
<span>Firefox Mobile 1.0</span>
&bull;
<span>Mac OS X 10.6</span>
&bull;
<span>{{ _('Tagged') }} lorem, ipsum, dolor, sit amet</span>
</div>
</li>
</ol>
{{ questions|paginator }}
{% else %}
{# Not localized because it's not worth localizers time. #}
<p>There are no questions. Maybe you should ask some!</p>
{% endif %}
{% endblock %}

7 changes: 5 additions & 2 deletions apps/questions/views.py
Expand Up @@ -4,6 +4,7 @@

from sumo.utils import paginate
from .models import QuestionForum, Question
import questions as constants


def question_forums(request):
Expand All @@ -20,7 +21,8 @@ def questions(request, forum_slug):

forum = get_object_or_404(QuestionForum, slug=forum_slug)

questions_ = paginate(forum.question_set.all())
questions_ = paginate(request, forum.questions.all(),
per_page=constants.QUESTIONS_PER_PAGE)

return jingo.render(request, 'questions/questions.html',
{'forum': forum, 'questions': questions_})
Expand All @@ -32,7 +34,8 @@ def answers(request, forum_slug, question_id):
forum = get_object_or_404(QuestionForum, slug=forum_slug)
question = get_object_or_404(Question, pk=question_id)

answers_ = paginate(question.answer_set.all())
answers_ = paginate(request, question.answers.all(),
per_page=constants.ANSWERS_PER_PAGE)

return jingo.render(request, 'questions/answers.html',
{'forum': forum, 'question': question,
Expand Down
1 change: 1 addition & 0 deletions media/css/main.css
Expand Up @@ -368,6 +368,7 @@ h2 {
----------------------------------*/

#content {
clear:both;
width: 920px;
margin: auto;
text-align: left;
Expand Down

0 comments on commit 8eb19c6

Please sign in to comment.