diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index ddbafbb4..a696e287 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -81,7 +81,7 @@
  • - + Settings
  • diff --git a/bookwyrm/templates/blocks.html b/bookwyrm/templates/preferences/blocks.html similarity index 91% rename from bookwyrm/templates/blocks.html rename to bookwyrm/templates/preferences/blocks.html index 1df49816..5fd29d25 100644 --- a/bookwyrm/templates/blocks.html +++ b/bookwyrm/templates/preferences/blocks.html @@ -1,4 +1,4 @@ -{% extends 'preferences_layout.html' %} +{% extends 'preferences/preferences_layout.html' %} {% block header %} Blocked Users diff --git a/bookwyrm/templates/change_password.html b/bookwyrm/templates/preferences/change_password.html similarity index 93% rename from bookwyrm/templates/change_password.html rename to bookwyrm/templates/preferences/change_password.html index c373dfc8..b1b2a049 100644 --- a/bookwyrm/templates/change_password.html +++ b/bookwyrm/templates/preferences/change_password.html @@ -1,4 +1,4 @@ -{% extends 'preferences_layout.html' %} +{% extends 'preferences/preferences_layout.html' %} {% block header %} Change Password {% endblock %} diff --git a/bookwyrm/templates/edit_user.html b/bookwyrm/templates/preferences/edit_user.html similarity index 96% rename from bookwyrm/templates/edit_user.html rename to bookwyrm/templates/preferences/edit_user.html index ee9ddb22..8b384276 100644 --- a/bookwyrm/templates/edit_user.html +++ b/bookwyrm/templates/preferences/edit_user.html @@ -1,4 +1,4 @@ -{% extends 'preferences_layout.html' %} +{% extends 'preferences/preferences_layout.html' %} {% block header %} Edit Profile {% endblock %} diff --git a/bookwyrm/templates/preferences_layout.html b/bookwyrm/templates/preferences/preferences_layout.html similarity index 57% rename from bookwyrm/templates/preferences_layout.html rename to bookwyrm/templates/preferences/preferences_layout.html index de2fe0df..b0e7b31a 100644 --- a/bookwyrm/templates/preferences_layout.html +++ b/bookwyrm/templates/preferences/preferences_layout.html @@ -10,16 +10,16 @@ diff --git a/bookwyrm/templates/user/user.html b/bookwyrm/templates/user/user.html index dc3169c2..48f15398 100644 --- a/bookwyrm/templates/user/user.html +++ b/bookwyrm/templates/user/user.html @@ -7,7 +7,7 @@ {% if is_self %}
    - + Edit profile diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index f03bcda9..e3b792ff 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -5,7 +5,6 @@ from django.urls import path, re_path from bookwyrm import incoming, settings, views, wellknown -from bookwyrm.views.rss_feed import RssFeed from bookwyrm.utils import regex user_path = r'^user/(?P%s)' % regex.username @@ -49,7 +48,6 @@ urlpatterns = [ re_path(r'^password-reset/?$', views.PasswordResetRequest.as_view()), re_path(r'^password-reset/(?P[A-Za-z0-9]+)/?$', views.PasswordReset.as_view()), - re_path(r'^change-password/?$', views.ChangePassword.as_view()), # invites 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/followers(.json)?/?$' % user_path, views.Followers.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()), + # 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\d+)/?$', views.Block.as_view()), + re_path(r'^unblock/(?P\d+)/?$', views.unblock), + # reading goals re_path(r'%s/goal/(?P\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'^delete-follow-request/?$', views.delete_follow_request), - re_path(r'^block/?$', views.Block.as_view()), - re_path(r'^block/(?P\d+)/?$', views.Block.as_view()), - re_path(r'^unblock/(?P\d+)/?$', views.unblock), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index e3ac29c8..36a4bed9 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -17,6 +17,7 @@ from .notifications import Notifications from .outbox import Outbox from .reading import edit_readthrough, create_readthrough, delete_readthrough from .reading import start_reading, finish_reading, delete_progressupdate +from .rss_feed import RssFeed from .password import PasswordResetRequest, PasswordReset, ChangePassword from .tag import Tag, AddTag, RemoveTag from .search import Search diff --git a/bookwyrm/views/block.py b/bookwyrm/views/block.py index fb95479a..ebcced2a 100644 --- a/bookwyrm/views/block.py +++ b/bookwyrm/views/block.py @@ -17,7 +17,7 @@ class Block(View): def get(self, request): ''' list of blocked users? ''' return TemplateResponse( - request, 'blocks.html', {'title': 'Blocked Users'}) + request, 'preferences/blocks.html', {'title': 'Blocked Users'}) def post(self, request, user_id): ''' block a user ''' @@ -31,7 +31,7 @@ class Block(View): privacy='direct', direct_recipients=[to_block] ) - return redirect('/block') + return redirect('/preferences/block') @require_POST @@ -55,4 +55,4 @@ def unblock(request, user_id): direct_recipients=[to_unblock] ) block.delete() - return redirect('/block') + return redirect('/preferences/block') diff --git a/bookwyrm/views/password.py b/bookwyrm/views/password.py index 06ddc1da..2adeebf5 100644 --- a/bookwyrm/views/password.py +++ b/bookwyrm/views/password.py @@ -94,7 +94,8 @@ class ChangePassword(View): 'title': 'Change Password', 'user': request.user, } - return TemplateResponse(request, 'change_password.html', data) + return TemplateResponse( + request, 'preferences/change_password.html', data) def post(self, request): ''' allow a user to change their password ''' @@ -102,9 +103,9 @@ class ChangePassword(View): confirm_password = request.POST.get('confirm-password') if new_password != confirm_password: - return redirect('/edit-profile') + return redirect('preferences/password') request.user.set_password(new_password) request.user.save() login(request, request.user) - return redirect('/user/%s' % request.user.localname) + return redirect(request.user.local_path) diff --git a/bookwyrm/views/rss_feed.py b/bookwyrm/views/rss_feed.py index d6bcd174..496689ff 100644 --- a/bookwyrm/views/rss_feed.py +++ b/bookwyrm/views/rss_feed.py @@ -1,29 +1,35 @@ -''' ''' +''' serialize user's posts in rss 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 +# pylint: disable=no-self-use, unused-argument class RssFeed(Feed): - - description_template = "snippets/rss_content.html" - title_template = "snippets/rss_title.html" + ''' serialize user's posts in rss feed ''' + description_template = 'snippets/rss_content.html' + title_template = 'snippets/rss_title.html' def get_object(self, request, username): + ''' the user who's posts get serialized ''' return get_user_from_username(username) + def link(self, obj): + ''' link to the user's profile ''' return obj.local_path + 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): - 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): + ''' link to the status ''' return item.local_path - diff --git a/bookwyrm/views/user.py b/bookwyrm/views/user.py index 4bbd8e29..a06face2 100644 --- a/bookwyrm/views/user.py +++ b/bookwyrm/views/user.py @@ -153,7 +153,7 @@ class EditUser(View): 'form': forms.EditUserForm(instance=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): ''' les get fancy with images ''' @@ -161,7 +161,7 @@ class EditUser(View): request.POST, request.FILES, instance=request.user) if not form.is_valid(): 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)