Merge lp:~widelands-dev/widelands-website/gaming_password into lp:widelands-website

Proposed by kaputtnik
Status: Merged
Merged at revision: 536
Proposed branch: lp:~widelands-dev/widelands-website/gaming_password
Merge into: lp:widelands-website
Diff against target: 243 lines (+53/-33)
10 files modified
templates/django_messages/base.html (+1/-3)
wlggz/forms.py (+8/-11)
wlggz/models.py (+10/-0)
wlggz/templates/wlggz/edit_ggz.html (+14/-3)
wlggz/views.py (+5/-1)
wlprofile/templates/wlprofile/base.html (+4/-11)
wlprofile/templates/wlprofile/edit_profile.html (+0/-1)
wlprofile/templates/wlprofile/view_profile.html (+5/-0)
wlprofile/views.py (+4/-1)
wlscheduling/templates/wlscheduling/base.html (+2/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands-website/gaming_password
Reviewer Review Type Date Requested Status
GunChleoc Approve
kaputtnik (community) Needs Resubmitting
Review via email: mp+367448@code.launchpad.net

Commit message

Better place for setting the online gaming password

Description of the change

Rework of a users profile page:

Removed tabs, because the links are also in the loginbox:
- Messages
- Scheduler

Added tab:
- Gaming Password
- Renamed Tab 'E-Mail settings' -> 'Notification Settings'

Added an additional edit field for setting the gaming password, so the password has to be entered two times. Added a check to compare the entered data and give an errormessage if the passwords didn't match.

Added some help text.

Moved hashing of password to models.py, because i think it fits better over there.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

Some string nits, rest LGTM :)

542. By kaputtnik

wording

Revision history for this message
kaputtnik (franku) wrote :

Many thanks :-)

543. By kaputtnik

switch to profile main view after set gaming password

544. By kaputtnik

give a success message when a user edits his profile or gaming password

Revision history for this message
kaputtnik (franku) wrote :

Commit 544 give's a user some sort of success messages when he edits his profile or gaming password. After saving both views (edit_profile and edit_ggz) the user is redirected to the main profile view, where the success message is shown centered on the top.

I guess my new english sentences are fine, but could you please look again?

review: Needs Resubmitting
Revision history for this message
GunChleoc (gunchleoc) wrote :

Yes, they are fine :)

review: Approve
Revision history for this message
kaputtnik (franku) wrote :

