コード例 #1
0
ファイル: validation.py プロジェクト: peppelinux/peer
def validate_domain_in_entityid(entity, doc, user=None):
    """
    Makes sure the entityid url belongs to the domain of the entity
    """
    errors, metadata = _parse_metadata(doc)
    if errors:
        return errors

    domain = entity.domain.name
    if user is None:
        user = entity.domain.owner

    url = urlparse.urlparse(metadata.entityid)
    if not check_superdomain_verified(url.netloc.lower(), user=user):
        errors.append(u'The entityid does not belong to the domain %s'
                      u' or to any of its subdomains.' % domain)

    return errors
コード例 #2
0
ファイル: validation.py プロジェクト: Emergya/peer
def validate_domain_in_entityid(entity, doc, user=None):
    """
    Makes sure the entityid url belongs to the domain of the entity
    """
    errors, metadata = _parse_metadata(doc)
    if errors:
        return errors

    domain = entity.domain.name
    if user is None:
        user = entity.domain.owner

    url = urlparse.urlparse(metadata.entityid)
    if not check_superdomain_verified(url.netloc.lower(), user=user):
        errors.append(
            u'The entityid does not belong to the domain %s'
            u' or to any of its subdomains.' % domain)

    return errors
コード例 #3
0
ファイル: validation.py プロジェクト: peppelinux/peer
def validate_domain_in_endpoints(entity, doc, user=None):
    """
    Makes sure the endpoints urls belongs to the domain of the entity
    """
    errors, metadata = _parse_metadata(doc)
    if errors:
        return errors

    domain = entity.domain.name
    if user is None:
        user = entity.domain.owner

    for endpoint in metadata.endpoints:
        if 'Location' in endpoint:
            url = urlparse.urlparse(endpoint['Location'])
            if not check_superdomain_verified(url.hostname.lower(), user=user):
                errors.append(
                    u'The endpoint at %s does not belong to the domain %s'
                    u' or to any of its subdomains.' %
                    (endpoint['Location'], domain))

    return errors
コード例 #4
0
ファイル: validation.py プロジェクト: Emergya/peer
def validate_domain_in_endpoints(entity, doc, user=None):
    """
    Makes sure the endpoints urls belongs to the domain of the entity
    """
    errors, metadata = _parse_metadata(doc)
    if errors:
        return errors

    domain = entity.domain.name
    if user is None:
        user = entity.domain.owner

    for endpoint in metadata.endpoints:
        if 'Location' in endpoint:
            url = urlparse.urlparse(endpoint['Location'])
            if not check_superdomain_verified(url.hostname.lower(), user=user):
                errors.append(
                    u'The endpoint at %s does not belong to the domain %s'
                    u' or to any of its subdomains.' %
                    (endpoint['Location'], domain))

    return errors
コード例 #5
0
ファイル: views.py プロジェクト: enriquepablo/peer
def domain_add(request):
    if request.method == 'POST':
        form = DomainForm(request.POST)
        if form.is_valid():
            messages.success(request, _(u'Domain created'))
            instance = form.save(commit=False)
            instance.owner = request.user
            if check_superdomain_verified(instance):
                return _domain_validate(request, instance)
            instance.save()
            return HttpResponseRedirect(
                reverse('domain_verify',
                        kwargs={'domain_id': instance.id}))
        else:
            messages.error(request, _('Please correct the errors'
                                      ' indicated below'))

    else:
        form = DomainForm()

    return render_to_response('domain/add.html', {
        'form': form,
    }, context_instance=RequestContext(request))
コード例 #6
0
ファイル: views.py プロジェクト: peppelinux/peer
def domain_add(request):
    if request.method == 'POST':
        form = DomainForm(request.POST)
        if form.is_valid():
            messages.success(request, _(u'Domain created'))
            instance = form.save(commit=False)
            instance.owner = request.user
            if check_superdomain_verified(instance):
                return _domain_validate(request, instance)
            instance.save()
            return HttpResponseRedirect(
                reverse('domain_verify',
                        kwargs={'domain_id': instance.id}))
        else:
            messages.error(request, _('Please correct the errors'
                                      ' indicated below'))

    else:
        form = DomainForm()

    return render_to_response('domain/add.html', {
        'form': form,
    }, context_instance=RequestContext(request))