fix addon-orphaned reviews trying to be displayed on user profile page (bug 881034)

This commit is contained in:
Kevin Ngo 2013-06-28 14:46:13 -07:00
Родитель 3442b9b2b7
Коммит cac7459db7
3 изменённых файлов: 17 добавлений и 15 удалений

Просмотреть файл

@ -5,6 +5,7 @@ import re
from operator import attrgetter
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.forms import CheckboxInput
from django.utils import translation
from django.utils.encoding import smart_unicode
@ -575,3 +576,13 @@ def remora_url(context, url, lang=None, app=None, prefix=''):
except (AttributeError, KeyError):
pass
return urlresolvers.remora_url(url=url, lang=lang, app=app, prefix=prefix)
@register.function
@jinja2.contextfunction
def hasOneToOne(context, obj, attr):
try:
getattr(obj, attr)
return True
except ObjectDoesNotExist:
return False

Просмотреть файл

@ -98,10 +98,12 @@
<div class="items">
{% if reviews %}
{% for review in reviews %}
{% set addon = review.addon %}
{% with show_addon = True %}
{% include "reviews/review.html" %}
{% endwith %}
{% if hasOneToOne(review, 'addon') %}
{% set addon = review.addon %}
{% with show_addon = True %}
{% include "reviews/review.html" %}
{% endwith %}
{% endif %}
{% endfor %}
{{ edit_review_form() }}
{% else %}

Просмотреть файл

@ -2,7 +2,6 @@ import datetime
import urlparse
from django.utils.encoding import smart_str
from django.core.exceptions import ObjectDoesNotExist
import jinja2
import waffle
@ -179,16 +178,6 @@ def sort_link(context, pretty_name, sort_field):
sort, order)
@register.function
@jinja2.contextfunction
def hasOneToOne(context, obj, attr):
try:
getattr(obj, attr)
return True
except ObjectDoesNotExist:
return False
@register.function
@jinja2.contextfunction
def is_expired_lock(context, lock):