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, 17 years ago)

tilde-v1

  • django/contrib/flatpages/models.py

    From 3cd9bdf800d2ad2031c82ef14344740f12cb5ccc Mon Sep 17 00:00:00 2001
    From: Christos Trochalakis <yatiohi@ideopolis.gr>
    Date: Mon, 14 Jan 2008 19:37:42 +0200
    Subject: [PATCH] contrib.flatpages: URL can now contain tilde
    
    ---
     django/contrib/flatpages/models.py |   11 ++++++++++-
     1 files changed, 10 insertions(+), 1 deletions(-)
    
    diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py
    index 36327c8..f41d753 100644
    a b  
     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'))
Back to Top