diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 3b88db3c5..7b18a2ffa 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -25,6 +25,8 @@ class CustomForm(ModelForm): input_type = visible.field.widget.input_type if isinstance(visible.field.widget, Textarea): input_type = 'textarea' + visible.field.widget.attrs['cols'] = None + visible.field.widget.attrs['rows'] = None visible.field.widget.attrs['class'] = css_classes[input_type] class LoginForm(CustomForm): @@ -96,7 +98,9 @@ class ReplyForm(CustomForm): class EditUserForm(CustomForm): class Meta: model = models.User - fields = ['avatar', 'name', 'summary', 'manually_approves_followers'] + fields = [ + 'avatar', 'name', 'email', 'summary', 'manually_approves_followers' + ] help_texts = {f: None for f in fields} diff --git a/bookwyrm/templates/edit_user.html b/bookwyrm/templates/edit_user.html index 1947d3ddf..df620df4c 100644 --- a/bookwyrm/templates/edit_user.html +++ b/bookwyrm/templates/edit_user.html @@ -1,11 +1,51 @@ {% extends 'layout.html' %} {% block content %} -
-

Edit Profile

-
- {% csrf_token %} - {{ form.as_p }} - -
+
+
+
+ {% csrf_token %} +

Profile

+

+ + {{ form.avatar }} +

+

+ + {{ form.name }} +

+

+ + {{ form.summary }} +

+

+ + {{ form.email }} +

+

+ +

+ +
+
+
+
+

Change password

+
+ {% csrf_token %} +

+ + +

+

+ + +

+ +
+
+
{% endblock %} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 4d188d965..d41495ee5 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -85,6 +85,7 @@ urlpatterns = [ re_path(r'^user-register/?$', actions.register), re_path(r'^reset-password-request/?$', actions.password_reset_request), re_path(r'^reset-password/?$', actions.password_reset), + re_path(r'^change-password/?$', actions.password_change), re_path(r'^edit_profile/?$', actions.edit_profile), diff --git a/bookwyrm/view_actions.py b/bookwyrm/view_actions.py index c87c36b2c..d8618c824 100644 --- a/bookwyrm/view_actions.py +++ b/bookwyrm/view_actions.py @@ -106,9 +106,8 @@ def password_reset_request(request): return TemplateResponse(request, 'password_reset_request.html', data) - def password_reset(request): - ''' allow a user to change their password ''' + ''' allow a user to change their password through an emailed token ''' try: reset_code = models.PasswordReset.objects.get( code=request.POST.get('reset-code') @@ -133,6 +132,21 @@ def password_reset(request): return redirect('/') +@login_required +def password_change(request): + ''' allow a user to change their password ''' + new_password = request.POST.get('password') + confirm_password = request.POST.get('confirm-password') + + if new_password != confirm_password: + return redirect('/user-edit') + + request.user.set_password(new_password) + request.user.save() + login(request, request.user) + return redirect('/user-edit') + + @login_required def edit_profile(request): ''' les get fancy with images '''