~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to wlprofile/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:
 
1
#!/usr/bin/env python -tt
 
2
# encoding: utf-8
 
3
#
 
4
# Created by Holger Rapp on 2009-03-15.
 
5
#
 
6
# Last Modified: $Date$
 
7
#
 
8
 
 
9
from django import forms
 
10
from models import Profile
 
11
 
 
12
import settings
 
13
import re
 
14
 
 
15
class EditProfileForm(forms.ModelForm):
 
16
    class Meta:
 
17
        model = Profile
 
18
        fields = ['site', 'jabber', 'icq', 'msn', 'aim', 'yahoo',
 
19
                  'location', 'signature', 'time_zone', "time_display", 'language',
 
20
                  'avatar', 'show_signatures',
 
21
                  'markup',
 
22
                  ]
 
23
 
 
24
 
 
25
    #def __init__(self, *args, **kwargs):
 
26
        #super(EditProfileForm, self).__init__(*args, **kwargs)
 
27
 
 
28
    def clean_signature(self):
 
29
        value = self.cleaned_data['signature'].strip()
 
30
        if len(re.findall(r'\n', value)) > settings.SIGNATURE_MAX_LINES:
 
31
            raise forms.ValidationError('Number of lines is limited to %d' % _settings.SIGNATURE_MAX_LINES)
 
32
        if len(value) > settings.SIGNATURE_MAX_LENGTH:
 
33
            raise forms.ValidationError('Length of signature is limited to %d' % settings.SIGNATURE_MAX_LENGTH)
 
34
        return value
 
35