Merge pull request #1469 from bookwyrm-social/user-shelf
Reorganize user/shelf/goal views code
This commit is contained in:
13
bookwyrm/templates/shelf/create_shelf_form.html
Normal file
13
bookwyrm/templates/shelf/create_shelf_form.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends 'components/inline_form.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block header %}
|
||||
{% trans "Create Shelf" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block form %}
|
||||
<form name="create-shelf" action="{% url 'shelf-create' %}" method="post">
|
||||
{% include "shelf/form.html" with editable=shelf.editable form=create_form %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
13
bookwyrm/templates/shelf/edit_shelf_form.html
Normal file
13
bookwyrm/templates/shelf/edit_shelf_form.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends 'components/inline_form.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block header %}
|
||||
{% trans "Edit Shelf" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block form %}
|
||||
<form name="edit-shelf" action="{{ shelf.local_path }}" method="post">
|
||||
{% include "shelf/form.html" with editable=shelf.editable form=edit_form privacy=shelf.privacy %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
28
bookwyrm/templates/shelf/form.html
Normal file
28
bookwyrm/templates/shelf/form.html
Normal file
@ -0,0 +1,28 @@
|
||||
{% load i18n %}
|
||||
{% load utilities %}
|
||||
{% with 0|uuid as uuid %}
|
||||
{% 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>
|
||||
<input type="text" name="name" value="{{ form.name.value|default:'' }}" maxlength="100" class="input" required="" id="id_name">
|
||||
</div>
|
||||
{% else %}
|
||||
<input type="hidden" name="name" required="true" value="{{ shelf.name }}">
|
||||
{% endif %}
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="id_description_{{ uuid }}">{% trans "Description:" %}</label>
|
||||
<textarea name="description" cols="40" rows="5" maxlength="500" class="textarea" id="id_description_{{ uuid }}">{{ form.description.value|default:'' }}</textarea>
|
||||
</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>
|
||||
{% endwith %}
|
@ -5,7 +5,7 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}
|
||||
{% include 'user/shelf/books_header.html' %}
|
||||
{% include 'user/books_header.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block opengraph_images %}
|
||||
@ -15,7 +15,7 @@
|
||||
{% block content %}
|
||||
<header class="block">
|
||||
<h1 class="title">
|
||||
{% include 'user/shelf/books_header.html' %}
|
||||
{% include 'user/books_header.html' %}
|
||||
</h1>
|
||||
</header>
|
||||
|
||||
@ -60,45 +60,62 @@
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
{% include 'user/shelf/create_shelf_form.html' with controls_text='create_shelf_form' %}
|
||||
{% include 'shelf/create_shelf_form.html' with controls_text='create_shelf_form' %}
|
||||
</div>
|
||||
|
||||
<div class="block columns is-mobile">
|
||||
<div class="column">
|
||||
<h2 class="title is-3">
|
||||
{{ shelf.name }}
|
||||
<span class="subtitle">
|
||||
{% include 'snippets/privacy-icons.html' with item=shelf %}
|
||||
</span>
|
||||
{% with count=books.paginator.count %}
|
||||
{% if count %}
|
||||
<p class="help">
|
||||
{% blocktrans trimmed count counter=count with formatted_count=count|intcomma %}
|
||||
{{ formatted_count }} book
|
||||
{% plural %}
|
||||
{{ formatted_count }} books
|
||||
{% endblocktrans %}
|
||||
|
||||
{% if books.has_other_pages %}
|
||||
{% blocktrans trimmed with start=books.start_index end=books.end_index %}
|
||||
(showing {{ start }}-{{ end }})
|
||||
<div>
|
||||
<div class="block columns is-mobile">
|
||||
<div class="column">
|
||||
<h2 class="title is-3">
|
||||
{{ shelf.name }}
|
||||
<span class="subtitle">
|
||||
{% include 'snippets/privacy-icons.html' with item=shelf %}
|
||||
</span>
|
||||
{% with count=books.paginator.count %}
|
||||
{% if count %}
|
||||
<p class="help">
|
||||
{% blocktrans trimmed count counter=count with formatted_count=count|intcomma %}
|
||||
{{ formatted_count }} book
|
||||
{% plural %}
|
||||
{{ formatted_count }} books
|
||||
{% endblocktrans %}
|
||||
|
||||
{% if books.has_other_pages %}
|
||||
{% blocktrans trimmed with start=books.start_index end=books.end_index %}
|
||||
(showing {{ start }}-{{ end }})
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</h2>
|
||||
</div>
|
||||
{% if is_self and shelf.id %}
|
||||
<div class="column is-narrow">
|
||||
{% trans "Edit shelf" as button_text %}
|
||||
{% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_shelf_form" focus="edit_shelf_form_header" %}
|
||||
{% endwith %}
|
||||
</h2>
|
||||
</div>
|
||||
{% if is_self and shelf.id %}
|
||||
<div class="column is-narrow">
|
||||
<div class="is-flex">
|
||||
{% trans "Edit shelf" as button_text %}
|
||||
{% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_shelf_form" focus="edit_shelf_form_header" %}
|
||||
|
||||
{% if shelf.deletable %}
|
||||
<form class="ml-1" name="delete-shelf" action="/delete-shelf/{{ shelf.id }}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||
<button class="button is-danger is-light" type="submit">
|
||||
{% trans "Delete shelf" %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if shelf.description %}
|
||||
<p>{{ shelf.description }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
{% include 'user/shelf/edit_shelf_form.html' with controls_text="edit_shelf_form" %}
|
||||
{% include 'shelf/edit_shelf_form.html' with controls_text="edit_shelf_form" %}
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
@ -167,17 +184,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>{% trans "This shelf is empty." %}</p>
|
||||
{% if shelf.id and shelf.editable %}
|
||||
<form name="delete-shelf" action="/delete-shelf/{{ shelf.id }}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||
<button class="button is-danger is-light" type="submit">
|
||||
{% trans "Delete shelf" %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
<p><em>{% trans "This shelf is empty." %}</em></p>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
@ -1,7 +1,7 @@
|
||||
{% load i18n %}
|
||||
{% load utilities %}
|
||||
<div class="select {{ class }}">
|
||||
{% with 0|uuid as uuid %}
|
||||
{% firstof uuid 0|uuid as uuid %}
|
||||
{% if not no_label %}
|
||||
<label class="is-sr-only" for="privacy_{{ uuid }}">{% trans "Post privacy" %}</label>
|
||||
{% endif %}
|
||||
@ -20,6 +20,5 @@
|
||||
{% trans "Private" %}
|
||||
</option>
|
||||
</select>
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
|
@ -9,6 +9,6 @@
|
||||
|
||||
{% block nullstate %}
|
||||
<div>
|
||||
{% blocktrans with username=user.display_name %}{{ username }} has no followers{% endblocktrans %}
|
||||
<em>{% blocktrans with username=user.display_name %}{{ username }} has no followers{% endblocktrans %}</em>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
{% block nullstate %}
|
||||
<div>
|
||||
{% blocktrans with username=user.display_name %}{{ username }} isn't following any users{% endblocktrans %}
|
||||
<em>{% blocktrans with username=user.display_name %}{{ username }} isn't following any users{% endblocktrans %}</em>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
{% extends 'components/inline_form.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block header %}
|
||||
{% trans "Create Shelf" %}
|
||||
{% endblock %}
|
||||
|
||||
{% 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>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
@ -1,31 +0,0 @@
|
||||
{% extends 'components/inline_form.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block header %}
|
||||
{% trans "Edit Shelf" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block form %}
|
||||
<form name="edit-shelf" action="{{ shelf.local_path }}" 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">{% 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="field has-addons">
|
||||
<div class="control">
|
||||
{% include 'snippets/privacy_select.html' with current=shelf.privacy %}
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">{% trans "Update shelf" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
@ -24,7 +24,7 @@
|
||||
{% if user.bookwyrm_user %}
|
||||
<div class="block">
|
||||
<h2 class="title">
|
||||
{% include 'user/shelf/books_header.html' %}
|
||||
{% include 'user/books_header.html' %}
|
||||
</h2>
|
||||
<div class="columns is-mobile scroll-x">
|
||||
{% for shelf in shelves %}
|
||||
|
Reference in New Issue
Block a user