Esempio n. 1
0
def verify_app_domain(manifest_url):
    if waffle.switch_is_active('webapps-unique-by-domain'):
        domain = Webapp.domain_from_url(manifest_url)
        if Addon.objects.filter(app_domain=domain).exists():
            raise forms.ValidationError(
                _('An app already exists on this domain, '
                  'only one app per domain is allowed.'))
Esempio n. 2
0
def verify_app_domain(manifest_url):
    if waffle.switch_is_active('webapps-unique-by-domain'):
        domain = Webapp.domain_from_url(manifest_url)
        if Addon.objects.filter(app_domain=domain).exists():
            raise forms.ValidationError(
                _('An app already exists on this domain, '
                  'only one app per domain is allowed.'))
Esempio n. 3
0
def verify_app_domain(manifest_url, exclude=None, packaged=False):
    if packaged or waffle.switch_is_active('webapps-unique-by-domain'):
        domain = Webapp.domain_from_url(manifest_url)
        qs = Webapp.objects.filter(app_domain=domain)
        if exclude:
            qs = qs.exclude(pk=exclude.pk)
        if qs.exists():
            raise forms.ValidationError(
                _('An app already exists on this domain; '
                  'only one app per domain is allowed.'))
Esempio n. 4
0
def verify_app_domain(manifest_url, exclude=None):
    if waffle.switch_is_active('webapps-unique-by-domain'):
        domain = Webapp.domain_from_url(manifest_url)
        qs = Webapp.objects.filter(app_domain=domain)
        if exclude:
            qs = qs.exclude(pk=exclude.pk)
        if qs.exists():
            raise forms.ValidationError(
                _('An app already exists on this domain; '
                  'only one app per domain is allowed.'))
Esempio n. 5
0
 def test_normalize_case(self):
     eq_(Webapp.domain_from_url('httP://mOzIllA.com/'),
         'http://mozilla.com')
Esempio n. 6
0
 def test_none(self):
     Webapp.domain_from_url(None)
Esempio n. 7
0
 def test_normalize_www(self):
     eq_(Webapp.domain_from_url("http://www.mozilla.com/super/rad.webapp"), "mozilla.com")
Esempio n. 8
0
 def test_https(self):
     eq_(Webapp.domain_from_url('https://mozilla.com/'),
         'https://mozilla.com')
Esempio n. 9
0
 def test_none(self):
     Webapp.domain_from_url(None)
Esempio n. 10
0
 def test_empty_or_none(self):
     eq_(Webapp.domain_from_url(None, allow_none=True), None)
Esempio n. 11
0
 def test_with_port(self):
     eq_(Webapp.domain_from_url('http://mozilla.com:9000/'),
         'http://mozilla.com:9000')
Esempio n. 12
0
 def test_long_path(self):
     eq_(Webapp.domain_from_url("http://mozilla.com/super/rad.webapp"), "http://mozilla.com")
Esempio n. 13
0
 def test_empty_or_none(self):
     eq_(Webapp.domain_from_url(None, allow_none=True), None)
Esempio n. 14
0
 def test_long_path(self):
     eq_(Webapp.domain_from_url('http://mozilla.com/super/rad.webapp'),
         'http://mozilla.com')
Esempio n. 15
0
 def test_https(self):
     eq_(Webapp.domain_from_url("https://mozilla.com/"), "https://mozilla.com")
Esempio n. 16
0
 def test_subdomains(self):
     eq_(Webapp.domain_from_url("http://apps.mozilla.com/"), "http://apps.mozilla.com")
Esempio n. 17
0
 def test_with_port(self):
     eq_(Webapp.domain_from_url("http://mozilla.com:9000/"), "http://mozilla.com:9000")
Esempio n. 18
0
 def test_empty(self):
     Webapp.domain_from_url('')
Esempio n. 19
0
 def test_https(self):
     eq_(Webapp.domain_from_url('https://mozilla.com/'),
         'https://mozilla.com')
Esempio n. 20
0
 def test_simple(self):
     eq_(Webapp.domain_from_url('http://mozilla.com/'),
         'http://mozilla.com')
Esempio n. 21
0
 def test_simple(self):
     eq_(Webapp.domain_from_url("http://mozilla.com/"), "http://mozilla.com")
Esempio n. 22
0
 def test_no_normalize_www(self):
     eq_(Webapp.domain_from_url('http://www.mozilla.com/super/rad.webapp'),
         'http://www.mozilla.com')
Esempio n. 23
0
 def test_simple(self):
     eq_(Webapp.domain_from_url('http://mozilla.com/'),
         'http://mozilla.com')
Esempio n. 24
0
 def test_subdomains(self):
     eq_(Webapp.domain_from_url('http://apps.mozilla.com/'),
         'http://apps.mozilla.com')
Esempio n. 25
0
 def test_long_path(self):
     eq_(Webapp.domain_from_url('http://mozilla.com/super/rad.webapp'),
         'http://mozilla.com')
Esempio n. 26
0
 def test_normalize_case(self):
     eq_(Webapp.domain_from_url('httP://mOzIllA.com/'),
         'http://mozilla.com')
Esempio n. 27
0
 def test_no_normalize_www(self):
     eq_(Webapp.domain_from_url('http://www.mozilla.com/super/rad.webapp'),
         'http://www.mozilla.com')
Esempio n. 28
0
 def test_empty(self):
     Webapp.domain_from_url('')
Esempio n. 29
0
 def test_with_port(self):
     eq_(Webapp.domain_from_url('http://mozilla.com:9000/'),
         'http://mozilla.com:9000')
Esempio n. 30
0
 def test_subdomains(self):
     eq_(Webapp.domain_from_url('http://apps.mozilla.com/'),
         'http://apps.mozilla.com')
Esempio n. 31
0
def run():
    for app in Webapp.objects.all():
        if app.manifest_url:
            app.update(app_domain=Webapp.domain_from_url(app.manifest_url))