コード例 #1
0
ファイル: models.py プロジェクト: EnTeQuAk/olympia
    def get_mirror(self, addon, attachment=False):
        if attachment:
            host = posixpath.join(user_media_url('addons'), '_attachments')
        elif addon.is_disabled or self.status == amo.STATUS_DISABLED:
            host = settings.PRIVATE_MIRROR_URL
        else:
            host = user_media_url('addons')

        return posixpath.join(*map(smart_str, [host, addon.id, self.filename]))
コード例 #2
0
ファイル: models.py プロジェクト: crdoconnor/olympia
    def get_mirror(self, addon, attachment=False):
        if attachment:
            host = posixpath.join(user_media_url('addons'), '_attachments')
        elif addon.is_disabled or self.status == amo.STATUS_DISABLED:
            host = settings.PRIVATE_MIRROR_URL
        else:
            host = user_media_url('addons')

        return posixpath.join(*map(smart_str, [host, addon.id, self.filename]))
コード例 #3
0
ファイル: utils.py プロジェクト: aditbiswas1/olympia
def get_mirror(status, id, row):
    if row['disabled_by_user'] or status == STATUS_DISABLED:
        host = settings.PRIVATE_MIRROR_URL
    else:
        host = user_media_url('addons')

    return posixpath.join(host, str(id), row['filename'])
コード例 #4
0
def get_mirror(status, id, row):
    if row['disabled_by_user'] or status == STATUS_DISABLED:
        host = settings.PRIVATE_MIRROR_URL
    else:
        host = user_media_url('addons')

    return posixpath.join(host, str(id), row['filename'])
コード例 #5
0
 def picture_url(self):
     from amo.helpers import user_media_url
     if not self.picture_type:
         return settings.STATIC_URL + '/img/zamboni/anon_user.png'
     else:
         split_id = re.match(r'((\d*?)(\d{0,3}?))\d{1,3}$', str(self.id))
         modified = int(time.mktime(self.modified.timetuple()))
         path = "/".join([
             split_id.group(2) or '0',
             split_id.group(1) or '0',
             "%s.png?modified=%s" % (self.id, modified)
         ])
         return user_media_url('userpics') + path
コード例 #6
0
ファイル: models.py プロジェクト: aditbiswas1/olympia
 def picture_url(self):
     from amo.helpers import user_media_url
     if not self.picture_type:
         return settings.STATIC_URL + '/img/zamboni/anon_user.png'
     else:
         split_id = re.match(r'((\d*?)(\d{0,3}?))\d{1,3}$', str(self.id))
         modified = int(time.mktime(self.modified.timetuple()))
         path = "/".join([
             split_id.group(2) or '0',
             split_id.group(1) or '0',
             "%s.png?modified=%s" % (self.id, modified)
         ])
         return user_media_url('userpics') + path
コード例 #7
0
 def icon_url(self):
     modified = int(time.mktime(self.modified.timetuple()))
     if self.icontype:
         # [1] is the whole ID, [2] is the directory
         split_id = re.match(r'((\d*?)\d{1,3})$', str(self.id))
         path = "/".join([
             split_id.group(2) or '0',
             "%s.png?m=%s" % (self.id, modified)
         ])
         return user_media_url('collection_icons') + path
     elif self.type == amo.COLLECTION_FAVORITES:
         return settings.STATIC_URL + 'img/icons/heart.png'
     else:
         return settings.STATIC_URL + 'img/icons/collection.png'
コード例 #8
0
ファイル: models.py プロジェクト: aditbiswas1/olympia
 def icon_url(self):
     modified = int(time.mktime(self.modified.timetuple()))
     if self.icontype:
         # [1] is the whole ID, [2] is the directory
         split_id = re.match(r'((\d*?)\d{1,3})$', str(self.id))
         path = "/".join([
             split_id.group(2) or '0',
             "%s.png?m=%s" % (self.id, modified)
         ])
         return user_media_url('collection_icons') + path
     elif self.type == amo.COLLECTION_FAVORITES:
         return settings.STATIC_URL + 'img/icons/heart.png'
     else:
         return settings.STATIC_URL + 'img/icons/collection.png'
コード例 #9
0
    def test_url_remote_beta(self):
        file = File.objects.get(pk=67442)
        file.status = amo.STATUS_BETA
        file.save()

        beta_version = '2.0.58 beta'
        file.version.update(version=beta_version)

        data = self.good_data.copy()
        data["version"] = beta_version
        up = self.get(data)
        self.addon_one.status = amo.STATUS_PUBLIC
        self.addon_one.save()
        up.get_rdf()
        eq_(up.data['row']['file_id'], file.pk)
        assert user_media_url('addons') in up.data['row']['url']
コード例 #10
0
ファイル: test_update.py プロジェクト: yohanboniface/olympia
    def test_url_remote_beta(self):
        file = File.objects.get(pk=67442)
        file.status = amo.STATUS_BETA
        file.save()

        beta_version = '2.0.58 beta'
        file.version.update(version=beta_version)

        data = self.good_data.copy()
        data["version"] = beta_version
        up = self.get(data)
        self.addon_one.status = amo.STATUS_PUBLIC
        self.addon_one.save()
        up.get_rdf()
        eq_(up.data['row']['file_id'], file.pk)
        assert user_media_url('addons') in up.data['row']['url']
コード例 #11
0
ファイル: test_update.py プロジェクト: yohanboniface/olympia
 def test_url_local_recent(self):
     a_bit_ago = datetime.now() - timedelta(seconds=60)
     File.objects.get(pk=67442).update(datestatuschanged=a_bit_ago)
     up = self.get(self.good_data)
     up.get_rdf()
     assert user_media_url('addons') in up.data['row']['url']
コード例 #12
0
 def test_image_url(self):
     up = self.get_update('en-US', 15663)
     up.get_update()
     image_url = up.image_url('foo.png')
     assert user_media_url('addons') in image_url
コード例 #13
0
 def test_url_local_recent(self):
     a_bit_ago = datetime.now() - timedelta(seconds=60)
     File.objects.get(pk=67442).update(datestatuschanged=a_bit_ago)
     up = self.get(self.good_data)
     up.get_rdf()
     assert user_media_url('addons') in up.data['row']['url']
コード例 #14
0
 def test_without_settings(self):
     del settings.USERPICS_URL
     settings.MEDIA_URL = '/mediapath/'
     url = helpers.user_media_url('userpics')
     eq_(url, '/mediapath/userpics/')
コード例 #15
0
 def test_image_url(self):
     up = self.get_update("en-US", 15663)
     up.get_update()
     image_url = up.image_url("foo.png")
     assert user_media_url("addons") in image_url
コード例 #16
0
ファイル: tests.py プロジェクト: waytai/olympia
 def assert_served_locally(self, response, file_=None, attachment=False):
     host = settings.SITE_URL + user_media_url('addons')
     if attachment:
         host += '_attachments/'
     self.assert_served_by_host(response, host, file_)
コード例 #17
0
ファイル: tests.py プロジェクト: waytai/olympia
 def assert_served_by_mirror(self, response, file_=None):
     url = settings.SITE_URL + user_media_url('addons')
     self.assert_served_by_host(response, url, file_)
コード例 #18
0
ファイル: test_helpers.py プロジェクト: peterkinalex/olympia
 def test_without_settings(self):
     del settings.USERPICS_URL
     settings.MEDIA_URL = '/mediapath/'
     url = helpers.user_media_url('userpics')
     eq_(url, '/mediapath/userpics/')
コード例 #19
0
 def test_url(self):
     up = self.get(self.good_data)
     up.get_rdf()
     assert user_media_url('addons') in up.data['row']['url']
コード例 #20
0
 def assert_served_locally(self, response, file_=None, attachment=False):
     host = settings.SITE_URL + user_media_url('addons')
     if attachment:
         host += '_attachments/'
     self.assert_served_by_host(response, host, file_)
コード例 #21
0
 def test_image_url(self):
     up = self.get_update('en-US', 15663)
     up.get_update()
     image_url = up.image_url('foo.png')
     assert user_media_url('addons') in image_url
コード例 #22
0
 def assert_served_by_mirror(self, response, file_=None):
     url = settings.SITE_URL + user_media_url('addons')
     self.assert_served_by_host(response, url, file_)
コード例 #23
0
ファイル: test_update.py プロジェクト: yohanboniface/olympia
 def test_url(self):
     up = self.get(self.good_data)
     up.get_rdf()
     assert user_media_url('addons') in up.data['row']['url']