1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 08:53:14 +00:00

Clean business group add

This commit is contained in:
xiez
2012-09-18 14:04:47 +08:00
parent 5d0fc681e8
commit 9c93e1a740
11 changed files with 140 additions and 105 deletions

View File

@@ -1,7 +1,10 @@
# encoding: utf-8
import os
from django import forms
from seahub.utils import validate_group_name
class MessageForm(forms.Form):
message = forms.CharField(max_length=500)
@@ -16,3 +19,19 @@ class GroupRecommendForm(MessageForm):
repo_id = forms.CharField(max_length=40)
path = forms.CharField()
attach_type = forms.CharField(max_length=5)
class GroupAddForm(forms.Form):
"""
A form used to add a new group.
"""
group_name = forms.CharField(max_length=255, error_messages={
'required': u'小组名称不能为空',
'max_length': u'小组名称太长不超过255个字符',
})
def clean_group_name(self):
group_name = self.cleaned_data['group_name']
if not validate_group_name(group_name):
error_msg = u'小组名称只能包含中英文字符,数字及下划线。'
raise forms.ValidationError(error_msg)
else:
return group_name