~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to wlggz/forms.py

  • Committer: Holger Rapp
  • Date: 2010-01-01 21:35:23 UTC
  • mto: (173.3.2 widelands)
  • mto: This revision was merged to the branch mainline in revision 176.
  • Revision ID: rapp@mrt.uka.de-20100101213523-53rcapbemm69ep6u
Made the site compatible to django 1.1 and all the various packages

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 Timo Wingender <timo.wingender@gmx.de> on 2010-06-02.
5
 
#
6
 
# Last Modified: $Date$
7
 
#
8
 
 
9
 
from django import forms
10
 
from models import GGZAuth
11
 
from django.utils.translation import ugettext_lazy as _
12
 
 
13
 
import hashlib
14
 
import base64
15
 
import settings
16
 
import re
17
 
 
18
 
class EditGGZForm(forms.ModelForm):
19
 
    password = forms.CharField(label=_(u'GGZ password'), widget = forms.PasswordInput(render_value = False), required=True)
20
 
 
21
 
    class Meta:
22
 
        model = GGZAuth
23
 
        fields = [ 'password', ]
24
 
 
25
 
    def __init__(self, *args, **kwargs):
26
 
        instance = kwargs.pop("instance")
27
 
 
28
 
        super(EditGGZForm, self).__init__(instance=instance, *args,**kwargs)
29
 
 
30
 
    def clean_password(self):
31
 
        pw = self.cleaned_data['password']
32
 
        pw_hash = hashlib.sha1(pw).digest()
33
 
        pw_base64 = base64.standard_b64encode(pw_hash)
34
 
        return pw_base64
35
 
 
36
 
 
37
 
    def save(self, *args, **kwargs):
38
 
        super(EditGGZForm, self).save(*args, **kwargs)
39