mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-10-31 22:19:00 +00:00
Merge branch 'main' into production
This commit is contained in:
commit
1eb979f05d
2 changed files with 7 additions and 6 deletions
|
@ -75,7 +75,7 @@
|
|||
|
||||
<div class="hidden box mb-5" id="edit-shelf-form">
|
||||
<h2 class="title is-4">Edit shelf</h2>
|
||||
<form name="create-shelf" action="/edit-shelf/{{ shelf.id }}" method="post">
|
||||
<form name="create-shelf" action="{{ shelf.local_path }}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||
{% if shelf.editable %}
|
||||
|
|
|
@ -65,12 +65,13 @@ class Shelf(View):
|
|||
return TemplateResponse(request, 'shelf.html', data)
|
||||
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
def post(self, request, username, shelf_id):
|
||||
''' user generated shelves '''
|
||||
if not request.user.username == username:
|
||||
return HttpResponseBadRequest()
|
||||
def post(self, request, username, shelf_identifier):
|
||||
''' edit a shelf '''
|
||||
try:
|
||||
shelf = request.user.shelf_set.get(identifier=shelf_identifier)
|
||||
except models.Shelf.DoesNotExist:
|
||||
return HttpResponseNotFound()
|
||||
|
||||
shelf = get_object_or_404(models.Shelf, id=shelf_id)
|
||||
if request.user != shelf.user:
|
||||
return HttpResponseBadRequest()
|
||||
if not shelf.editable and request.POST.get('name') != shelf.name:
|
||||
|
|
Loading…
Reference in a new issue