Generation of slugs and new urls to handle slugs
- TODO: redirect to correct slug if not found.
This commit is contained in:
parent
0751a56474
commit
ebf463fc91
22 changed files with 71 additions and 29 deletions
|
@ -19,7 +19,7 @@ from bookwyrm.views.helpers import is_api_request
|
|||
class Author(View):
|
||||
"""this person wrote a book"""
|
||||
|
||||
def get(self, request, author_id):
|
||||
def get(self, request, author_id, slug=None):
|
||||
"""landing page for an author"""
|
||||
author = get_object_or_404(models.Author, id=author_id)
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ from bookwyrm.views.helpers import is_api_request
|
|||
class Book(View):
|
||||
"""a book! this is the stuff"""
|
||||
|
||||
def get(self, request, book_id, user_statuses=False):
|
||||
def get(self, request, book_id, **kwargs):
|
||||
"""info about a book"""
|
||||
if is_api_request(request):
|
||||
book = get_object_or_404(
|
||||
|
@ -30,7 +30,7 @@ class Book(View):
|
|||
)
|
||||
return ActivitypubResponse(book.to_activity())
|
||||
|
||||
user_statuses = user_statuses if request.user.is_authenticated else False
|
||||
user_statuses = kwargs.get("user_statuses", False) if request.user.is_authenticated else False
|
||||
|
||||
# it's safe to use this OR because edition and work and subclasses of the same
|
||||
# table, so they never have clashing IDs
|
||||
|
|
|
@ -113,7 +113,7 @@ class DirectMessage(View):
|
|||
class Status(View):
|
||||
"""get posting"""
|
||||
|
||||
def get(self, request, username, status_id):
|
||||
def get(self, request, username, status_id, slug=None):
|
||||
"""display a particular status (and replies, etc)"""
|
||||
user = get_user_from_username(request.user, username)
|
||||
status = get_object_or_404(
|
||||
|
|
|
@ -20,7 +20,7 @@ from .helpers import get_user_from_username
|
|||
class Group(View):
|
||||
"""group page"""
|
||||
|
||||
def get(self, request, group_id):
|
||||
def get(self, request, group_id, slug=None):
|
||||
"""display a group"""
|
||||
|
||||
group = get_object_or_404(models.Group, id=group_id)
|
||||
|
@ -80,7 +80,7 @@ class Group(View):
|
|||
class UserGroups(View):
|
||||
"""a user's groups page"""
|
||||
|
||||
def get(self, request, username):
|
||||
def get(self, request, username, slug=None):
|
||||
"""display a group"""
|
||||
user = get_user_from_username(request.user, username)
|
||||
groups = (
|
||||
|
|
|
@ -25,8 +25,11 @@ from bookwyrm.views.helpers import is_api_request
|
|||
class List(View):
|
||||
"""book list page"""
|
||||
|
||||
def get(self, request, list_id, add_failed=False, add_succeeded=False):
|
||||
def get(self, request, list_id, **kwargs):
|
||||
"""display a book list"""
|
||||
add_failed = kwargs.get("add_failed", False)
|
||||
add_succeeded = kwargs.get("add_succeeded", False)
|
||||
|
||||
book_list = get_object_or_404(models.List, id=list_id)
|
||||
book_list.raise_visible_to_user(request.user)
|
||||
|
||||
|
|
|
@ -21,8 +21,9 @@ from bookwyrm.views.helpers import is_api_request, get_user_from_username
|
|||
class Shelf(View):
|
||||
"""shelf page"""
|
||||
|
||||
def get(self, request, username, shelf_identifier=None):
|
||||
def get(self, request, username, **kwargs):
|
||||
"""display a shelf"""
|
||||
shelf_identifier = kwargs.get("shelf_identifier")
|
||||
user = get_user_from_username(request.user, username)
|
||||
|
||||
is_self = user == request.user
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue