Django

Code

Ticket #5192: 0001-contrib.flatpages-URL-can-now-contain-tilde.patch

File 0001-contrib.flatpages-URL-can-now-contain-tilde.patch, 1.5 kB (added by ctrochalakis, 4 months ago)

tilde-v1

  • a/django/contrib/flatpages/models.py

    old new  
     1import re 
     2 
    13from django.core import validators 
    24from django.db import models 
    35from django.contrib.sites.models import Site 
    46from django.utils.translation import ugettext_lazy as _ 
     7from django.core.validators import ValidationError 
     8 
     9validURL_re = re.compile(r'^[-\w/~]+$') 
     10 
     11def isValidURL(field_data, all_data): 
     12    if not validURL_re.search(field_data): 
     13        raise ValidationError, _("This value must contain only letters, numbers, underscores, dashes, the tilde, or slashes.") 
    514 
    615class FlatPage(models.Model): 
    7     url = models.CharField(_('URL'), max_length=100, validator_list=[validators.isAlphaNumericURL], db_index=True, 
     16    url = models.CharField(_('URL'), max_length=100, validator_list=[isValidURL], db_index=True, 
    817        help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes.")) 
    918    title = models.CharField(_('title'), max_length=200) 
    1019    content = models.TextField(_('content'))