kaputtnik has proposed merging lp:~widelands-dev/widelands-website/gaming_password into lp:widelands-website.
Commit message: Better place for setting the online gaming password Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1828677 in Widelands Website: "Give online gaming password a more prominent place." https://bugs.launchpad.net/widelands-website/+bug/1828677 For more details, see: https://code.launchpad.net/~widelands-dev/widelands-website/gaming_password/+merge/367448 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. -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/gaming_password into lp:widelands-website.
=== 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-15 06:56:07 +0000 @@ -1,4 +1,4 @@ -{% extends "wlprofile/base.html" %} +{% extends "mainpage/base.html" %} {% load i18n %} {% load static %} @@ -9,8 +9,6 @@ <script type="text/javascript" src="{% static 'js/jquery-ui.min.js' %}"></script> {{ block.super}}{% endblock %} -{% block messages %}class="active"{% endblock %} - {% block title %} Messages - {{block.super}} {% endblock %} === modified file 'wlggz/forms.py' --- wlggz/forms.py 2019-03-05 08:47:47 +0000 +++ wlggz/forms.py 2019-05-15 06:56:07 +0000 @@ -10,13 +10,12 @@ from models import GGZAuth from django.utils.translation import ugettext_lazy as _ -import hashlib -import base64 - class EditGGZForm(forms.ModelForm): password = forms.CharField(label=_(u'Online Gaming Password'), widget=forms.PasswordInput(render_value=False), required=True) + password2 = forms.CharField(label=_(u'Enter again'), + widget=forms.PasswordInput(render_value=False), required=True) class Meta: model = GGZAuth @@ -27,11 +26,9 @@ super(EditGGZForm, self).__init__(instance=instance, *args, **kwargs) - def clean_password(self): - pw = self.cleaned_data['password'] - pw_hash = hashlib.sha1(pw.encode('utf-8')).digest() - pw_base64 = base64.standard_b64encode(pw_hash) - return pw_base64 - - def save(self, *args, **kwargs): - super(EditGGZForm, self).save(*args, **kwargs) + def clean(self): + cleaned_data = super(EditGGZForm,self).clean() + pw = cleaned_data.get('password') + pw2 = cleaned_data.get('password2') + if pw != pw2: + self.add_error('password2', "The passwords didn't match") === modified file 'wlggz/models.py' --- wlggz/models.py 2019-03-31 11:08:21 +0000 +++ wlggz/models.py 2019-05-15 06:56:07 +0000 @@ -13,6 +13,8 @@ from django.utils.translation import ugettext_lazy as _ from pybb.models import Post +import hashlib +import base64 class GGZAuth(models.Model): user = AutoOneToOneField( @@ -24,3 +26,11 @@ class Meta: verbose_name = _('ggz') verbose_name_plural = _('ggz') + + def save(self, *args, **kwargs): + # hash the password + pw_hash = hashlib.sha1(self.password.encode('utf-8')).digest() + pw_base64 = base64.standard_b64encode(pw_hash) + self.password = pw_base64 + # Save into the database + super(GGZAuth, self).save(*args, **kwargs) === 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-15 06:56:07 +0000 @@ -1,4 +1,4 @@ -{% extends "mainpage/base.html" %} +{% extends "wlprofile/base.html" %} {% load i18n %} @@ -6,17 +6,28 @@ {% trans "Set Online Gaming Password" %} - {{ block.super }} {% endblock %} +{% block game_passwrd %}class="active"{% endblock %} + {% block content_header %} <h1>{% trans "Set Online Gaming Password" %}</h1> {% endblock %} {% block content_main %} -<div class="blogEntry"> +<div class="blogEntry"> + <p>The password set here can be used when playing widelands over internet. + Although it is optional to use a password it is recommended to use one, + because your username will be reserved then. The password is stored encrypted.</p> + <p>To use the password on internetgames:</p> + <ul> + <li>Start the game and click on 'Multiplayer -> Internet Game'</li> + <li>Enter your website's username and the password you have set here</li> + <li>Click on 'Login'</li> + </ul> <form method="post" enctype="multipart/form-data"> <table> {% for field in ggz_form %} <tr> - <td class="grey">{{ field.label_tag }}:</td> + <td class="grey">{{ field.label_tag }}</td> <td>{{ field }}</td> <td class="errormessage">{{ field.errors }}</td> </tr> === modified file 'wlggz/views.py' --- wlggz/views.py 2018-04-08 14:40:17 +0000 +++ wlggz/views.py 2019-05-15 06:56:07 +0000 @@ -17,6 +17,7 @@ if request.method == 'POST': form = EditGGZForm(request.POST, instance=instance, files=request.FILES) + if form.is_valid(): form.save() === 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-15 06:56:07 +0000 @@ -30,17 +30,10 @@ <a {% block edit_profile %}{% endblock %} href="{% url 'profile_edit' %}">Edit Profile</a> </li> <li> - <a {% block notifications %}{% endblock %} href="{% url 'notification_notices' %}">E-Mail settings</a> - </li> - <li> - <a {% block scheduling %}{% endblock %} href="{% url 'scheduling_main' %}">Game Scheduler</a> - <ul> - <li><a href="{% url 'scheduling_scheduling' %}">Define your playtime</a></li> - <li><a href="{% url 'scheduling_find' %}">Show playtimes</a></li> - </ul> - </li> - <li> - <a {% block messages %}{% endblock %} href="{% url 'messages_inbox' %}" title="Your private messages">Messages</a> + <a {% block notifications %}{% endblock %} href="{% url 'notification_notices' %}">Notification settings</a> + </li> + <li> + <a {% block game_passwrd %}{% endblock %} href="{% url 'wlggz_changepw' %}" title="Online Gaming Password">Gaming Password</a> </li> {% endif %} </ul> === 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-15 06:56:07 +0000 @@ -49,7 +49,6 @@ <h2>Other options:</h2> <ul> <li><a href="{% url 'password_change' %}">Change website password</a></li> - <li><a href="{% url 'wlggz_changepw' %}">Change online gaming password</a></li> <li><a href="{% url 'delete_me' %}">Delete me</a></li> </ul> </div> === 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-15 06:56:07 +0000 @@ -1,4 +1,4 @@ -{% extends "wlprofile/base.html" %} +{% extends "mainpage/base.html" %} {% load static %} {% block extra_head %} @@ -13,4 +13,4 @@ {% block title %} Scheduling - {{block.super}} {% endblock %} -{% block scheduling %}class="active"{% endblock %} +
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp