# Path: src/hydra/utils.py
# def in_whitelist(project, url):
#     parsed_url = urlparse(url)
#     if parsed_url.scheme == '':
#         return False, 'url must be absolute'
#     project = RedisProject(project)
#     results = [parsed_url.netloc.endswith('.%s' % domain)
#                for domain in project.whitelist]
#     results.append(parsed_url.netloc in project.whitelist)
#     if not any(results):
#         return False, '%s is not on a domain in the whitelist.' % url
#     return True, ''


from django import forms
from .utils import in_whitelist



class SlugForm(forms.Form):
    project = forms.CharField(max_length=255)
    slug = forms.CharField(max_length=255)
    url = forms.URLField()

    def clean_url(self):
        url = self.cleaned_data['url']
        project = self.cleaned_data['project']

# Path: src/hydra/utils.py
# def in_whitelist(project, url):
#     parsed_url = urlparse(url)
#     if parsed_url.scheme == '':
#         return False, 'url must be absolute'
#     project = RedisProject(project)
#     results = [parsed_url.netloc.endswith('.%s' % domain)
#                for domain in project.whitelist]
#     results.append(parsed_url.netloc in project.whitelist)
#     if not any(results):
#         return False, '%s is not on a domain in the whitelist.' % url
#     return True, ''


# Path: src/hydra/forms.py
from django import forms
from .utils import in_whitelist




class SlugForm(forms.Form):
    project = forms.CharField(max_length=255)
    slug = forms.CharField(max_length=255)
    url = forms.URLField()

    def clean_url(self):
        url = self.cleaned_data['url']
        project = self.cleaned_data['project']

        valid, msg = in_whitelist(project, url)