1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-28 19:51:34 +00:00
seahub/organizations/forms.py

20 lines
782 B
Python
Raw Normal View History

2012-07-26 09:08:31 +00:00
# encoding: utf-8
from django import forms
from seaserv import ccnet_threaded_rpc
class OrgCreateForm(forms.Form):
org_name = forms.CharField(max_length=256,
widget=forms.TextInput(),
label="Organization Name")
url_prefix = forms.RegexField(label="Url Prefix", max_length=20,
regex=r'^[a-z0-9]+$',
error_message="域名前缀只能包含字母或数字")
def clean_url_prefix(self):
url_prefix = self.cleaned_data['url_prefix']
org = ccnet_threaded_rpc.get_org_by_url_prefix(url_prefix)
if not org:
return url_prefix
else:
raise forms.ValidationError("该域名前缀已被注册")