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
|
|
| 1 | import re |
| 2 | |
1 | 3 | from django.core import validators |
2 | 4 | from django.db import models |
3 | 5 | from django.contrib.sites.models import Site |
4 | 6 | from django.utils.translation import ugettext_lazy as _ |
| 7 | from django.core.validators import ValidationError |
| 8 | |
| 9 | validURL_re = re.compile(r'^[-\w/~]+$') |
| 10 | |
| 11 | def 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.") |
5 | 14 | |
6 | 15 | class 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, |
8 | 17 | help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes.")) |
9 | 18 | title = models.CharField(_('title'), max_length=200) |
10 | 19 | content = models.TextField(_('content')) |