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-11-05 08:55:39 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
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
|
|
|
"""
|
|
|
|
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-11-05 08:55:39 +00:00
|
|
|
'required': _(u'Group name can\'t be empty'),
|
|
|
|
'max_length': _(u'Group name is too long (maximum is 255 characters)'),
|
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-11-05 08:55:39 +00:00
|
|
|
error_msg = _(u'Group name can only contain letters, numbers or underline')
|
2012-09-18 06:04:47 +00:00
|
|
|
raise forms.ValidationError(error_msg)
|
|
|
|
else:
|
|
|
|
return group_name
|
2012-09-26 09:05:32 +00:00
|
|
|
|
|
|
|
class GroupJoinMsgForm(forms.Form):
|
|
|
|
"""
|
|
|
|
A form used to send group join request message.
|
|
|
|
"""
|
|
|
|
group_join_msg = forms.CharField(max_length=255, error_messages={
|
2012-11-05 08:55:39 +00:00
|
|
|
'required': _(u'Verification message can\'t be empty'),
|
|
|
|
'max_length': _(u'Verification message is too long (maximun is 255 characters)'),
|
2012-09-26 09:05:32 +00:00
|
|
|
})
|
|
|
|
|