1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-04-28 19:25:03 +00:00
seahub/group/forms.py

38 lines
1.1 KiB
Python
Raw Normal View History

2012-09-18 06:04:47 +00:00
# encoding: utf-8
2012-07-11 07:13:59 +00:00
import os
2012-06-25 06:57:14 +00:00
from django import forms
2012-09-18 06:04:47 +00:00
from seahub.utils import validate_group_name
2012-06-25 06:57:14 +00:00
class MessageForm(forms.Form):
2012-08-10 13:20:01 +00:00
message = forms.CharField(max_length=500)
2012-06-25 06:57:14 +00:00
2012-06-27 03:27:00 +00:00
class MessageReplyForm(forms.Form):
message = forms.CharField(max_length=150)
2012-07-11 07:13:59 +00:00
2012-08-13 07:58:54 +00:00
class GroupRecommendForm(MessageForm):
2012-08-10 13:16:55 +00:00
"""
2012-08-13 07:58:54 +00:00
A form used to recommend a file or directory.
2012-08-10 13:16:55 +00:00
"""
groups = forms.CharField()
repo_id = forms.CharField(max_length=40)
2012-08-13 07:58:54 +00:00
path = forms.CharField()
attach_type = forms.CharField(max_length=5)
2012-09-18 06:04:47 +00:00
class GroupAddForm(forms.Form):
"""
A form used to add a new group.
"""
group_name = forms.CharField(max_length=255, error_messages={
2012-09-24 02:10:01 +00:00
'required': u'群组名称不能为空',
'max_length': u'群组名称太长不超过255个字符',
2012-09-18 06:04:47 +00:00
})
def clean_group_name(self):
group_name = self.cleaned_data['group_name']
if not validate_group_name(group_name):
2012-09-24 02:10:01 +00:00
error_msg = u'群组名称只能包含中英文字符,数字及下划线。'
2012-09-18 06:04:47 +00:00
raise forms.ValidationError(error_msg)
else:
return group_name