- Added PricingPlan Model
- Implement a complete cycle for buying a Matrix Chat Host - Refactor the Payement cycle and stripe related methods
This commit is contained in:
parent
e205d8d07c
commit
b7aa1c6971
81 changed files with 5079 additions and 810 deletions
34
matrixhosting/validators.py
Normal file
34
matrixhosting/validators.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from django.core.validators import RegexValidator
|
||||
|
||||
|
||||
def _validator():
|
||||
|
||||
ul = '\u00a1-\uffff' # unicode letters range (must not be a raw string)
|
||||
|
||||
# IP patterns
|
||||
ipv4_re = r'(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}'
|
||||
ipv6_re = r'\[[0-9a-f:\.]+\]' # (simple regex, validated later)
|
||||
|
||||
# Host patterns
|
||||
hostname_re = r'[a-z' + ul + \
|
||||
r'0-9](?:[a-z' + ul + r'0-9-]{0,61}[a-z' + ul + r'0-9])?'
|
||||
# Max length for domain name labels is 63 characters per RFC 1034 sec. 3.1
|
||||
domain_re = r'(?:\.(?!-)[a-z' + ul + r'0-9-]{1,63}(?<!-))*'
|
||||
tld_re = (
|
||||
r'\.' # dot
|
||||
r'(?!-)' # can't start with a dash
|
||||
r'(?:[a-z' + ul + '-]{2,63}' # domain label
|
||||
r'|xn--[a-z0-9]{1,59})' # or punycode label
|
||||
r'(?<!-)' # can't end with a dash
|
||||
r'\.?' # may have a trailing dot
|
||||
r'/?'
|
||||
)
|
||||
host_re = '(' + hostname_re + domain_re + tld_re + ')'
|
||||
regex = (
|
||||
r'(?:' + ipv4_re + '|' + ipv6_re + '|' + host_re + ')'
|
||||
r'(?::\d{2,5})?' # port
|
||||
r'\Z')
|
||||
return RegexValidator(regex, message='Enter a valid Domain (Not a URL)', code='invalid_domain')
|
||||
|
||||
|
||||
domain_name_validator = _validator()
|
||||
Loading…
Add table
Add a link
Reference in a new issue