mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-20 08:31:07 +00:00
Merge pull request #370 from mouse-reeve/quick-add-description
Inline form to add description to book
This commit is contained in:
commit
0fba7aaa1b
3 changed files with 52 additions and 3 deletions
|
@ -57,6 +57,35 @@
|
||||||
|
|
||||||
{% include 'snippets/trimmed_text.html' with full=book|book_description %}
|
{% include 'snippets/trimmed_text.html' with full=book|book_description %}
|
||||||
|
|
||||||
|
{% if request.user.is_authenticated and perms.bookwyrm.edit_book and not book|book_description %}
|
||||||
|
<div>
|
||||||
|
<input class="toggle-control" type="radio" name="add-description" id="hide-description" checked>
|
||||||
|
<div class="toggle-content hidden">
|
||||||
|
<label class="button" for="add-description" tabindex="0" role="button">Add description</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<input class="toggle-control" type="radio" name="add-description" id="add-description">
|
||||||
|
<div class="toggle-content hidden">
|
||||||
|
<div class="box">
|
||||||
|
<form name="add-description" method="POST" action="/add-description/{{ book.id }}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<p class="fields is-grouped">
|
||||||
|
<label class="label"for="id_description">Description:</label>
|
||||||
|
<textarea name="description" cols="None" rows="None" class="textarea" id="id_description"></textarea>
|
||||||
|
</p>
|
||||||
|
<div class="field">
|
||||||
|
<button class="button is-primary" type="submit">Save</button>
|
||||||
|
<label class="button" for="hide-description" tabindex="0" role="button">Cancel</label>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% if book.parent_work.edition_set.count > 1 %}
|
{% if book.parent_work.edition_set.count > 1 %}
|
||||||
<p><a href="/book/{{ book.parent_work.id }}/editions">{{ book.parent_work.edition_set.count }} editions</a></p>
|
<p><a href="/book/{{ book.parent_work.id }}/editions">{{ book.parent_work.edition_set.count }} editions</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -112,7 +141,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="field is-grouped">
|
<div class="field is-grouped">
|
||||||
<button class="button is-primary" type="submit">Save</button>
|
<button class="button is-primary" type="submit">Save</button>
|
||||||
<label class="button" for="show-readthrough-{{ readthrough.id }}">Cancel</label>
|
<label class="button" for="show-readthrough-{{ readthrough.id }}" role="button" tabindex="0">Cancel</label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -135,7 +164,7 @@
|
||||||
<button class="button is-danger is-light" type="submit">
|
<button class="button is-danger is-light" type="submit">
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
<label for="delete-readthrough-{{ readthrough.id }}" class="button">Cancel</button>
|
<label for="delete-readthrough-{{ readthrough.id }}" class="button" role="button" tabindex="0">Cancel</button>
|
||||||
</form>
|
</form>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -102,6 +102,7 @@ urlpatterns = [
|
||||||
re_path(r'^resolve-book/?', actions.resolve_book),
|
re_path(r'^resolve-book/?', actions.resolve_book),
|
||||||
re_path(r'^edit-book/(?P<book_id>\d+)/?', actions.edit_book),
|
re_path(r'^edit-book/(?P<book_id>\d+)/?', actions.edit_book),
|
||||||
re_path(r'^upload-cover/(?P<book_id>\d+)/?', actions.upload_cover),
|
re_path(r'^upload-cover/(?P<book_id>\d+)/?', actions.upload_cover),
|
||||||
|
re_path(r'^add-description/(?P<book_id>\d+)/?', actions.add_description),
|
||||||
|
|
||||||
re_path(r'^edit-readthrough/?', actions.edit_readthrough),
|
re_path(r'^edit-readthrough/?', actions.edit_readthrough),
|
||||||
re_path(r'^delete-readthrough/?', actions.delete_readthrough),
|
re_path(r'^delete-readthrough/?', actions.delete_readthrough),
|
||||||
|
|
|
@ -252,7 +252,7 @@ def upload_cover(request, book_id):
|
||||||
|
|
||||||
form = forms.CoverForm(request.POST, request.FILES, instance=book)
|
form = forms.CoverForm(request.POST, request.FILES, instance=book)
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
return redirect(request.headers.get('Referer', '/'))
|
return redirect('/book/%d' % book.id)
|
||||||
|
|
||||||
book.cover = form.files['cover']
|
book.cover = form.files['cover']
|
||||||
book.sync_cover = False
|
book.sync_cover = False
|
||||||
|
@ -262,6 +262,25 @@ def upload_cover(request, book_id):
|
||||||
return redirect('/book/%s' % book.id)
|
return redirect('/book/%s' % book.id)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@require_POST
|
||||||
|
@permission_required('bookwyrm.edit_book', raise_exception=True)
|
||||||
|
def add_description(request, book_id):
|
||||||
|
''' upload a new cover '''
|
||||||
|
if not request.method == 'POST':
|
||||||
|
return redirect('/')
|
||||||
|
|
||||||
|
book = get_object_or_404(models.Edition, id=book_id)
|
||||||
|
|
||||||
|
description = request.POST.get('description')
|
||||||
|
|
||||||
|
book.description = description
|
||||||
|
book.save()
|
||||||
|
|
||||||
|
outgoing.handle_update_book(request.user, book)
|
||||||
|
return redirect('/book/%s' % book.id)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@require_POST
|
@require_POST
|
||||||
def create_shelf(request):
|
def create_shelf(request):
|
||||||
|
|
Loading…
Reference in a new issue