Thanks, merged and deployed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'templates/django_messages/base.html'
--- templates/django_messages/base.html 2019-02-23 19:02:18 +0000
+++ templates/django_messages/base.html 2019-05-16 06:21:17 +0000
@@ -1,4 +1,4 @@
1{% extends "wlprofile/base.html" %}1{% extends "mainpage/base.html" %}
2{% load i18n %}2{% load i18n %}
3{% load static %}3{% load static %}
44
@@ -9,8 +9,6 @@
9 <script type="text/javascript" src="{% static 'js/jquery-ui.min.js' %}"></script>9 <script type="text/javascript" src="{% static 'js/jquery-ui.min.js' %}"></script>
10{{ block.super}}{% endblock %}10{{ block.super}}{% endblock %}
1111
12{% block messages %}class="active"{% endblock %}
13
14{% block title %}12{% block title %}
15Messages - {{block.super}}13Messages - {{block.super}}
16{% endblock %}14{% endblock %}
1715
=== modified file 'wlggz/forms.py'
--- wlggz/forms.py 2019-03-05 08:47:47 +0000
+++ wlggz/forms.py 2019-05-16 06:21:17 +0000
@@ -10,13 +10,12 @@
10from models import GGZAuth10from models import GGZAuth
11from django.utils.translation import ugettext_lazy as _11from django.utils.translation import ugettext_lazy as _
1212
13import hashlib
14import base64
15
1613
17class EditGGZForm(forms.ModelForm):14class EditGGZForm(forms.ModelForm):
18 password = forms.CharField(label=_(u'Online Gaming Password'),15 password = forms.CharField(label=_(u'Online Gaming Password'),
19 widget=forms.PasswordInput(render_value=False), required=True)16 widget=forms.PasswordInput(render_value=False), required=True)
17 password2 = forms.CharField(label=_(u'Enter the password again'),
18 widget=forms.PasswordInput(render_value=False), required=True)
2019
21 class Meta:20 class Meta:
22 model = GGZAuth21 model = GGZAuth
@@ -27,11 +26,9 @@
2726
28 super(EditGGZForm, self).__init__(instance=instance, *args, **kwargs)27 super(EditGGZForm, self).__init__(instance=instance, *args, **kwargs)
2928
30 def clean_password(self):29 def clean(self):
31 pw = self.cleaned_data['password']30 cleaned_data = super(EditGGZForm,self).clean()
32 pw_hash = hashlib.sha1(pw.encode('utf-8')).digest()31 pw = cleaned_data.get('password')
33 pw_base64 = base64.standard_b64encode(pw_hash)32 pw2 = cleaned_data.get('password2')
34 return pw_base6433 if pw != pw2:
3534 self.add_error('password2', "The passwords didn't match")
36 def save(self, *args, **kwargs):
37 super(EditGGZForm, self).save(*args, **kwargs)
3835
=== modified file 'wlggz/models.py'
--- wlggz/models.py 2019-03-31 11:08:21 +0000
+++ wlggz/models.py 2019-05-16 06:21:17 +0000
@@ -13,6 +13,8 @@
13from django.utils.translation import ugettext_lazy as _13from django.utils.translation import ugettext_lazy as _
14from pybb.models import Post14from pybb.models import Post
1515
16import hashlib
17import base64
1618
17class GGZAuth(models.Model):19class GGZAuth(models.Model):
18 user = AutoOneToOneField(20 user = AutoOneToOneField(
@@ -24,3 +26,11 @@
24 class Meta:26 class Meta:
25 verbose_name = _('ggz')27 verbose_name = _('ggz')
26 verbose_name_plural = _('ggz')28 verbose_name_plural = _('ggz')
29
30 def save(self, *args, **kwargs):
31 # hash the password
32 pw_hash = hashlib.sha1(self.password.encode('utf-8')).digest()
33 pw_base64 = base64.standard_b64encode(pw_hash)
34 self.password = pw_base64
35 # Save into the database
36 super(GGZAuth, self).save(*args, **kwargs)
2737
=== modified file 'wlggz/templates/wlggz/edit_ggz.html'
--- wlggz/templates/wlggz/edit_ggz.html 2019-01-24 18:03:54 +0000
+++ wlggz/templates/wlggz/edit_ggz.html 2019-05-16 06:21:17 +0000
@@ -1,4 +1,4 @@
1{% extends "mainpage/base.html" %}1{% extends "wlprofile/base.html" %}
22
3{% load i18n %}3{% load i18n %}
44
@@ -6,17 +6,28 @@
6{% trans "Set Online Gaming Password" %} - {{ block.super }}6{% trans "Set Online Gaming Password" %} - {{ block.super }}
7{% endblock %}7{% endblock %}
88
9{% block game_passwrd %}class="active"{% endblock %}
10
9{% block content_header %}11{% block content_header %}
10 <h1>{% trans "Set Online Gaming Password" %}</h1>12 <h1>{% trans "Set Online Gaming Password" %}</h1>
11{% endblock %}13{% endblock %}
1214
13{% block content_main %}15{% block content_main %}
14<div class="blogEntry"> 16<div class="blogEntry">
17 <p>The password set here can be used when playing widelands over the internet.
18 Although it is optional to use a password it is recommended to use one,
19 because your username will be reserved then. The password is stored encrypted.</p>
20 <p>To use the password in internet games:</p>
21 <ul>
22 <li>Start the game and click on 'Multiplayer -> Internet Game'</li>
23 <li>Enter your Widelands website username and the password you have set here</li>
24 <li>Click on 'Login'</li>
25 </ul>
15 <form method="post" enctype="multipart/form-data">26 <form method="post" enctype="multipart/form-data">
16 <table>27 <table>
17 {% for field in ggz_form %}28 {% for field in ggz_form %}
18 <tr>29 <tr>
19 <td class="grey">{{ field.label_tag }}:</td>30 <td class="grey">{{ field.label_tag }}</td>
20 <td>{{ field }}</td>31 <td>{{ field }}</td>
21 <td class="errormessage">{{ field.errors }}</td>32 <td class="errormessage">{{ field.errors }}</td>
22 </tr>33 </tr>
2334
=== modified file 'wlggz/views.py'
--- wlggz/views.py 2018-04-08 14:40:17 +0000
+++ wlggz/views.py 2019-05-16 06:21:17 +0000
@@ -5,6 +5,7 @@
5from django.contrib.auth.decorators import login_required5from django.contrib.auth.decorators import login_required
6from django.shortcuts import render6from django.shortcuts import render
7from django.http import HttpResponseRedirect7from django.http import HttpResponseRedirect
8from django.contrib import messages
89
9from forms import EditGGZForm10from forms import EditGGZForm
1011
@@ -17,10 +18,13 @@
17 if request.method == 'POST':18 if request.method == 'POST':
18 form = EditGGZForm(request.POST,19 form = EditGGZForm(request.POST,
19 instance=instance, files=request.FILES)20 instance=instance, files=request.FILES)
21
20 if form.is_valid():22 if form.is_valid():
21 form.save()23 form.save()
24 messages.info(request,
25 'Your password was saved successfully.')
2226
23 return HttpResponseRedirect(reverse('profile_edit'))27 return HttpResponseRedirect(reverse('profile_view'))
24 else:28 else:
25 form = EditGGZForm(instance=instance)29 form = EditGGZForm(instance=instance)
2630
2731
=== modified file 'wlprofile/templates/wlprofile/base.html'
--- wlprofile/templates/wlprofile/base.html 2019-01-24 18:03:54 +0000
+++ wlprofile/templates/wlprofile/base.html 2019-05-16 06:21:17 +0000
@@ -30,17 +30,10 @@
30 <a {% block edit_profile %}{% endblock %} href="{% url 'profile_edit' %}">Edit Profile</a>30 <a {% block edit_profile %}{% endblock %} href="{% url 'profile_edit' %}">Edit Profile</a>
31 </li>31 </li>
32 <li>32 <li>
33 <a {% block notifications %}{% endblock %} href="{% url 'notification_notices' %}">E-Mail settings</a>33 <a {% block notifications %}{% endblock %} href="{% url 'notification_notices' %}">Notification Settings</a>
34 </li>34 </li>
35 <li>35 <li>
36 <a {% block scheduling %}{% endblock %} href="{% url 'scheduling_main' %}">Game Scheduler</a>36 <a {% block game_passwrd %}{% endblock %} href="{% url 'wlggz_changepw' %}" title="Online Gaming Password">Gaming Password</a>
37 <ul>
38 <li><a href="{% url 'scheduling_scheduling' %}">Define your playtime</a></li>
39 <li><a href="{% url 'scheduling_find' %}">Show playtimes</a></li>
40 </ul>
41 </li>
42 <li>
43 <a {% block messages %}{% endblock %} href="{% url 'messages_inbox' %}" title="Your private messages">Messages</a>
44 </li>37 </li>
45 {% endif %}38 {% endif %}
46 </ul>39 </ul>
4740
=== modified file 'wlprofile/templates/wlprofile/edit_profile.html'
--- wlprofile/templates/wlprofile/edit_profile.html 2019-03-03 15:17:58 +0000
+++ wlprofile/templates/wlprofile/edit_profile.html 2019-05-16 06:21:17 +0000
@@ -49,7 +49,6 @@
49 <h2>Other options:</h2>49 <h2>Other options:</h2>
50 <ul>50 <ul>
51 <li><a href="{% url 'password_change' %}">Change website password</a></li>51 <li><a href="{% url 'password_change' %}">Change website password</a></li>
52 <li><a href="{% url 'wlggz_changepw' %}">Change online gaming password</a></li>
53 <li><a href="{% url 'delete_me' %}">Delete me</a></li>52 <li><a href="{% url 'delete_me' %}">Delete me</a></li>
54 </ul>53 </ul>
55</div>54</div>
5655
=== modified file 'wlprofile/templates/wlprofile/view_profile.html'
--- wlprofile/templates/wlprofile/view_profile.html 2019-05-06 17:55:58 +0000
+++ wlprofile/templates/wlprofile/view_profile.html 2019-05-16 06:21:17 +0000
@@ -27,6 +27,11 @@
2727
28{% block content_main %}28{% block content_main %}
29<div class="blogEntry">29<div class="blogEntry">
30 {% if messages %}
31 {% for message in messages %}
32 <p style="text-align: center;">{{ message }}</p>
33 {% endfor %}
34 {% endif %}
30 {% if not profile.deleted %}35 {% if not profile.deleted %}
31 <table>36 <table>
32 <tr>37 <tr>
3338
=== modified file 'wlprofile/views.py'
--- wlprofile/views.py 2019-01-18 11:10:27 +0000
+++ wlprofile/views.py 2019-05-16 06:21:17 +0000
@@ -8,6 +8,7 @@
8from django.http import HttpResponseRedirect8from django.http import HttpResponseRedirect
9from django.shortcuts import get_object_or_4049from django.shortcuts import get_object_or_404
10from django.conf import settings10from django.conf import settings
11from django.contrib import messages
1112
12from forms import EditProfileForm13from forms import EditProfileForm
1314
@@ -133,8 +134,10 @@
133 instance=instance, files=request.FILES)134 instance=instance, files=request.FILES)
134 if form.is_valid():135 if form.is_valid():
135 form.save()136 form.save()
137 messages.info(request,
138 'Your profile was changed successfully.')
136139
137 return HttpResponseRedirect(reverse(view))140 return HttpResponseRedirect(reverse('profile_view'))
138 else:141 else:
139 form = EditProfileForm(instance=instance)142 form = EditProfileForm(instance=instance)
140143
141144
=== modified file 'wlscheduling/templates/wlscheduling/base.html'
--- wlscheduling/templates/wlscheduling/base.html 2019-01-24 18:50:59 +0000
+++ wlscheduling/templates/wlscheduling/base.html 2019-05-16 06:21:17 +0000
@@ -1,4 +1,4 @@
1{% extends "wlprofile/base.html" %}1{% extends "mainpage/base.html" %}
2{% load static %}2{% load static %}
33
4{% block extra_head %}4{% block extra_head %}
@@ -13,4 +13,4 @@
13{% block title %}13{% block title %}
14 Scheduling - {{block.super}}14 Scheduling - {{block.super}}
15{% endblock %}15{% endblock %}
16{% block scheduling %}class="active"{% endblock %}16

Subscribers

People subscribed via source and target branches