mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 18:11:09 +00:00
Updates edit/create shelf forms
This commit is contained in:
parent
dba0aaff2c
commit
24553e0e35
4 changed files with 29 additions and 33 deletions
|
@ -7,21 +7,7 @@
|
|||
|
||||
{% block form %}
|
||||
<form name="create-shelf" action="{% url 'shelf-create' %}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||
<div class="field">
|
||||
<label class="label" for="id_name_create">{% trans "Name:" %}</label>
|
||||
<input type="text" name="name" maxlength="100" class="input" required="true" id="id_name_create">
|
||||
</div>
|
||||
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
{% include 'snippets/privacy_select.html' %}
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">{% trans "Create Shelf" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
{% include "shelf/form.html" with editable=shelf.editable form=create_form %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -7,24 +7,7 @@
|
|||
|
||||
{% block form %}
|
||||
<form name="edit-shelf" action="{{ shelf.local_path }}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||
<div class="columns is-mobile">
|
||||
{% if shelf.editable %}
|
||||
<div class="column">
|
||||
<label class="label" for="id_name">{% trans "Name:" %}</label>
|
||||
<input type="text" name="name" maxlength="100" class="input" required="true" value="{{ shelf.name }}" id="id_name">
|
||||
</div>
|
||||
{% else %}
|
||||
<input type="hidden" name="name" required="true" value="{{ shelf.name }}">
|
||||
{% endif %}
|
||||
|
||||
<div class="column">
|
||||
<label class="label" for="privacy_{{ shelf.id }}">{% trans "Shelf privacy:" %}</label>
|
||||
{% include 'snippets/privacy_select.html' with current=shelf.privacy uuid=shelf.id no_label=True %}
|
||||
</div>
|
||||
</div>
|
||||
<button class="button is-primary" type="submit">{% trans "Update shelf" %}</button>
|
||||
{% include "shelf/form.html" with editable=shelf.editable form=edit_form privacy=shelf.privacy %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
|
25
bookwyrm/templates/shelf/form.html
Normal file
25
bookwyrm/templates/shelf/form.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
{% load i18n %}
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||
|
||||
{% if editable %}
|
||||
<div class="field">
|
||||
<label class="label" for="id_name">{% trans "Name:" %}</label>
|
||||
{{ form.name }}
|
||||
</div>
|
||||
{% else %}
|
||||
<input type="hidden" name="name" required="true" value="{{ shelf.name }}">
|
||||
{% endif %}
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="id_description">{% trans "Description:" %}</label>
|
||||
{{ form.description }}
|
||||
</div>
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
{% include 'snippets/privacy_select.html' with current=privacy %}
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
|
@ -85,6 +85,8 @@ class Shelf(View):
|
|||
"shelves": shelves,
|
||||
"shelf": shelf,
|
||||
"books": page,
|
||||
"edit_form": forms.ShelfForm(instance=shelf),
|
||||
"create_form": forms.ShelfForm(),
|
||||
"page_range": paginated.get_elided_page_range(
|
||||
page.number, on_each_side=2, on_ends=1
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue