Beispiel #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.'))
Beispiel #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.'))
Beispiel #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.'))
Beispiel #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.'))
Beispiel #5
0
 def test_normalize_case(self):
     eq_(Webapp.domain_from_url('httP://mOzIllA.com/'),
         'http://mozilla.com')
Beispiel #6
0
 def test_none(self):
     Webapp.domain_from_url(None)
Beispiel #7
0
 def test_normalize_www(self):
     eq_(Webapp.domain_from_url("http://www.mozilla.com/super/rad.webapp"), "mozilla.com")
Beispiel #8
0
 def test_https(self):
     eq_(Webapp.domain_from_url('https://mozilla.com/'),
         'https://mozilla.com')
Beispiel #9
0
 def test_none(self):
     Webapp.domain_from_url(None)
Beispiel #10
0
 def test_empty_or_none(self):
     eq_(Webapp.domain_from_url(None, allow_none=True), None)
Beispiel #11
0
 def test_with_port(self):
     eq_(Webapp.domain_from_url('http://mozilla.com:9000/'),
         'http://mozilla.com:9000')
Beispiel #12
0
 def test_long_path(self):
     eq_(Webapp.domain_from_url("http://mozilla.com/super/rad.webapp"), "http://mozilla.com")
Beispiel #13
0
 def test_empty_or_none(self):
     eq_(Webapp.domain_from_url(None, allow_none=True), None)
Beispiel #14
0
 def test_long_path(self):
     eq_(Webapp.domain_from_url('http://mozilla.com/super/rad.webapp'),
         'http://mozilla.com')
Beispiel #15
0
 def test_https(self):
     eq_(Webapp.domain_from_url("https://mozilla.com/"), "https://mozilla.com")
Beispiel #16
0
 def test_subdomains(self):
     eq_(Webapp.domain_from_url("http://apps.mozilla.com/"), "http://apps.mozilla.com")
Beispiel #17
0
 def test_with_port(self):
     eq_(Webapp.domain_from_url("http://mozilla.com:9000/"), "http://mozilla.com:9000")
Beispiel #18
0
 def test_empty(self):
     Webapp.domain_from_url('')
Beispiel #19
0
 def test_https(self):
     eq_(Webapp.domain_from_url('https://mozilla.com/'),
         'https://mozilla.com')
Beispiel #20
0
 def test_simple(self):
     eq_(Webapp.domain_from_url('http://mozilla.com/'),
         'http://mozilla.com')
Beispiel #21
0
 def test_simple(self):
     eq_(Webapp.domain_from_url("http://mozilla.com/"), "http://mozilla.com")
Beispiel #22
0
 def test_no_normalize_www(self):
     eq_(Webapp.domain_from_url('http://www.mozilla.com/super/rad.webapp'),
         'http://www.mozilla.com')
Beispiel #23
0
 def test_simple(self):
     eq_(Webapp.domain_from_url('http://mozilla.com/'),
         'http://mozilla.com')
Beispiel #24
0
 def test_subdomains(self):
     eq_(Webapp.domain_from_url('http://apps.mozilla.com/'),
         'http://apps.mozilla.com')
Beispiel #25
0
 def test_long_path(self):
     eq_(Webapp.domain_from_url('http://mozilla.com/super/rad.webapp'),
         'http://mozilla.com')
Beispiel #26
0
 def test_normalize_case(self):
     eq_(Webapp.domain_from_url('httP://mOzIllA.com/'),
         'http://mozilla.com')
Beispiel #27
0
 def test_no_normalize_www(self):
     eq_(Webapp.domain_from_url('http://www.mozilla.com/super/rad.webapp'),
         'http://www.mozilla.com')
Beispiel #28
0
 def test_empty(self):
     Webapp.domain_from_url('')
Beispiel #29
0
 def test_with_port(self):
     eq_(Webapp.domain_from_url('http://mozilla.com:9000/'),
         'http://mozilla.com:9000')
Beispiel #30
0
 def test_subdomains(self):
     eq_(Webapp.domain_from_url('http://apps.mozilla.com/'),
         'http://apps.mozilla.com')
def run():
    for app in Webapp.objects.all():
        if app.manifest_url:
            app.update(app_domain=Webapp.domain_from_url(app.manifest_url))