include the app in the file download url (bug 566919)
This commit is contained in:
Родитель
630a14b411
Коммит
5e7ff0fc8a
|
@ -137,7 +137,7 @@ class InstallButton(object):
|
|||
self.addon.status == file.status == amo.STATUS_PUBLIC):
|
||||
url = file.latest_xpi_url()
|
||||
else:
|
||||
url = file.get_url_path(self.src)
|
||||
url = file.get_url_path(self.app, self.src)
|
||||
|
||||
if platform == amo.PLATFORM_ALL.id:
|
||||
text, os = _('Download Now'), None
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
{%- for file in addon.current_version.all_files -%}
|
||||
<install hash="{{ file.hash }}"
|
||||
os="{{ amo.PLATFORMS[file.platform_id].api_name }}"
|
||||
size="{{ file.size * 1024 }}">{{ file.get_url_path('api') }}</install>
|
||||
size="{{ file.size * 1024 }}">{{ file.get_url_path(APP, 'api') }}</install>
|
||||
{% endfor -%}
|
||||
{%- endif -%}
|
||||
{%- if api_version >= 1.5 %}
|
||||
|
@ -77,7 +77,7 @@
|
|||
<install hash="{{ file.hash }}" os="{{ file.platform.name }}"
|
||||
size="{{ file.size * 1024 }}"
|
||||
status="{{ amo.STATUS_CHOICES[amo.STATUS_BETA] }}">
|
||||
{{ file.get_url_path('api') }}
|
||||
{{ file.get_url_path(APP, 'api') }}
|
||||
</install>
|
||||
{% endfor -%}
|
||||
{%- endif -%}
|
||||
|
|
|
@ -2,6 +2,7 @@ import os
|
|||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils import translation
|
||||
|
||||
import amo.models
|
||||
from amo.urlresolvers import reverse
|
||||
|
@ -24,9 +25,11 @@ class File(amo.models.ModelBase):
|
|||
class Meta(amo.models.ModelBase.Meta):
|
||||
db_table = 'files'
|
||||
|
||||
def get_url_path(self, src):
|
||||
def get_url_path(self, app, src):
|
||||
from amo.helpers import urlparams
|
||||
base = settings.FILES_URL % (self.id, self.filename, src)
|
||||
lang = translation.get_language()
|
||||
base = settings.FILES_URL % (lang, app.short, self.id,
|
||||
self.filename, src)
|
||||
return urlparams(base, confirmed=1)
|
||||
|
||||
def latest_xpi_url(self):
|
||||
|
|
|
@ -2,6 +2,7 @@ from django import test
|
|||
|
||||
from nose.tools import eq_
|
||||
|
||||
import amo
|
||||
from files.models import File
|
||||
|
||||
|
||||
|
@ -14,9 +15,10 @@ class TestFile(test.TestCase):
|
|||
|
||||
def test_get_absolute_url(self):
|
||||
f = File.objects.get(id=11993)
|
||||
assert f.get_absolute_url(src='src').endswith(
|
||||
'downloads/file/11993/'
|
||||
'del.icio.us_bookmarks-1.0.43-fx.xpi?src=src&confirmed=1')
|
||||
url = f.get_absolute_url(amo.FIREFOX, src='src')
|
||||
expected = ('/firefox/downloads/file/11993/'
|
||||
'del.icio.us_bookmarks-1.0.43-fx.xpi?src=src&confirmed=1')
|
||||
assert url.endswith(expected), url
|
||||
|
||||
def test_latest_url(self):
|
||||
# With platform.
|
||||
|
|
|
@ -358,7 +358,7 @@ PREVIEW_FULL_URL = (STATIC_URL +
|
|||
'/img/uploads/previews/full/%s/%d.png?modified=%d')
|
||||
USER_PIC_URL = STATIC_URL + '/img/uploads/userpics/%s/%s/%s.jpg?modified=%d'
|
||||
# paths for uploaded extensions
|
||||
FILES_URL = STATIC_URL + "/downloads/file/%d/%s?src=%s"
|
||||
FILES_URL = STATIC_URL + "/%s/%s/downloads/file/%d/%s?src=%s"
|
||||
COLLECTION_ICON_URL = ('%s/%s/%s/images/collection_icon/%%s/%%s' %
|
||||
(STATIC_URL, LANGUAGE_CODE, DEFAULT_APP))
|
||||
PERSONAS_IMAGE_URL = ('http://getpersonas.com/static/'
|
||||
|
|
Загрузка…
Ссылка в новой задаче