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
1=== modified file 'templates/django_messages/base.html'
2--- templates/django_messages/base.html 2019-02-23 19:02:18 +0000
3+++ templates/django_messages/base.html 2019-05-16 06:21:17 +0000
4@@ -1,4 +1,4 @@
5-{% extends "wlprofile/base.html" %}
6+{% extends "mainpage/base.html" %}
7 {% load i18n %}
8 {% load static %}
9
10@@ -9,8 +9,6 @@
11 <script type="text/javascript" src="{% static 'js/jquery-ui.min.js' %}"></script>
12 {{ block.super}}{% endblock %}
13
14-{% block messages %}class="active"{% endblock %}
15-
16 {% block title %}
17 Messages - {{block.super}}
18 {% endblock %}
19
20=== modified file 'wlggz/forms.py'
21--- wlggz/forms.py 2019-03-05 08:47:47 +0000
22+++ wlggz/forms.py 2019-05-16 06:21:17 +0000
23@@ -10,13 +10,12 @@
24 from models import GGZAuth
25 from django.utils.translation import ugettext_lazy as _
26
27-import hashlib
28-import base64
29-
30
31 class EditGGZForm(forms.ModelForm):
32 password = forms.CharField(label=_(u'Online Gaming Password'),
33 widget=forms.PasswordInput(render_value=False), required=True)
34+ password2 = forms.CharField(label=_(u'Enter the password again'),
35+ widget=forms.PasswordInput(render_value=False), required=True)
36
37 class Meta:
38 model = GGZAuth
39@@ -27,11 +26,9 @@
40
41 super(EditGGZForm, self).__init__(instance=instance, *args, **kwargs)
42
43- def clean_password(self):
44- pw = self.cleaned_data['password']
45- pw_hash = hashlib.sha1(pw.encode('utf-8')).digest()
46- pw_base64 = base64.standard_b64encode(pw_hash)
47- return pw_base64
48-
49- def save(self, *args, **kwargs):
50- super(EditGGZForm, self).save(*args, **kwargs)
51+ def clean(self):
52+ cleaned_data = super(EditGGZForm,self).clean()
53+ pw = cleaned_data.get('password')
54+ pw2 = cleaned_data.get('password2')
55+ if pw != pw2:
56+ self.add_error('password2', "The passwords didn't match")
57
58=== modified file 'wlggz/models.py'
59--- wlggz/models.py 2019-03-31 11:08:21 +0000
60+++ wlggz/models.py 2019-05-16 06:21:17 +0000
61@@ -13,6 +13,8 @@
62 from django.utils.translation import ugettext_lazy as _
63 from pybb.models import Post
64
65+import hashlib
66+import base64
67
68 class GGZAuth(models.Model):
69 user = AutoOneToOneField(
70@@ -24,3 +26,11 @@
71 class Meta:
72 verbose_name = _('ggz')
73 verbose_name_plural = _('ggz')
74+
75+ def save(self, *args, **kwargs):
76+ # hash the password
77+ pw_hash = hashlib.sha1(self.password.encode('utf-8')).digest()
78+ pw_base64 = base64.standard_b64encode(pw_hash)
79+ self.password = pw_base64
80+ # Save into the database
81+ super(GGZAuth, self).save(*args, **kwargs)
82
83=== modified file 'wlggz/templates/wlggz/edit_ggz.html'
84--- wlggz/templates/wlggz/edit_ggz.html 2019-01-24 18:03:54 +0000
85+++ wlggz/templates/wlggz/edit_ggz.html 2019-05-16 06:21:17 +0000
86@@ -1,4 +1,4 @@
87-{% extends "mainpage/base.html" %}
88+{% extends "wlprofile/base.html" %}
89
90 {% load i18n %}
91
92@@ -6,17 +6,28 @@
93 {% trans "Set Online Gaming Password" %} - {{ block.super }}
94 {% endblock %}
95
96+{% block game_passwrd %}class="active"{% endblock %}
97+
98 {% block content_header %}
99 <h1>{% trans "Set Online Gaming Password" %}</h1>
100 {% endblock %}
101
102 {% block content_main %}
103-<div class="blogEntry">
104+<div class="blogEntry">
105+ <p>The password set here can be used when playing widelands over the internet.
106+ Although it is optional to use a password it is recommended to use one,
107+ because your username will be reserved then. The password is stored encrypted.</p>
108+ <p>To use the password in internet games:</p>
109+ <ul>
110+ <li>Start the game and click on 'Multiplayer -> Internet Game'</li>
111+ <li>Enter your Widelands website username and the password you have set here</li>
112+ <li>Click on 'Login'</li>
113+ </ul>
114 <form method="post" enctype="multipart/form-data">
115 <table>
116 {% for field in ggz_form %}
117 <tr>
118- <td class="grey">{{ field.label_tag }}:</td>
119+ <td class="grey">{{ field.label_tag }}</td>
120 <td>{{ field }}</td>
121 <td class="errormessage">{{ field.errors }}</td>
122 </tr>
123
124=== modified file 'wlggz/views.py'
125--- wlggz/views.py 2018-04-08 14:40:17 +0000
126+++ wlggz/views.py 2019-05-16 06:21:17 +0000
127@@ -5,6 +5,7 @@
128 from django.contrib.auth.decorators import login_required
129 from django.shortcuts import render
130 from django.http import HttpResponseRedirect
131+from django.contrib import messages
132
133 from forms import EditGGZForm
134
135@@ -17,10 +18,13 @@
136 if request.method == 'POST':
137 form = EditGGZForm(request.POST,
138 instance=instance, files=request.FILES)
139+
140 if form.is_valid():
141 form.save()
142+ messages.info(request,
143+ 'Your password was saved successfully.')
144
145- return HttpResponseRedirect(reverse('profile_edit'))
146+ return HttpResponseRedirect(reverse('profile_view'))
147 else:
148 form = EditGGZForm(instance=instance)
149
150
151=== modified file 'wlprofile/templates/wlprofile/base.html'
152--- wlprofile/templates/wlprofile/base.html 2019-01-24 18:03:54 +0000
153+++ wlprofile/templates/wlprofile/base.html 2019-05-16 06:21:17 +0000
154@@ -30,17 +30,10 @@
155 <a {% block edit_profile %}{% endblock %} href="{% url 'profile_edit' %}">Edit Profile</a>
156 </li>
157 <li>
158- <a {% block notifications %}{% endblock %} href="{% url 'notification_notices' %}">E-Mail settings</a>
159- </li>
160- <li>
161- <a {% block scheduling %}{% endblock %} href="{% url 'scheduling_main' %}">Game Scheduler</a>
162- <ul>
163- <li><a href="{% url 'scheduling_scheduling' %}">Define your playtime</a></li>
164- <li><a href="{% url 'scheduling_find' %}">Show playtimes</a></li>
165- </ul>
166- </li>
167- <li>
168- <a {% block messages %}{% endblock %} href="{% url 'messages_inbox' %}" title="Your private messages">Messages</a>
169+ <a {% block notifications %}{% endblock %} href="{% url 'notification_notices' %}">Notification Settings</a>
170+ </li>
171+ <li>
172+ <a {% block game_passwrd %}{% endblock %} href="{% url 'wlggz_changepw' %}" title="Online Gaming Password">Gaming Password</a>
173 </li>
174 {% endif %}
175 </ul>
176
177=== modified file 'wlprofile/templates/wlprofile/edit_profile.html'
178--- wlprofile/templates/wlprofile/edit_profile.html 2019-03-03 15:17:58 +0000
179+++ wlprofile/templates/wlprofile/edit_profile.html 2019-05-16 06:21:17 +0000
180@@ -49,7 +49,6 @@
181 <h2>Other options:</h2>
182 <ul>
183 <li><a href="{% url 'password_change' %}">Change website password</a></li>
184- <li><a href="{% url 'wlggz_changepw' %}">Change online gaming password</a></li>
185 <li><a href="{% url 'delete_me' %}">Delete me</a></li>
186 </ul>
187 </div>
188
189=== modified file 'wlprofile/templates/wlprofile/view_profile.html'
190--- wlprofile/templates/wlprofile/view_profile.html 2019-05-06 17:55:58 +0000
191+++ wlprofile/templates/wlprofile/view_profile.html 2019-05-16 06:21:17 +0000
192@@ -27,6 +27,11 @@
193
194 {% block content_main %}
195 <div class="blogEntry">
196+ {% if messages %}
197+ {% for message in messages %}
198+ <p style="text-align: center;">{{ message }}</p>
199+ {% endfor %}
200+ {% endif %}
201 {% if not profile.deleted %}
202 <table>
203 <tr>
204
205=== modified file 'wlprofile/views.py'
206--- wlprofile/views.py 2019-01-18 11:10:27 +0000
207+++ wlprofile/views.py 2019-05-16 06:21:17 +0000
208@@ -8,6 +8,7 @@
209 from django.http import HttpResponseRedirect
210 from django.shortcuts import get_object_or_404
211 from django.conf import settings
212+from django.contrib import messages
213
214 from forms import EditProfileForm
215
216@@ -133,8 +134,10 @@
217 instance=instance, files=request.FILES)
218 if form.is_valid():
219 form.save()
220+ messages.info(request,
221+ 'Your profile was changed successfully.')
222
223- return HttpResponseRedirect(reverse(view))
224+ return HttpResponseRedirect(reverse('profile_view'))
225 else:
226 form = EditProfileForm(instance=instance)
227
228
229=== modified file 'wlscheduling/templates/wlscheduling/base.html'
230--- wlscheduling/templates/wlscheduling/base.html 2019-01-24 18:50:59 +0000
231+++ wlscheduling/templates/wlscheduling/base.html 2019-05-16 06:21:17 +0000
232@@ -1,4 +1,4 @@
233-{% extends "wlprofile/base.html" %}
234+{% extends "mainpage/base.html" %}
235 {% load static %}
236
237 {% block extra_head %}
238@@ -13,4 +13,4 @@
239 {% block title %}
240 Scheduling - {{block.super}}
241 {% endblock %}
242-{% block scheduling %}class="active"{% endblock %}
243+

Subscribers

People subscribed via source and target branches