mobile reviews page (bug 632677)
This commit is contained in:
Родитель
bc4b6dd6bd
Коммит
4ecec95f18
|
@ -0,0 +1,15 @@
|
|||
{% if grouped_ratings and addon.total_reviews %}
|
||||
<div>
|
||||
<ul class="grouped_ratings" data-total="{{ addon.total_reviews }}">
|
||||
{% for rating, count in grouped_ratings|sort(reverse=True) %}
|
||||
{% set pct = ( count|float / addon.total_reviews * 100 )|round( method='floor' ) %}
|
||||
<li>{{ rating|stars }}
|
||||
<div class="rating_bar" data-num-reviews="{{ count }}">
|
||||
<span class="bar" style="width:{{ pct }}%">
|
||||
<span class="num_ratings">{{ count }}</span>
|
||||
</span>
|
||||
</div> </li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
|
@ -0,0 +1,43 @@
|
|||
{% extends "mobile/base.html" %}
|
||||
|
||||
{# L10n: {0} is an addon name. #}
|
||||
{% block title %}{{ page_title(_('Reviews for {0}')|f(addon.name)) }}{% endblock %}
|
||||
|
||||
{% block page %}
|
||||
<a href="{{ addon.get_url_path() }}">« {{ addon.name }}</a>
|
||||
|
||||
{% if not addon.total_reviews %}
|
||||
{{ _('No ratings yet.') }}
|
||||
{% else %}
|
||||
|
||||
<h2>{{ _('Rating') }}</h2>
|
||||
<span>
|
||||
{{ addon.average_rating|float|stars }}
|
||||
{{ ngettext('Average from {0} Rating', 'Average from {0} Ratings',
|
||||
addon.total_reviews)|f(addon.total_reviews|numberfmt) }}
|
||||
</span>
|
||||
{% include "reviews/grouped_ratings.html" %}
|
||||
|
||||
|
||||
<h2>{{ _('Reviews') }}</h2>
|
||||
{% for review in reviews.object_list %}
|
||||
<div class="review">
|
||||
{% if review.title %}
|
||||
<h3>{{ review.title }}</h3>
|
||||
{% endif %}
|
||||
{{ review.rating|float|stars }}
|
||||
{% trans user=review.user|user_link %}
|
||||
by {{ user }}
|
||||
{% endtrans %}
|
||||
<p>{{ review.body|nl2br }}</p>
|
||||
{% if review.version_id and review.version_id != addon._current_version_id %}
|
||||
{# L10n: {0} is a version number (like 1.01) #}
|
||||
<span>{{ _('This review is for a previous version of the add-on ({0}).')|f(review.version.version) }} </span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{{ reviews|mobile_paginator }}
|
||||
|
||||
{% endif %} {# if addon.total_reviews #}
|
||||
{% endblock %}
|
|
@ -95,21 +95,7 @@
|
|||
{% endtrans %}
|
||||
</span>
|
||||
</div>
|
||||
{% if grouped_ratings and addon.total_reviews %}
|
||||
<div>
|
||||
<ul class="grouped_ratings" data-total="{{ addon.total_reviews }}">
|
||||
{% for rating, count in grouped_ratings|sort(reverse=True) %}
|
||||
{% set pct = ( count|float / addon.total_reviews * 100 )|round( method='floor' ) %}
|
||||
<li>{{ rating|stars }}
|
||||
<div class="rating_bar" data-num-reviews="{{ count }}">
|
||||
<span class="bar" style="width:{{ pct }}%">
|
||||
<span class="num_ratings">{{ count }}</span>
|
||||
</span>
|
||||
</div> </li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% include "reviews/grouped_ratings.html" %}
|
||||
{% if not review_perms.is_author %}
|
||||
<div>
|
||||
<a class="button" href="{{ url('reviews.add', addon.slug) }}">
|
||||
|
|
|
@ -3,6 +3,7 @@ import test_utils
|
|||
|
||||
from amo.urlresolvers import reverse
|
||||
from access.models import GroupUser
|
||||
from addons.tests.test_views import TestMobile
|
||||
from devhub.models import ActivityLog
|
||||
from reviews.models import Review, ReviewFlag
|
||||
|
||||
|
@ -181,3 +182,12 @@ class TestEdit(ReviewTest):
|
|||
review = Review.objects.get(id=218468)
|
||||
eq_('%s' % review.title, 'fo')
|
||||
eq_('%s' % review.body, 'shizzle')
|
||||
|
||||
|
||||
class TestMobileReviews(TestMobile):
|
||||
fixtures = ['base/apps', 'reviews/dev-reply.json']
|
||||
|
||||
def test_mobile(self):
|
||||
r = self.client.get(reverse('reviews.list', args=['a1865']))
|
||||
eq_(r.status_code, 200)
|
||||
self.assertTemplateUsed(r, 'reviews/mobile/review_list.html')
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.shortcuts import get_object_or_404, redirect
|
|||
import commonware.log
|
||||
import jingo
|
||||
from tower import ugettext as _
|
||||
from mobility.decorators import mobile_template
|
||||
|
||||
from amo import messages
|
||||
import amo.utils
|
||||
|
@ -25,7 +26,8 @@ def flag_context():
|
|||
|
||||
|
||||
@addon_view
|
||||
def review_list(request, addon, review_id=None, user_id=None):
|
||||
@mobile_template('reviews/{mobile/}review_list.html')
|
||||
def review_list(request, addon, review_id=None, user_id=None, template=None):
|
||||
q = (Review.objects.valid().filter(addon=addon)
|
||||
.order_by('-created'))
|
||||
|
||||
|
@ -65,7 +67,7 @@ def review_list(request, addon, review_id=None, user_id=None):
|
|||
ctx['flags'] = get_flags(request, reviews.object_list)
|
||||
else:
|
||||
ctx['review_perms'] = {}
|
||||
return jingo.render(request, 'reviews/review_list.html', ctx)
|
||||
return jingo.render(request, template, ctx)
|
||||
|
||||
|
||||
def get_flags(request, reviews):
|
||||
|
|
Загрузка…
Ссылка в новой задаче