mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 18:30:53 +00:00
Move group_avatar from group to avatar.
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import os
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.template.defaultfilters import filesizeformat
|
||||
|
||||
from group.settings import ( AVATAR_MAX_SIZE, AVATAR_ALLOWED_FILE_EXTS)
|
||||
|
||||
class MessageForm(forms.Form):
|
||||
message = forms.CharField(max_length=500)
|
||||
@@ -12,19 +8,3 @@ class MessageForm(forms.Form):
|
||||
class MessageReplyForm(forms.Form):
|
||||
message = forms.CharField(max_length=150)
|
||||
|
||||
class AvatarForm(forms.Form):
|
||||
avatar = forms.ImageField()
|
||||
|
||||
def clean_avatar(self):
|
||||
data = self.cleaned_data['avatar']
|
||||
if AVATAR_ALLOWED_FILE_EXTS:
|
||||
(root, ext) = os.path.splitext(data.name.lower())
|
||||
if ext not in AVATAR_ALLOWED_FILE_EXTS:
|
||||
raise forms.ValidationError(
|
||||
_(u"%(ext)s is an invalid file extension. Authorized extensions are : %(valid_exts_list)s") %
|
||||
{ 'ext' : ext, 'valid_exts_list' : ", ".join(AVATAR_ALLOWED_FILE_EXTS) })
|
||||
if data.size > AVATAR_MAX_SIZE:
|
||||
raise forms.ValidationError(
|
||||
_(u"Your file is too big (%(size)s), the maximum allowed size is %(max_valid_size)s") %
|
||||
{ 'size' : filesizeformat(data.size), 'max_valid_size' : filesizeformat(AVATAR_MAX_SIZE)})
|
||||
|
||||
|
Reference in New Issue
Block a user