Adding fugue-icons submodule and adding django-staticmedia to the list of prerequisites.
[philo.git] / validators.py
1 from django.utils.translation import ugettext_lazy as _
2 from django.core.validators import RegexValidator
3 import re
4
5
6 class RedirectValidator(RegexValidator):
7         """Based loosely on the URLValidator, but no option to verify_exists"""
8         regex = re.compile(
9                 r'^(?:https?://' # http:// or https://
10                 r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' #domain...
11                 r'localhost|' #localhost...
12                 r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
13                 r'(?::\d+)?' # optional port
14                 r'(?:/?|[/?#]?\S+)|'
15                 r'[^?#\s]\S*)$',
16                 re.IGNORECASE)
17         message = _(u'Enter a valid absolute or relative redirect target')
18
19
20 class URLLinkValidator(RegexValidator):
21         """Based loosely on the URLValidator, but no option to verify_exists"""
22         regex = re.compile(
23                 r'^(?:https?://' # http:// or https://
24                 r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' #domain...
25                 r'localhost|' #localhost...
26                 r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
27                 r'(?::\d+)?' # optional port
28                 r'|)' # also allow internal links
29                 r'(?:/?|[/?#]?\S+)$', re.IGNORECASE)
30         message = _(u'Enter a valid absolute or relative redirect target')