本文整理汇总了Python中reviews.models.GroupedRating类的典型用法代码示例。如果您正苦于以下问题:Python GroupedRating类的具体用法?Python GroupedRating怎么用?Python GroupedRating使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GroupedRating类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: extension_detail
def extension_detail(request, addon):
"""Extensions details page."""
# If current version is incompatible with this app, redirect.
comp_apps = addon.compatible_apps
if comp_apps and request.APP not in comp_apps:
prefixer = urlresolvers.get_url_prefix()
prefixer.app = comp_apps.keys()[0].short
return redirect('addons.detail', addon.slug, permanent=True)
# Popular collections this addon is part of.
collections = Collection.objects.listed().filter(
addons=addon, application=request.APP.id)
ctx = {
'addon': addon,
'src': request.GET.get('src', 'dp-btn-primary'),
'version_src': request.GET.get('src', 'dp-btn-version'),
'tags': addon.tags.not_blacklisted(),
'grouped_ratings': GroupedRating.get(addon.id),
'review_form': ReviewForm(),
'reviews': Review.objects.valid().filter(addon=addon, is_latest=True),
'get_replies': Review.get_replies,
'collections': collections.order_by('-subscribers')[:3],
'abuse_form': AbuseForm(request=request),
}
# details.html just returns the top half of the page for speed. The bottom
# does a lot more queries we don't want on the initial page load.
if request.is_ajax():
# Other add-ons/apps from the same author(s).
ctx['author_addons'] = addon.authors_other_addons(app=request.APP)[:6]
return render(request, 'addons/impala/details-more.html', ctx)
else:
return render(request, 'addons/impala/details.html', ctx)
开发者ID:jvillalobos,项目名称:olympia,代码行数:34,代码来源:views.py
示例2: detail
def detail(request, addon, add_review=False):
"""Product details page."""
reviews = Review.objects.valid().filter(addon=addon, is_latest=True)
# Mature regions show only reviews from within that region.
if not request.REGION.adolescent:
reviews = reviews.filter(client_data__region=request.REGION.id)
reviewed_filter = dict(user=request.user.id)
if addon.is_packaged:
reviewed_filter['version'] = addon.current_version
num_reviews = 6 if request.TABLET or not request.MOBILE else 2
user_review = reviews.filter(**reviewed_filter)
ctx = {
'product': addon,
'reviews': reviews[:num_reviews],
'flags': get_flags(request, reviews),
'has_review': request.user.is_authenticated() and
user_review.exists(),
'grouped_ratings': GroupedRating.get(addon.id),
'details_page': True,
'add_review': add_review,
}
if ctx['has_review']:
ctx['my_review'] = user_review[0]
if addon.is_public():
ctx['abuse_form'] = AbuseForm(request=request)
return jingo.render(request, 'detail/app.html', ctx)
开发者ID:MaxDumont,项目名称:zamboni,代码行数:26,代码来源:views.py
示例3: extension_detail
def extension_detail(request, addon):
"""Extensions details page."""
# If current version is incompatible with this app, redirect.
comp_apps = addon.compatible_apps
if comp_apps and request.APP not in comp_apps:
prefixer = urlresolvers.get_url_prefix()
prefixer.app = comp_apps.keys()[0].short
return redirect('addons.detail', addon.slug, permanent=True)
# get satisfaction only supports en-US.
lang = translation.to_locale(translation.get_language())
addon.has_satisfaction = (lang == 'en_US' and
addon.get_satisfaction_company)
# Addon recommendations.
recommended = Addon.objects.listed(request.APP).filter(
recommended_for__addon=addon)[:6]
# Popular collections this addon is part of.
collections = Collection.objects.listed().filter(
addons=addon, application__id=request.APP.id)
ctx = {
'addon': addon,
'src': request.GET.get('src', 'dp-btn-primary'),
'version_src': request.GET.get('src', 'dp-btn-version'),
'tags': addon.tags.not_blacklisted(),
'grouped_ratings': GroupedRating.get(addon.id),
'recommendations': recommended,
'review_form': ReviewForm(),
'reviews': Review.objects.latest().filter(addon=addon),
'get_replies': Review.get_replies,
'collections': collections.order_by('-subscribers')[:3],
'abuse_form': AbuseForm(request=request),
}
# details.html just returns the top half of the page for speed. The bottom
# does a lot more queries we don't want on the initial page load.
if request.is_ajax():
# Other add-ons/apps from the same author(s).
if addon.is_webapp():
others = Webapp.objects.listed().filter(type=amo.ADDON_WEBAPP)
else:
others = (Addon.objects.listed(request.APP)
.exclude(type=amo.ADDON_WEBAPP))
others = (others.exclude(id=addon.id).distinct()
.filter(addonuser__listed=True,
authors__in=addon.listed_authors))
ctx['author_addons'] = others[:6]
return jingo.render(request, 'addons/impala/details-more.html', ctx)
else:
if addon.is_webapp():
ctx['search_placeholder'] = 'apps'
return jingo.render(request, 'addons/impala/details.html', ctx)
开发者ID:pennyfx,项目名称:zamboni,代码行数:54,代码来源:views.py
示例4: impala_extension_detail
def impala_extension_detail(request, addon):
"""Extensions details page."""
# if current version is incompatible with this app, redirect
comp_apps = addon.compatible_apps
if comp_apps and request.APP not in comp_apps:
prefixer = urlresolvers.get_url_prefix()
prefixer.app = comp_apps.keys()[0].short
return http.HttpResponsePermanentRedirect(reverse(
'addons.detail', args=[addon.slug]))
# source tracking
src = request.GET.get('src', 'addon-detail')
# get satisfaction only supports en-US
lang = translation.to_locale(translation.get_language())
addon.has_satisfaction = (lang == 'en_US' and
addon.get_satisfaction_company)
# other add-ons from the same author(s)
author_addons = order_by_translation(addon.authors_other_addons, 'name')[:6]
# tags
tags = addon.tags.not_blacklisted()
# addon recommendations
recommended = MiniAddon.objects.valid().filter(
recommended_for__addon=addon)[:5]
# popular collections this addon is part of
collections = Collection.objects.listed().filter(
addons=addon, application__id=request.APP.id)
data = {
'addon': addon,
'author_addons': author_addons,
'src': src,
'tags': tags,
'grouped_ratings': GroupedRating.get(addon.id),
'recommendations': recommended,
'review_form': ReviewForm(),
'reviews': Review.objects.latest().filter(addon=addon),
'get_replies': Review.get_replies,
'collections': collections.order_by('-subscribers')[:3],
}
if settings.REPORT_ABUSE:
data['abuse_form'] = AbuseForm(request=request)
return jingo.render(request, 'addons/impala/details.html', data)
开发者ID:ricardodani,项目名称:zamboni,代码行数:52,代码来源:views.py
示例5: detail
def detail(request, addon):
"""Product details page."""
reviews = Review.objects.latest().filter(addon=addon)
ctx = {
"product": addon,
"reviews": reviews[:2],
"flags": get_flags(request, reviews),
"has_review": request.user.is_authenticated() and reviews.filter(user=request.user.id).exists(),
"grouped_ratings": GroupedRating.get(addon.id),
}
if addon.is_public():
ctx["abuse_form"] = AbuseForm(request=request)
return jingo.render(request, "detail/app.html", ctx)
开发者ID:dbialer,项目名称:zamboni,代码行数:13,代码来源:views.py
示例6: extension_detail
def extension_detail(request, addon):
"""Extensions details page."""
# If current version is incompatible with this app, redirect.
comp_apps = addon.compatible_apps
if comp_apps and request.APP not in comp_apps:
prefixer = urlresolvers.get_url_prefix()
prefixer.app = comp_apps.keys()[0].short
return redirect("addons.detail", addon.slug, permanent=True)
# get satisfaction only supports en-US.
lang = translation.to_locale(translation.get_language())
addon.has_satisfaction = lang == "en_US" and addon.get_satisfaction_company
# Addon recommendations.
recommended = Addon.objects.listed(request.APP).filter(recommended_for__addon=addon)[:6]
# Popular collections this addon is part of.
collections = Collection.objects.listed().filter(addons=addon, application__id=request.APP.id)
ctx = {
"addon": addon,
"src": request.GET.get("src", "dp-btn-primary"),
"version_src": request.GET.get("src", "dp-btn-version"),
"tags": addon.tags.not_blacklisted(),
"grouped_ratings": GroupedRating.get(addon.id),
"recommendations": recommended,
"review_form": ReviewForm(),
"reviews": Review.objects.latest().filter(addon=addon),
"get_replies": Review.get_replies,
"collections": collections.order_by("-subscribers")[:3],
"abuse_form": AbuseForm(request=request),
}
# details.html just returns the top half of the page for speed. The bottom
# does a lot more queries we don't want on the initial page load.
if request.is_ajax():
# Other add-ons/apps from the same author(s).
if addon.is_webapp():
others = Webapp.objects.listed().filter(type=amo.ADDON_WEBAPP)
else:
others = Addon.objects.listed(request.APP).exclude(type=amo.ADDON_WEBAPP)
others = others.exclude(id=addon.id).distinct().filter(addonuser__listed=True, authors__in=addon.listed_authors)
ctx["author_addons"] = others[:6]
return jingo.render(request, "addons/impala/details-more.html", ctx)
else:
if addon.is_webapp():
ctx["search_cat"] = "apps"
return jingo.render(request, "addons/impala/details.html", ctx)
开发者ID:james4388,项目名称:zamboni,代码行数:48,代码来源:views.py
示例7: extension_detail
def extension_detail(request, addon):
"""Extensions details page."""
# If current version is incompatible with this app, redirect.
comp_apps = addon.compatible_apps
if comp_apps and request.APP not in comp_apps:
prefixer = urlresolvers.get_url_prefix()
prefixer.app = comp_apps.keys()[0].short
return redirect("addons.detail", addon.slug, permanent=True)
# Addon recommendations.
recommended = Addon.objects.listed(request.APP).filter(recommended_for__addon=addon)[:6]
# Popular collections this addon is part of.
collections = Collection.objects.listed().filter(addons=addon, application__id=request.APP.id)
ctx = {
"addon": addon,
"src": request.GET.get("src", "dp-btn-primary"),
"version_src": request.GET.get("src", "dp-btn-version"),
"tags": addon.tags.not_blacklisted(),
"grouped_ratings": GroupedRating.get(addon.id),
"recommendations": recommended,
"review_form": ReviewForm(),
"reviews": Review.objects.valid().filter(addon=addon, is_latest=True),
"get_replies": Review.get_replies,
"collections": collections.order_by("-subscribers")[:3],
"abuse_form": AbuseForm(request=request),
}
# details.html just returns the top half of the page for speed. The bottom
# does a lot more queries we don't want on the initial page load.
if request.is_ajax():
# Other add-ons/apps from the same author(s).
ctx["author_addons"] = addon.authors_other_addons(app=request.APP)[:6]
return render(request, "addons/impala/details-more.html", ctx)
else:
return render(request, "addons/impala/details.html", ctx)
开发者ID:BavarianTomcat,项目名称:olympia,代码行数:37,代码来源:views.py
示例8: test_set
def test_set(self):
eq_(GroupedRating.get(1865), None)
GroupedRating.set(1865)
eq_(GroupedRating.get(1865), [(1, 0), (2, 0), (3, 0), (4, 1), (5, 0)])
开发者ID:fligtar,项目名称:zamboni,代码行数:4,代码来源:test_models.py
示例9: rating_header
def rating_header(context, product, title):
c = dict(context.items())
c.update(product=product, title=title,
grouped_ratings=GroupedRating.get(product.id))
return c
开发者ID:gedex,项目名称:zamboni,代码行数:5,代码来源:helpers.py
示例10: test_update_none
def test_update_none(self):
eq_(GroupedRating.get(1865, update_none=False), None)
eq_(GroupedRating.get(1865, update_none=True), self.grouped_ratings)
开发者ID:AALEKH,项目名称:zamboni,代码行数:3,代码来源:test_models.py
示例11: test_cron
def test_cron(self):
eq_(GroupedRating.get(1865), None)
tasks.addon_grouped_rating(1865)
eq_(GroupedRating.get(1865), [(1, 0), (2, 0), (3, 0), (4, 1), (5, 0)])
开发者ID:fligtar,项目名称:zamboni,代码行数:4,代码来源:test_models.py
示例12: test_set
def test_set(self):
eq_(GroupedRating.get(1865, update_none=False), None)
GroupedRating.set(1865)
eq_(GroupedRating.get(1865, update_none=False), self.grouped_ratings)
开发者ID:AALEKH,项目名称:zamboni,代码行数:4,代码来源:test_models.py
示例13: test_cron
def test_cron(self):
eq_(GroupedRating.get(1865, update_none=False), None)
tasks.addon_grouped_rating(1865)
eq_(GroupedRating.get(1865, update_none=False), self.grouped_ratings)
开发者ID:AALEKH,项目名称:zamboni,代码行数:4,代码来源:test_models.py
示例14: test_get_none
def test_get_none(self):
eq_(GroupedRating.get(3, update_none=False), None)
开发者ID:AALEKH,项目名称:zamboni,代码行数:2,代码来源:test_models.py
示例15: test_get_none
def test_get_none(self):
eq_(GroupedRating.get(3), None)
开发者ID:21echoes,项目名称:zamboni,代码行数:2,代码来源:test_models.py
示例16: test_set
def test_set(self):
eq_(GroupedRating.get(1865), None)
GroupedRating.set(1865)
eq_(GroupedRating.get(1865), [[1, 0], [2, 0], [3, 0], [4, 1], [5, 0]])
开发者ID:21echoes,项目名称:zamboni,代码行数:4,代码来源:test_models.py
示例17: setUp
def setUp(self):
cache.set(GroupedRating.key(1865), None)
开发者ID:fligtar,项目名称:zamboni,代码行数:2,代码来源:test_models.py
示例18: test_cron
def test_cron(self):
eq_(GroupedRating.get(1865), None)
tasks.addon_grouped_rating(1865)
eq_(GroupedRating.get(1865), [[1, 0], [2, 0], [3, 0], [4, 1], [5, 0]])
开发者ID:21echoes,项目名称:zamboni,代码行数:4,代码来源:test_models.py
注:本文中的reviews.models.GroupedRating类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论