fix displaying built-in theme licenses (bug 880274)

This commit is contained in:
Kevin Ngo 2013-06-26 11:11:54 -07:00
Родитель f7f705916f
Коммит 52d3532da6
1 изменённых файлов: 10 добавлений и 4 удалений

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

@ -18,6 +18,7 @@ from tower import ugettext as _, strip_whitespace
import amo
from amo import utils, urlresolvers
from constants.licenses import PERSONA_LICENSES_IDS
from translations.query import order_by_translation
from translations.helpers import truncate
from versions.models import License
@ -386,10 +387,15 @@ def license_link(license):
"""Link to a code license, including icon where applicable."""
# If passed in an integer, try to look up the License.
if isinstance(license, (long, int)):
license = License.objects.filter(id=license)
if not license.exists():
return ''
license = license[0]
if license in PERSONA_LICENSES_IDS:
# Grab built-in license.
license = PERSONA_LICENSES_IDS[license]
else:
# Grab custom license.
license = License.objects.filter(id=license)
if not license.exists():
return ''
license = license[0]
elif not license:
return ''