1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-20 20:32:44 +00:00
seahub/group/forms.py
2012-10-20 15:22:54 +08:00

47 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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)
class MessageReplyForm(forms.Form):
message = forms.CharField(max_length=150)
class GroupRecommendForm(MessageForm):
"""
A form used to recommend a file or directory.
"""
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
class GroupJoinMsgForm(forms.Form):
"""
A form used to send group join request message.
"""
group_join_msg = forms.CharField(max_length=255, error_messages={
'required': u'验证信息不能为空',
'max_length': u'验证信息太长不超过255个字符',
})