Create edit_account.html
This commit is contained in:
parent
9c196287ad
commit
c8071fa591
@ -37,7 +37,7 @@ class EditForm(wtforms.Form):
|
|||||||
_('Slug'),
|
_('Slug'),
|
||||||
[wtforms.validators.Required(message=_("The slug can't be empty"))],
|
[wtforms.validators.Required(message=_("The slug can't be empty"))],
|
||||||
description=_(
|
description=_(
|
||||||
"The title part of this media's URL. "
|
"The title part of this media's address. "
|
||||||
"You usually don't need to change this."))
|
"You usually don't need to change this."))
|
||||||
|
|
||||||
|
|
||||||
@ -52,20 +52,19 @@ class EditProfileForm(wtforms.Form):
|
|||||||
url = wtforms.TextField(
|
url = wtforms.TextField(
|
||||||
_('Website'),
|
_('Website'),
|
||||||
[wtforms.validators.Optional(),
|
[wtforms.validators.Optional(),
|
||||||
wtforms.validators.URL(message='Improperly formed URL')])
|
wtforms.validators.URL(message="""This address contains errors""")])
|
||||||
|
|
||||||
|
|
||||||
|
class EditAccountForm(wtforms.Form):
|
||||||
old_password = wtforms.PasswordField(
|
old_password = wtforms.PasswordField(
|
||||||
_('Old password'),
|
_('Old password'),
|
||||||
[wtforms.validators.Optional()])
|
[wtforms.validators.Required()],
|
||||||
|
description=_(
|
||||||
|
"Enter your old password to prove you own this account."))
|
||||||
new_password = wtforms.PasswordField(
|
new_password = wtforms.PasswordField(
|
||||||
_('New Password'),
|
_('New password'),
|
||||||
[wtforms.validators.Optional(),
|
[wtforms.validators.Required(),
|
||||||
wtforms.validators.Length(min=6, max=30),
|
wtforms.validators.Length(min=6, max=30)])
|
||||||
wtforms.validators.EqualTo(
|
|
||||||
'confirm_password',
|
|
||||||
'Passwords must match.')])
|
|
||||||
confirm_password = wtforms.PasswordField(
|
|
||||||
'Confirm password',
|
|
||||||
[wtforms.validators.Optional()])
|
|
||||||
|
|
||||||
|
|
||||||
class EditAttachmentsForm(wtforms.Form):
|
class EditAttachmentsForm(wtforms.Form):
|
||||||
|
@ -20,4 +20,7 @@ from routes.route import Route
|
|||||||
edit_routes = [
|
edit_routes = [
|
||||||
# Media editing view handled in user_pages/routing.py
|
# Media editing view handled in user_pages/routing.py
|
||||||
Route('mediagoblin.edit.profile', '/profile/',
|
Route('mediagoblin.edit.profile', '/profile/',
|
||||||
controller="mediagoblin.edit.views:edit_profile")]
|
controller="mediagoblin.edit.views:edit_profile"),
|
||||||
|
Route('mediagoblin.edit.account', '/account/',
|
||||||
|
controller="mediagoblin.edit.views:edit_account")
|
||||||
|
]
|
||||||
|
@ -161,6 +161,35 @@ def edit_profile(request):
|
|||||||
url=user.get('url'),
|
url=user.get('url'),
|
||||||
bio=user.get('bio'))
|
bio=user.get('bio'))
|
||||||
|
|
||||||
|
if request.method == 'POST' and form.validate():
|
||||||
|
user.url = unicode(request.POST['url'])
|
||||||
|
user.bio = unicode(request.POST['bio'])
|
||||||
|
|
||||||
|
user.bio_html = cleaned_markdown_conversion(user['bio'])
|
||||||
|
|
||||||
|
user.save()
|
||||||
|
|
||||||
|
messages.add_message(request,
|
||||||
|
messages.SUCCESS,
|
||||||
|
_("Profile changes saved"))
|
||||||
|
return redirect(request,
|
||||||
|
'mediagoblin.user_pages.user_home',
|
||||||
|
user=user['username'])
|
||||||
|
|
||||||
|
return render_to_response(
|
||||||
|
request,
|
||||||
|
'mediagoblin/edit/edit_profile.html',
|
||||||
|
{'user': user,
|
||||||
|
'form': form})
|
||||||
|
|
||||||
|
|
||||||
|
@require_active_login
|
||||||
|
def edit_account(request):
|
||||||
|
edit_username = request.GET.get('username')
|
||||||
|
user = request.user
|
||||||
|
|
||||||
|
form = forms.EditAccountForm(request.POST)
|
||||||
|
|
||||||
if request.method == 'POST' and form.validate():
|
if request.method == 'POST' and form.validate():
|
||||||
password_matches = auth_lib.bcrypt_check_password(
|
password_matches = auth_lib.bcrypt_check_password(
|
||||||
request.POST['old_password'],
|
request.POST['old_password'],
|
||||||
@ -172,30 +201,25 @@ def edit_profile(request):
|
|||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
request,
|
request,
|
||||||
'mediagoblin/edit/edit_profile.html',
|
'mediagoblin/edit/edit_account.html',
|
||||||
{'user': user,
|
{'user': user,
|
||||||
'form': form})
|
'form': form})
|
||||||
|
|
||||||
user.url = unicode(request.POST['url'])
|
|
||||||
user.bio = unicode(request.POST['bio'])
|
|
||||||
|
|
||||||
if password_matches:
|
if password_matches:
|
||||||
user['pw_hash'] = auth_lib.bcrypt_gen_password_hash(
|
user['pw_hash'] = auth_lib.bcrypt_gen_password_hash(
|
||||||
request.POST['new_password'])
|
request.POST['new_password'])
|
||||||
|
|
||||||
user.bio_html = cleaned_markdown_conversion(user['bio'])
|
|
||||||
|
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
messages.add_message(request,
|
messages.add_message(request,
|
||||||
messages.SUCCESS,
|
messages.SUCCESS,
|
||||||
_("Profile edited!"))
|
_("Account settings saved"))
|
||||||
return redirect(request,
|
return redirect(request,
|
||||||
'mediagoblin.user_pages.user_home',
|
'mediagoblin.user_pages.user_home',
|
||||||
user=user['username'])
|
user=user['username'])
|
||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
request,
|
request,
|
||||||
'mediagoblin/edit/edit_profile.html',
|
'mediagoblin/edit/edit_account.html',
|
||||||
{'user': user,
|
{'user': user,
|
||||||
'form': form})
|
'form': form})
|
||||||
|
45
mediagoblin/templates/mediagoblin/edit/edit_account.html
Normal file
45
mediagoblin/templates/mediagoblin/edit/edit_account.html
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{#
|
||||||
|
# GNU MediaGoblin -- federated, autonomous media hosting
|
||||||
|
# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
{% extends "mediagoblin/base.html" %}
|
||||||
|
|
||||||
|
{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
|
||||||
|
|
||||||
|
{% block mediagoblin_head %}
|
||||||
|
<script type="text/javascript"
|
||||||
|
src="{{ request.staticdirect('/js/show_password.js') }}"></script>
|
||||||
|
{% endblock mediagoblin_head %}
|
||||||
|
|
||||||
|
{% block mediagoblin_content %}
|
||||||
|
|
||||||
|
<form action="{{ request.urlgen('mediagoblin.edit.account') }}?username={{
|
||||||
|
user.username }}"
|
||||||
|
method="POST" enctype="multipart/form-data">
|
||||||
|
<div class="grid_8 prefix_1 suffix_1 edit_box form_box">
|
||||||
|
<h1>
|
||||||
|
{%- trans username=user.username -%}
|
||||||
|
Changing {{ username }}'s account settings
|
||||||
|
{%- endtrans %}
|
||||||
|
</h1>
|
||||||
|
{{ wtforms_util.render_divs(form) }}
|
||||||
|
<div class="form_submit_buttons">
|
||||||
|
<input type="submit" value="{% trans %}Save changes{% endtrans %}" class="button_form" />
|
||||||
|
{{ csrf_token }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user