forked from mirrors/bookwyrm
Edit shelf
This commit is contained in:
parent
c16047d0bc
commit
ee59c64a10
4 changed files with 78 additions and 21 deletions
|
@ -31,18 +31,21 @@
|
||||||
|
|
||||||
{% if is_self %}
|
{% if is_self %}
|
||||||
<div class="column is-narrow">
|
<div class="column is-narrow">
|
||||||
<label for="create-shelf-form">
|
<input type="radio" id="create-shelf-form-hide" name="create-shelf-form" class="toggle-control" checked>
|
||||||
|
<div class="toggle-content hidden">
|
||||||
|
<label for="create-shelf-form-show">
|
||||||
<div role="button" tabindex="0">
|
<div role="button" tabindex="0">
|
||||||
<span class="icon icon-plus">
|
<span class="icon icon-plus">
|
||||||
<span class="is-sr-only">Create new shelf</span>
|
<span class="is-sr-only">Create new shelf</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="checkbox" id="create-shelf-form" class="toggle-control">
|
<input type="radio" id="create-shelf-form-show" name="create-shelf-form" class="toggle-control">
|
||||||
<div class="toggle-content hidden">
|
<div class="toggle-content hidden">
|
||||||
<div class="box mb-5">
|
<div class="box mb-5">
|
||||||
<h2 class="title is-4">Create new shelf</h2>
|
<h2 class="title is-4">Create new shelf</h2>
|
||||||
|
@ -51,7 +54,7 @@
|
||||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="id_name">Name:</label>
|
<label class="label" for="id_name">Name:</label>
|
||||||
<input type="text" name="name" maxlength="100" class="input" required="" id="id_name">
|
<input type="text" name="name" maxlength="100" class="input" required="true" id="id_name">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label class="label">
|
<label class="label">
|
||||||
|
@ -60,7 +63,7 @@
|
||||||
</label>
|
</label>
|
||||||
<div class="field is-grouped">
|
<div class="field is-grouped">
|
||||||
<button class="button is-primary" type="submit">Create shelf</button>
|
<button class="button is-primary" type="submit">Create shelf</button>
|
||||||
<label role="button" class="button" for="create-shelf-form" tabindex="0">Cancel<label>
|
<label role="button" class="button" for="create-shelf-form-hide" tabindex="0">Cancel<label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -77,15 +80,46 @@
|
||||||
</div>
|
</div>
|
||||||
{% if is_self %}
|
{% if is_self %}
|
||||||
<div class="column is-narrow">
|
<div class="column is-narrow">
|
||||||
<a href="/edit-shelf/{{ shelf.identifier }}">
|
<input type="radio" id="edit-shelf-form-hide" name="edit-shelf-form" class="toggle-control" checked>
|
||||||
|
<div class="toggle-content hidden">
|
||||||
|
<label for="edit-shelf-form-show">
|
||||||
|
<div role="button" tabindex="0">
|
||||||
<span class="icon icon-pencil">
|
<span class="icon icon-pencil">
|
||||||
<span class="is-sr-only">Edit shelf</span>
|
<span class="is-sr-only">Edit shelf</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<input type="radio" id="edit-shelf-form-show" name="edit-shelf-form" class="toggle-control">
|
||||||
|
<div class="toggle-content hidden">
|
||||||
|
<div class="box mb-5">
|
||||||
|
<h2 class="title is-4">Edit shelf</h2>
|
||||||
|
<form name="create-shelf" action="/edit-shelf/{{ shelf.id }}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||||
|
{% if shelf.editable %}
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" for="id_name">Name:</label>
|
||||||
|
<input type="text" name="name" maxlength="100" class="input" required="true" value="{{ shelf.name }}" id="id_name">
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<label class="label">
|
||||||
|
<p>Shelf privacy:</p>
|
||||||
|
{% include 'snippets/privacy_select.html' with no_label=True current=shelf.privacy %}
|
||||||
|
</label>
|
||||||
|
<div class="field is-grouped">
|
||||||
|
<button class="button is-primary" type="submit">Update shelf</button>
|
||||||
|
<label role="button" class="button" for="edit-shelf-form-hide" tabindex="0">Cancel<label>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<div>
|
<div>
|
||||||
{% include 'snippets/shelf.html' with shelf=shelf ratings=ratings %}
|
{% include 'snippets/shelf.html' with shelf=shelf ratings=ratings %}
|
||||||
|
|
|
@ -5,10 +5,18 @@
|
||||||
<label class="is-sr-only" for="privacy-{{ uuid }}">Post privacy</label>
|
<label class="is-sr-only" for="privacy-{{ uuid }}">Post privacy</label>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<select name="privacy" id="privacy-{{ uuid }}">
|
<select name="privacy" id="privacy-{{ uuid }}">
|
||||||
<option value="public" selected>Public</option>
|
<option value="public" {% if not current or current == 'public' %}selected{% endif %}>
|
||||||
<option value="unlisted">Unlisted</option>
|
Public
|
||||||
<option value="followers">Followers only</option>
|
</option>
|
||||||
<option value="direct">Private</option>
|
<option value="unlisted" {% if current == 'unlisted' %}selected{% endif %}>
|
||||||
|
Unlisted
|
||||||
|
</option>
|
||||||
|
<option value="followers" {% if current == 'followers' %}selected{% endif %}>
|
||||||
|
Followers only
|
||||||
|
</option>
|
||||||
|
<option value="direct" {% if current == 'direct' %}selected{% endif %}>
|
||||||
|
Private
|
||||||
|
</option>
|
||||||
</select>
|
</select>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -121,6 +121,7 @@ urlpatterns = [
|
||||||
re_path(r'^delete-status/?$', actions.delete_status),
|
re_path(r'^delete-status/?$', actions.delete_status),
|
||||||
|
|
||||||
re_path(r'^create-shelf/?$', actions.create_shelf),
|
re_path(r'^create-shelf/?$', actions.create_shelf),
|
||||||
|
re_path(r'^edit-shelf/(?P<shelf_id>\d+)?$', actions.edit_shelf),
|
||||||
re_path(r'^shelve/?$', actions.shelve),
|
re_path(r'^shelve/?$', actions.shelve),
|
||||||
re_path(r'^unshelve/?$', actions.unshelve),
|
re_path(r'^unshelve/?$', actions.unshelve),
|
||||||
re_path(r'^start-reading/?$', actions.start_reading),
|
re_path(r'^start-reading/?$', actions.start_reading),
|
||||||
|
|
|
@ -11,7 +11,7 @@ from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
from django.http import HttpResponseBadRequest, HttpResponseNotFound
|
from django.http import HttpResponseBadRequest, HttpResponseNotFound
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
@ -276,6 +276,20 @@ def upload_cover(request, book_id):
|
||||||
def create_shelf(request):
|
def create_shelf(request):
|
||||||
''' user generated shelves '''
|
''' user generated shelves '''
|
||||||
form = forms.ShelfForm(request.POST)
|
form = forms.ShelfForm(request.POST)
|
||||||
|
if not form.is_valid():
|
||||||
|
return redirect(request.headers.get('Referer', '/'))
|
||||||
|
|
||||||
|
shelf = form.save()
|
||||||
|
return redirect('/user/%s/shelf/%s' % \
|
||||||
|
(request.user.localname, shelf.identifier))
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def edit_shelf(request, shelf_id):
|
||||||
|
''' user generated shelves '''
|
||||||
|
shelf = get_object_or_404(models.Shelf, id=shelf_id)
|
||||||
|
|
||||||
|
form = forms.ShelfForm(request.POST, instance=shelf)
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
return redirect(request.headers.get('Referer', '/'))
|
return redirect(request.headers.get('Referer', '/'))
|
||||||
shelf = form.save()
|
shelf = form.save()
|
||||||
|
|
Loading…
Reference in a new issue