diff --git a/settings.py b/settings.py index 58ee541238..51c7c4c93e 100644 --- a/settings.py +++ b/settings.py @@ -42,6 +42,7 @@ ES_DEFAULT_NUM_REPLICAS = 0 SITE_URL = os.environ.get('OLYMPIA_SITE_URL') or 'http://localhost:8000' DOMAIN = SERVICES_DOMAIN = urlparse(SITE_URL).netloc SERVICES_URL = SITE_URL +EXTERNAL_SITE_URL = SITE_URL CODE_MANAGER_URL = os.environ.get('CODE_MANAGER_URL') or 'http://localhost:3000' diff --git a/settings_test.py b/settings_test.py index c14d94548c..7876fb357a 100644 --- a/settings_test.py +++ b/settings_test.py @@ -23,7 +23,7 @@ DEBUG = False # We won't actually send an email. SEND_REAL_EMAIL = True -SITE_URL = CDN_HOST = 'http://testserver' +SITE_URL = CDN_HOST = EXTERNAL_SITE_URL = 'http://testserver' STATIC_URL = '%s/static/' % CDN_HOST MEDIA_URL = '%s/user-media/' % CDN_HOST diff --git a/src/olympia/accounts/serializers.py b/src/olympia/accounts/serializers.py index 5bf48cf1c8..9c99c2a157 100644 --- a/src/olympia/accounts/serializers.py +++ b/src/olympia/accounts/serializers.py @@ -41,7 +41,7 @@ class BaseUserSerializer(serializers.ModelSerializer): current_user = getattr(request, 'user', None) if request else None # Only return your own profile url, and for developers. if obj == current_user or is_adminish(current_user) or obj.is_public: - return absolutify(obj.get_url_path()) + return obj.get_absolute_url() # Used in subclasses. def get_permissions(self, obj): diff --git a/src/olympia/addons/serializers.py b/src/olympia/addons/serializers.py index c366995791..e0dd85913a 100644 --- a/src/olympia/addons/serializers.py +++ b/src/olympia/addons/serializers.py @@ -47,9 +47,7 @@ class FileSerializer(serializers.ModelSerializer): 'platform', 'size', 'status', 'url', 'permissions') def get_url(self, obj): - # File.get_url_path() is a little different, it's already absolute, but - # needs a src parameter that is appended as a query string. - return obj.get_url_path(src='') + return obj.get_absolute_url(src='') class PreviewSerializer(serializers.ModelSerializer): @@ -427,9 +425,9 @@ class AddonSerializer(serializers.ModelSerializer): return getattr(obj, 'tag_list', []) def get_url(self, obj): - # Use get_detail_url(), get_url_path() does an extra check on - # current_version that is annoying in subclasses which don't want to - # load that version. + # Use absolutify(get_detail_url()), get_absolute_url() calls + # get_url_path() which does an extra check on current_version that is + # annoying in subclasses which don't want to load that version. return absolutify(obj.get_detail_url()) def get_edit_url(self, obj): @@ -714,11 +712,12 @@ class ESAddonAutoCompleteSerializer(ESAddonSerializer): model = Addon def get_url(self, obj): - # Addon.get_url_path() wants current_version to exist, but that's just - # a safeguard. We don't care and don't want to fetch the current - # version field to improve perf, so give it a fake one. + # Addon.get_absolute_url() calls get_url_path(), which wants + # current_version to exist, but that's just a safeguard. We don't care + # and don't want to fetch the current version field to improve perf, so + # give it a fake one. obj._current_version = Version() - return absolutify(obj.get_url_path()) + return obj.get_absolute_url() class StaticCategorySerializer(serializers.Serializer): diff --git a/src/olympia/addons/tests/test_serializers.py b/src/olympia/addons/tests/test_serializers.py index 5bd84a9065..15c40cedf8 100644 --- a/src/olympia/addons/tests/test_serializers.py +++ b/src/olympia/addons/tests/test_serializers.py @@ -45,7 +45,7 @@ class AddonSerializerOutputTestMixin(object): 'id': author.pk, 'name': author.name, 'picture_url': None, - 'url': absolutify(author.get_url_path()), + 'url': author.get_absolute_url(), 'username': author.username, } @@ -93,7 +93,7 @@ class AddonSerializerOutputTestMixin(object): amo.PLATFORM_CHOICES_API[file_.platform]) assert result_file['size'] == file_.size assert result_file['status'] == amo.STATUS_CHOICES_API[file_.status] - assert result_file['url'] == file_.get_url_path(src='') + assert result_file['url'] == file_.get_absolute_url(src='') assert result_file['permissions'] == file_.webext_permissions_list assert data['edit_url'] == absolutify( @@ -289,7 +289,7 @@ class AddonSerializerOutputTestMixin(object): assert 'theme_data' not in result assert set(result['tags']) == {'some_tag', 'some_other_tag'} assert result['type'] == 'extension' - assert result['url'] == absolutify(self.addon.get_url_path()) + assert result['url'] == self.addon.get_absolute_url() assert result['weekly_downloads'] == self.addon.weekly_downloads return result @@ -880,7 +880,7 @@ class TestESAddonSerializerOutput(AddonSerializerOutputTestMixin, ESTestCase): assert data == { 'id': author.pk, 'name': author.name, - 'url': absolutify(author.get_url_path()), + 'url': author.get_absolute_url(), 'username': author.username, } @@ -968,7 +968,7 @@ class TestVersionSerializerOutput(TestCase): assert result['files'][0]['platform'] == 'windows' assert result['files'][0]['size'] == first_file.size assert result['files'][0]['status'] == 'public' - assert result['files'][0]['url'] == first_file.get_url_path(src='') + assert result['files'][0]['url'] == first_file.get_absolute_url(src='') assert result['files'][1]['id'] == second_file.pk assert result['files'][1]['created'] == ( @@ -981,7 +981,8 @@ class TestVersionSerializerOutput(TestCase): assert result['files'][1]['platform'] == 'mac' assert result['files'][1]['size'] == second_file.size assert result['files'][1]['status'] == 'public' - assert result['files'][1]['url'] == second_file.get_url_path(src='') + assert result['files'][1]['url'] == second_file.get_absolute_url( + src='') assert result['channel'] == 'listed' assert result['edit_url'] == absolutify(addon.get_dev_url( @@ -1168,7 +1169,7 @@ class TestLanguageToolsSerializerOutput(TestCase): assert result['slug'] == self.addon.slug assert result['target_locale'] == self.addon.target_locale assert result['type'] == 'language' - assert result['url'] == absolutify(self.addon.get_url_path()) + assert result['url'] == self.addon.get_absolute_url() assert 'current_compatible_version' not in result assert 'locale_disambiguation' not in result @@ -1266,7 +1267,7 @@ class TestESAddonAutoCompleteSerializer(ESTestCase): assert result['icon_url'] == absolutify(self.addon.get_icon_url(64)) assert result['is_recommended'] == self.addon.is_recommended is False assert result['type'] == 'extension' - assert result['url'] == absolutify(self.addon.get_url_path()) + assert result['url'] == self.addon.get_absolute_url() def test_translations(self): translated_name = { @@ -1398,7 +1399,7 @@ class TestReplacementAddonSerializer(TestCase): assert result['replacement'] == [u'newstuff@mozilla'] # But urls aren't resolved - and don't break everything - rep.update(path=absolutify(addon.get_url_path())) + rep.update(path=addon.get_absolute_url()) result = self.serialize(rep) assert result['guid'] == u'legacy@mozilla' assert result['replacement'] == [] diff --git a/src/olympia/devhub/templates/devhub/addons/submit/done.html b/src/olympia/devhub/templates/devhub/addons/submit/done.html index 4656d65ce5..b0abf8c21f 100644 --- a/src/olympia/devhub/templates/devhub/addons/submit/done.html +++ b/src/olympia/devhub/templates/devhub/addons/submit/done.html @@ -65,7 +65,7 @@
{% set file = uploaded_version.all_files[-1] %} - {{ + {{ _("Download {0}")|format_html(file.pretty_filename()) }}
{% endif %} diff --git a/src/olympia/devhub/templates/devhub/includes/version_file.html b/src/olympia/devhub/templates/devhub/includes/version_file.html index df313e01f4..4e2241ca0e 100644 --- a/src/olympia/devhub/templates/devhub/includes/version_file.html +++ b/src/olympia/devhub/templates/devhub/includes/version_file.html @@ -1,6 +1,6 @@