hide <authors> for personas (bug 584242)

This commit is contained in:
Jeff Balogh 2010-08-04 17:29:03 -07:00
Родитель e4434caa0c
Коммит d7b24292f9
5 изменённых файлов: 35 добавлений и 4 удалений

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

@ -19,7 +19,7 @@ from reviews.models import Review
from stats.models import Contribution as ContributionStats, ShareCountTotal
from translations.fields import (TranslatedField, PurifiedField,
LinkifiedField, translations_with_fallback)
from users.models import UserProfile
from users.models import UserProfile, PersonaAuthor
from versions.models import Version
from . import query
@ -316,7 +316,7 @@ class Addon(amo.models.ModelBase):
for persona in Persona.objects.no_cache().filter(addon__in=personas):
addon = addon_dict[persona.addon_id]
addon.persona = persona
addon.listed_authors = [persona.display_username]
addon.listed_authors = [PersonaAuthor(persona.display_username)]
addon.weekly_downloads = persona.popularity
# Personas need categories for the JSON dump.

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

@ -116,6 +116,24 @@
"nomination_date": null
}
},
{
"pk": 575,
"model": "addons.persona",
"fields": {
"display_username": "ladygaga",
"popularity": 8381,
"footer": "Persona_Footer_UNI_GAGA_FINAL.jpg",
"movers": -0.11117283254862,
"author": "ladygaga",
"submit": "2009-03-30 21:26:59",
"accentcolor": "000000",
"header": "Persona_Header_UNI_GAGA_FINAL_2.jpg",
"textcolor": "ffffff",
"approve": "2009-03-30 23:18:20",
"persona_id": 830,
"addon": 15679
}
},
{
"pk": 342,
"model": "addons.feature",

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

@ -6,6 +6,7 @@
<version>{{ addon.current_version.version }}</version>
<status id="{{ addon.status }}">{{ amo.STATUS_CHOICES[addon.status] }}</status>
<authors>
{% if not addon.is_persona %}
{% for author in addon.listed_authors -%}
{%- if api_version >= 1.5 -%}
<author id="{{ author.id }}">
@ -16,6 +17,7 @@
<author>{{ author.display_name }}</author>
{%- endif -%}
{%- endfor %}
{% endif %}
</authors>
<summary>{{ addon.summary }}</summary>
<description>{{ addon.description }}</description>

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

@ -345,9 +345,12 @@ class ListTest(amo.test_utils.ExtraSetup, TestCase):
This tests that list filtering works.
E.g. /list/recommended/theme gets only shows themes
"""
request = make_call('list/recommended/9/1')
response = make_call('list/recommended/9/1')
self.assertContains(response, """<type id="9">Persona</type>""", 1)
self.assertContains(request, """<type id="9">Persona</type>""", 1)
def test_persona_search_15(self):
response = make_call('list/recommended/9/1', version=1.5)
self.assertContains(response, """<type id="9">Persona</type>""", 1)
def test_limits(self):
"""

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

@ -206,3 +206,11 @@ class BlacklistedNickname(amo.models.ModelBase):
# Could also cache the entire blacklist and simply check if the
# nickname is in the list here. @TODO?
return cls.uncached.only('nickname').filter(nickname=nick).exists()
class PersonaAuthor(unicode):
"""Stub user until the persona authors get imported."""
@property
def display_name(self):
return self