Exemple #1
0
    def clean_view(self):
        link = self.cleaned_data['view'] or ''
        # It could be a fully-qualified URL -- try that first b/c reverse()
        # chokes on "http://"

        if any([link.startswith(s) for s in ('http://', 'https://')]):
            URLValidator()(link)
            self.url = link
            return self.cleaned_data['view']

        auto = self.cleaned_data['cms_page']

        if not auto:
            if link:
                link, self.url = clean_url(link, include=True, detail=True)
                return link
            raise ValidationError(_('Please supply a valid URL or URL name.'))

        else:  #auto
            if link:
                link, self.url = clean_url(link,
                                           include=True,
                                           detail=True,
                                           lis=True,
                                           existe=False)
                return link
                #try:
                #    re.compile(link)
                #    self.url = link
                #    return link
                #except:
                #    raise forms.ValidationError(_("%s is not a valide Regex." % link))
                #elif link[0] != "/":
                #    self.url = "/"+link
                #else:
                #    self.url = link
                #return link

        parent = self.cleaned_data['parent']
        if parent:
            p_url = parent.url
            if '#' in p_url:
                p_url = p_url[:p_url.find('#')]

            if p_url == "/":
                self.url = "/" + self.cleaned_data['slug']
            elif p_url[-1] != "/":
                self.url = p_url + "/" + self.cleaned_data['slug']
            else:
                self.url = p_url + self.cleaned_data['slug']
        else:
            self.url = "/" + self.cleaned_data['slug']
        return ''
Exemple #2
0
    def clean_view(self):
        link = self.cleaned_data['view'] or ''
        # It could be a fully-qualified URL -- try that first b/c reverse()
        # chokes on "http://"

        if any([link.startswith(s) for s in ('http://', 'https://')]):
            URLValidator()(link)
            self.url = link
            return self.cleaned_data['view']

        auto = self.cleaned_data['cms_page']

        if not auto:
            if link:
               link,self.url = clean_url(link,include=True,detail=True)
               return link
            raise ValidationError(_('Please supply a valid URL or URL name.'))

        else: #auto
            if link:
                link,self.url = clean_url(link,include=True,detail=True,lis=True,existe=False)
                return link
                #try:
                #    re.compile(link)
                #    self.url = link
                #    return link
                #except:
                #    raise forms.ValidationError(_("%s is not a valide Regex." % link))
                #elif link[0] != "/":
                #    self.url = "/"+link
                #else:
                #    self.url = link
                #return link
        
        parent = self.cleaned_data['parent']
        if parent:
            p_url = parent.url
            if '#' in p_url:
                p_url = p_url[:p_url.find('#')]

            if p_url == "/":
                self.url = "/"+self.cleaned_data['slug'] 
            elif p_url[-1] != "/":
                self.url = p_url +"/"+self.cleaned_data['slug']
            else:
                self.url = p_url +self.cleaned_data['slug'] 
        else:
            self.url = "/"+self.cleaned_data['slug']
        return ''
Exemple #3
0
 def clean_view(self):
     view = self.cleaned_data['view']
     self.url = view
     if view:
         view, self.url = clean_url(view)
     if view and view[-1] != "/":
         self.url += "/"
     return view
Exemple #4
0
 def clean_view(self):
     view = self.cleaned_data['view']
     self.url = view
     if view:
         view,self.url = clean_url(view)
     if view and view[-1] != "/":
         self.url+="/"
     return view