~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to pybb/forms.py

  • Committer: Holger Rapp
  • Date: 2009-03-15 16:40:37 UTC
  • mto: This revision was merged to the branch mainline in revision 64.
  • Revision ID: sirver@kallisto.local-20090315164037-6sbx3vlo089d46e8
Added support for profiles. No gravatar yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
from django.utils.translation import ugettext as _
8
8
from django.contrib.auth.models import User
9
9
 
10
 
from pybb.models import Topic, Post, Profile, PrivateMessage, Attachment
 
10
from pybb.models import Topic, Post, PrivateMessage, Attachment
11
11
from pybb import settings as pybb_settings
12
12
 
13
13
class AddPostForm(forms.ModelForm):
76
76
            obj.save()
77
77
 
78
78
 
79
 
class EditProfileForm(forms.ModelForm):
80
 
    class Meta:
81
 
        model = Profile
82
 
        fields = ['site', 'jabber', 'icq', 'msn', 'aim', 'yahoo',
83
 
                  'location', 'signature', 'time_zone', 'language',
84
 
                  'avatar', 'show_signatures',
85
 
                  'markup',
86
 
                  ]
87
 
 
88
 
 
89
 
    #def __init__(self, *args, **kwargs):
90
 
        #super(EditProfileForm, self).__init__(*args, **kwargs)
91
 
 
92
 
    def clean_signature(self):
93
 
        value = self.cleaned_data['signature'].strip()
94
 
        if len(re.findall(r'\n', value)) > pybb_settings.SIGNATURE_MAX_LINES:
95
 
            raise forms.ValidationError('Number of lines is limited to %d' % pybb_settings.SIGNATURE_MAX_LINES)
96
 
        if len(value) > pybb_settings.SIGNATURE_MAX_LENGTH:
97
 
            raise forms.ValidationError('Length of signature is limited to %d' % pybb_settings.SIGNATURE_MAX_LENGTH)
98
 
        return value
99
79
 
100
80
class EditPostForm(forms.ModelForm):
101
81
    class Meta: