Groups profile settings templates

This commit is contained in:
Mouse Reeve 2021-01-29 09:28:00 -08:00
parent 24af288c52
commit 9fa8ee3940
12 changed files with 41 additions and 32 deletions

View file

@ -81,7 +81,7 @@
</a> </a>
</li> </li>
<li> <li>
<a href="/edit-profile" class="navbar-item"> <a href="/preferences/profile" class="navbar-item">
Settings Settings
</a> </a>
</li> </li>

View file

@ -1,4 +1,4 @@
{% extends 'preferences_layout.html' %} {% extends 'preferences/preferences_layout.html' %}
{% block header %} {% block header %}
Blocked Users Blocked Users

View file

@ -1,4 +1,4 @@
{% extends 'preferences_layout.html' %} {% extends 'preferences/preferences_layout.html' %}
{% block header %} {% block header %}
Change Password Change Password
{% endblock %} {% endblock %}

View file

@ -1,4 +1,4 @@
{% extends 'preferences_layout.html' %} {% extends 'preferences/preferences_layout.html' %}
{% block header %} {% block header %}
Edit Profile Edit Profile
{% endblock %} {% endblock %}

View file

@ -10,16 +10,16 @@
<h2 class="menu-label">Account</h2> <h2 class="menu-label">Account</h2>
<ul class="menu-list"> <ul class="menu-list">
<li> <li>
<a href="/edit-profile"{% if '/edit-profile' in request.path %} class="is-active" aria-selected="true"{% endif %}>Profile</a> <a href="/preferences/profile"{% if '/preferences/profile' in request.path %} class="is-active" aria-selected="true"{% endif %}>Profile</a>
</li> </li>
<li> <li>
<a href="/change-password"{% if '/change-password' in request.path %} class="is-active" aria-selected="true"{% endif %}>Change password</a> <a href="/preferences/password"{% if '/preferences/password' in request.path %} class="is-active" aria-selected="true"{% endif %}>Change password</a>
</li> </li>
</ul> </ul>
<h2 class="menu-label">Relationships</h2> <h2 class="menu-label">Relationships</h2>
<ul class="menu-list"> <ul class="menu-list">
<li> <li>
<a href="/block"{% if '/block' in request.path %} class="is-active" aria-selected="true"{% endif %}>Blocked users</a> <a href="/preferences/block"{% if '/preferences/block' in request.path %} class="is-active" aria-selected="true"{% endif %}>Blocked users</a>
</li> </li>
</ul> </ul>
</nav> </nav>

View file

@ -7,7 +7,7 @@
</div> </div>
{% if is_self %} {% if is_self %}
<div class="column is-narrow"> <div class="column is-narrow">
<a href="/edit-profile"> <a href="/preferences/profile">
<span class="icon icon-pencil" title="Edit profile"> <span class="icon icon-pencil" title="Edit profile">
<span class="is-sr-only">Edit profile</span> <span class="is-sr-only">Edit profile</span>
</span> </span>

View file

@ -5,7 +5,6 @@ from django.urls import path, re_path
from bookwyrm import incoming, settings, views, wellknown from bookwyrm import incoming, settings, views, wellknown
from bookwyrm.views.rss_feed import RssFeed
from bookwyrm.utils import regex from bookwyrm.utils import regex
user_path = r'^user/(?P<username>%s)' % regex.username user_path = r'^user/(?P<username>%s)' % regex.username
@ -49,7 +48,6 @@ urlpatterns = [
re_path(r'^password-reset/?$', views.PasswordResetRequest.as_view()), re_path(r'^password-reset/?$', views.PasswordResetRequest.as_view()),
re_path(r'^password-reset/(?P<code>[A-Za-z0-9]+)/?$', re_path(r'^password-reset/(?P<code>[A-Za-z0-9]+)/?$',
views.PasswordReset.as_view()), views.PasswordReset.as_view()),
re_path(r'^change-password/?$', views.ChangePassword.as_view()),
# invites # invites
re_path(r'^invite/?$', views.ManageInvites.as_view()), re_path(r'^invite/?$', views.ManageInvites.as_view()),
@ -76,9 +74,15 @@ urlpatterns = [
re_path(r'%s/shelves/?$' % user_path, views.user_shelves_page), re_path(r'%s/shelves/?$' % user_path, views.user_shelves_page),
re_path(r'%s/followers(.json)?/?$' % user_path, views.Followers.as_view()), re_path(r'%s/followers(.json)?/?$' % user_path, views.Followers.as_view()),
re_path(r'%s/following(.json)?/?$' % user_path, views.Following.as_view()), re_path(r'%s/following(.json)?/?$' % user_path, views.Following.as_view()),
re_path(r'^edit-profile/?$', views.EditUser.as_view()),
re_path(r'%s/rss' % user_path, views.rss_feed.RssFeed()), re_path(r'%s/rss' % user_path, views.rss_feed.RssFeed()),
# preferences
re_path(r'^preferences/profile/?$', views.EditUser.as_view()),
re_path(r'^preferences/password/?$', views.ChangePassword.as_view()),
re_path(r'^preferences/block/?$', views.Block.as_view()),
re_path(r'^block/(?P<user_id>\d+)/?$', views.Block.as_view()),
re_path(r'^unblock/(?P<user_id>\d+)/?$', views.unblock),
# reading goals # reading goals
re_path(r'%s/goal/(?P<year>\d{4})/?$' % user_path, views.Goal.as_view()), re_path(r'%s/goal/(?P<year>\d{4})/?$' % user_path, views.Goal.as_view()),
@ -140,7 +144,4 @@ urlpatterns = [
re_path(r'^accept-follow-request/?$', views.accept_follow_request), re_path(r'^accept-follow-request/?$', views.accept_follow_request),
re_path(r'^delete-follow-request/?$', views.delete_follow_request), re_path(r'^delete-follow-request/?$', views.delete_follow_request),
re_path(r'^block/?$', views.Block.as_view()),
re_path(r'^block/(?P<user_id>\d+)/?$', views.Block.as_view()),
re_path(r'^unblock/(?P<user_id>\d+)/?$', views.unblock),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View file

@ -17,6 +17,7 @@ from .notifications import Notifications
from .outbox import Outbox from .outbox import Outbox
from .reading import edit_readthrough, create_readthrough, delete_readthrough from .reading import edit_readthrough, create_readthrough, delete_readthrough
from .reading import start_reading, finish_reading, delete_progressupdate from .reading import start_reading, finish_reading, delete_progressupdate
from .rss_feed import RssFeed
from .password import PasswordResetRequest, PasswordReset, ChangePassword from .password import PasswordResetRequest, PasswordReset, ChangePassword
from .tag import Tag, AddTag, RemoveTag from .tag import Tag, AddTag, RemoveTag
from .search import Search from .search import Search

View file

@ -17,7 +17,7 @@ class Block(View):
def get(self, request): def get(self, request):
''' list of blocked users? ''' ''' list of blocked users? '''
return TemplateResponse( return TemplateResponse(
request, 'blocks.html', {'title': 'Blocked Users'}) request, 'preferences/blocks.html', {'title': 'Blocked Users'})
def post(self, request, user_id): def post(self, request, user_id):
''' block a user ''' ''' block a user '''
@ -31,7 +31,7 @@ class Block(View):
privacy='direct', privacy='direct',
direct_recipients=[to_block] direct_recipients=[to_block]
) )
return redirect('/block') return redirect('/preferences/block')
@require_POST @require_POST
@ -55,4 +55,4 @@ def unblock(request, user_id):
direct_recipients=[to_unblock] direct_recipients=[to_unblock]
) )
block.delete() block.delete()
return redirect('/block') return redirect('/preferences/block')

View file

@ -94,7 +94,8 @@ class ChangePassword(View):
'title': 'Change Password', 'title': 'Change Password',
'user': request.user, 'user': request.user,
} }
return TemplateResponse(request, 'change_password.html', data) return TemplateResponse(
request, 'preferences/change_password.html', data)
def post(self, request): def post(self, request):
''' allow a user to change their password ''' ''' allow a user to change their password '''
@ -102,9 +103,9 @@ class ChangePassword(View):
confirm_password = request.POST.get('confirm-password') confirm_password = request.POST.get('confirm-password')
if new_password != confirm_password: if new_password != confirm_password:
return redirect('/edit-profile') return redirect('preferences/password')
request.user.set_password(new_password) request.user.set_password(new_password)
request.user.save() request.user.save()
login(request, request.user) login(request, request.user)
return redirect('/user/%s' % request.user.localname) return redirect(request.user.local_path)

View file

@ -1,29 +1,35 @@
''' ''' ''' serialize user's posts in rss feed '''
from django.contrib.syndication.views import Feed from django.contrib.syndication.views import Feed
from django.urls import reverse
from bookwyrm.models.user import User
from .helpers import get_activity_feed, get_user_from_username from .helpers import get_activity_feed, get_user_from_username
# pylint: disable=no-self-use, unused-argument
class RssFeed(Feed): class RssFeed(Feed):
''' serialize user's posts in rss feed '''
description_template = "snippets/rss_content.html" description_template = 'snippets/rss_content.html'
title_template = "snippets/rss_title.html" title_template = 'snippets/rss_title.html'
def get_object(self, request, username): def get_object(self, request, username):
''' the user who's posts get serialized '''
return get_user_from_username(username) return get_user_from_username(username)
def link(self, obj): def link(self, obj):
''' link to the user's profile '''
return obj.local_path return obj.local_path
def title(self, obj): def title(self, obj):
return f"Status updates from {obj.display_name}" ''' title of the rss feed entry '''
return f'Status updates from {obj.display_name}'
def items(self, obj): def items(self, obj):
return get_activity_feed(obj, ['public', 'unlisted'], queryset=obj.status_set) ''' the user's activity feed '''
return get_activity_feed(
obj, ['public', 'unlisted'], queryset=obj.status_set)
def item_link(self, item): def item_link(self, item):
''' link to the status '''
return item.local_path return item.local_path

View file

@ -153,7 +153,7 @@ class EditUser(View):
'form': forms.EditUserForm(instance=request.user), 'form': forms.EditUserForm(instance=request.user),
'user': request.user, 'user': request.user,
} }
return TemplateResponse(request, 'settings/edit_user.html', data) return TemplateResponse(request, 'preferences/edit_user.html', data)
def post(self, request): def post(self, request):
''' les get fancy with images ''' ''' les get fancy with images '''
@ -161,7 +161,7 @@ class EditUser(View):
request.POST, request.FILES, instance=request.user) request.POST, request.FILES, instance=request.user)
if not form.is_valid(): if not form.is_valid():
data = {'form': form, 'user': request.user} data = {'form': form, 'user': request.user}
return TemplateResponse(request, 'settings/edit_user.html', data) return TemplateResponse(request, 'preferences/edit_user.html', data)
user = form.save(commit=False) user = form.save(commit=False)