~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to wlggz/forms.py

  • Committer: franku
  • Date: 2019-04-09 06:34:51 UTC
  • mfrom: (530.1.5 mv_main_files)
  • Revision ID: somal@arcor.de-20190409063451-orglu7d2oda37ej9
moved files stored in folder widelands to folder widelands/mainpage

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
import hashlib
14
14
import base64
15
 
import settings
16
 
import re
 
15
 
17
16
 
18
17
class EditGGZForm(forms.ModelForm):
19
 
    password = forms.CharField(label=_(u'GGZ password'), widget = forms.PasswordInput(render_value = False), required=True)
 
18
    password = forms.CharField(label=_(u'Online Gaming Password'),
 
19
                               widget=forms.PasswordInput(render_value=False), required=True)
20
20
 
21
21
    class Meta:
22
22
        model = GGZAuth
23
 
        fields = [ 'password', ]
 
23
        fields = ['password', ]
24
24
 
25
25
    def __init__(self, *args, **kwargs):
26
 
        instance = kwargs.pop("instance")
 
26
        instance = kwargs.pop('instance')
27
27
 
28
 
        super(EditGGZForm, self).__init__(instance=instance, *args,**kwargs)
 
28
        super(EditGGZForm, self).__init__(instance=instance, *args, **kwargs)
29
29
 
30
30
    def clean_password(self):
31
31
        pw = self.cleaned_data['password']
32
 
        pw_hash = hashlib.sha1(pw).digest()
 
32
        pw_hash = hashlib.sha1(pw.encode('utf-8')).digest()
33
33
        pw_base64 = base64.standard_b64encode(pw_hash)
34
34
        return pw_base64
35
35
 
36
 
 
37
36
    def save(self, *args, **kwargs):
38
37
        super(EditGGZForm, self).save(*args, **kwargs)
39