mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 02:42:47 +00:00
Let user choose wiki name and description
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
import os
|
||||
|
||||
from django import forms
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from seaserv import is_valid_filename
|
||||
|
||||
from seahub.utils import validate_group_name
|
||||
|
||||
class MessageForm(forms.Form):
|
||||
@@ -45,3 +47,25 @@ class GroupJoinMsgForm(forms.Form):
|
||||
'max_length': _(u'Verification message is too long (maximun is 255 characters)'),
|
||||
})
|
||||
|
||||
class WikiCreateForm(forms.Form):
|
||||
"""
|
||||
A form used to create wiki.
|
||||
"""
|
||||
repo_name = forms.CharField(max_length=settings.MAX_FILE_NAME,
|
||||
error_messages={
|
||||
'required': _(u'Name can\'t be empty'),
|
||||
'max_length': _(u'Name is too long (maximum is 255 characters)')
|
||||
})
|
||||
repo_desc = forms.CharField(max_length=100, error_messages={
|
||||
'required': _(u'Description can\'t be empty'),
|
||||
'max_length': _(u'Description is too long (maximum is 100 characters)')
|
||||
})
|
||||
|
||||
def clean_repo_name(self):
|
||||
repo_name = self.cleaned_data['repo_name']
|
||||
if not is_valid_filename(repo_name):
|
||||
error_msg = _(u'"%s" is not a valid name') % repo_name
|
||||
raise forms.ValidationError(error_msg)
|
||||
else:
|
||||
return repo_name
|
||||
|
||||
|
Reference in New Issue
Block a user