Book editing

This commit is contained in:
Mouse Reeve 2020-09-29 20:36:43 -07:00
parent 24d9839d07
commit 2d89d4abf8
7 changed files with 97 additions and 90 deletions

View file

@ -16,6 +16,7 @@ class CustomForm(ModelForm):
css_classes['text'] = 'input' css_classes['text'] = 'input'
css_classes['password'] = 'input' css_classes['password'] = 'input'
css_classes['email'] = 'input' css_classes['email'] = 'input'
css_classes['number'] = 'input'
css_classes['checkbox'] = 'checkbox' css_classes['checkbox'] = 'checkbox'
css_classes['textarea'] = 'textarea' css_classes['textarea'] = 'textarea'
super(CustomForm, self).__init__(*args, **kwargs) super(CustomForm, self).__init__(*args, **kwargs)
@ -118,6 +119,7 @@ class EditionForm(CustomForm):
class Meta: class Meta:
model = models.Edition model = models.Edition
exclude = [ exclude = [
'remote_id',
'created_date', 'created_date',
'updated_date', 'updated_date',
'last_sync_date', 'last_sync_date',

View file

@ -1,21 +1,20 @@
{% extends 'layout.html' %} {% extends 'layout.html' %}
{% block content %} {% block content %}
<div class="content-container">
<h2>About {{ site_settings.name }}</h2> <div class="columns">
<div class="column block">
<h2 class="title">About {{ site_settings.name }}</h2>
<p> <p>
{{ site_settings.instance_description }} {{ site_settings.instance_description }}
</p> </p>
</div>
<p> <div class="column block">
<small> <h2 class="title">Code of Conduct</h2>
<a href="/login/">Login or Create an Account</a>
</small>
</p>
<h2>Code of Conduct</h2>
<p> <p>
{{ site_settings.code_of_conduct }} {{ site_settings.code_of_conduct }}
</p> </p>
</div>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -20,7 +20,7 @@
</div> </div>
<div class="columns"> <div class="columns">
<div class="column"> <div class="column is-narrow">
{% include 'snippets/book_cover.html' with book=book size=large %} {% include 'snippets/book_cover.html' with book=book size=large %}
{% include 'snippets/rate_action.html' with user=request.user book=book %} {% include 'snippets/rate_action.html' with user=request.user book=book %}
{% include 'snippets/shelve_button.html' %} {% include 'snippets/shelve_button.html' %}
@ -43,9 +43,9 @@
</dl> </dl>
</div> </div>
<div class="column is-three-quarters"> <div class="column">
<div class="block"> <div class="block">
<h3>{% include 'snippets/stars.html' with rating=rating %}</h3> <h3 class="field is-grouped">{% include 'snippets/stars.html' with rating=rating %} ({{ reviews|length }} reviews)</h3>
{% include 'snippets/book_description.html' %} {% include 'snippets/book_description.html' %}

View file

@ -1,71 +1,83 @@
{% extends 'layout.html' %} {% extends 'layout.html' %}
{% load humanize %} {% load humanize %}
{% block content %} {% block content %}
<div class="content-container"> <div class="block">
<h2> <div class="level">
<h2 class="title level-left">
Edit "{{ book.title }}" Edit "{{ book.title }}"
</h2>
<div class="level-right">
<a href="/book/{{ book.id }}"> <a href="/book/{{ book.id }}">
<span class="edit-link icon icon-close"> <span class="edit-link icon icon-close">
<span class="hidden-text">Close</span> <span class="hidden-text">Close</span>
</span> </span>
</a> </a>
</h2> </div>
<div class="book-preview row"> </div>
<div class="cover-container"> <div class="columns">
<div class="column is-narrow">
{% include 'snippets/book_cover.html' with book=book size="small" %} {% include 'snippets/book_cover.html' with book=book size="small" %}
</div> </div>
<div> <div class="column is-narrow">
<p>Added: {{ book.created_date | naturaltime }}</p> <p>Added: {{ book.created_date | naturaltime }}</p>
<p>Updated: {{ book.updated_date | naturaltime }}</p> <p>Updated: {{ book.updated_date | naturaltime }}</p>
</div> </div>
</div> </div>
</div> </div>
<form class="book-form content-container" name="edit-book" action="/edit_book/{{ book.id }}" method="post" enctype="multipart/form-data"> <form class="block" name="edit-book" action="/edit_book/{{ book.id }}" method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
<h3>Data sync <div class="block">
<small>If sync is enabled, any changes will be over-written</small> <h3 class="title is-4">Data sync</h3>
<h4 class="subtitle is-5">If sync is enabled, any changes will be over-written</h4>
</h3> </h3>
<div> <div class="columns">
<div class="row"> <div class="column is-narrow">
<p><label for="id_sync">Sync:</label> <input type="checkbox" name="sync" id="id_sync"></p> <label class="checkbox" for="id_sync"><input class="checkbox" type="checkbox" name="sync" id="id_sync"> Sync</label>
<p><label for="id_sync_cover">Sync cover:</label> <input type="checkbox" name="sync_cover" id="id_sync_cover"></p> </div>
<div class="column is-narrow">
<label class="checkbox" for="id_sync_cover"><input class="checkbox" type="checkbox" name="sync_cover" id="id_sync_cover"> Sync cover</label>
</div>
</div> </div>
</div> </div>
<h3>Cover</h3> <div class="columns">
<div class="image-form"> <div class="block column">
<h3 class="title is-4">Book Identifiers</h3>
<p class="fields is-grouped"><label class="label"for="id_isbn_13">ISBN 13:</label> {{ form.isbn_13 }} </p>
<p class="fields is-grouped"><label class="label"for="id_isbn_10">ISBN 10:</label> {{ form.isbn_10 }} </p>
<p class="fields is-grouped"><label class="label"for="id_openlibrary_key">Openlibrary key:</label> {{ form.openlibrary_key }} </p>
<p class="fields is-grouped"><label class="label"for="id_librarything_key">Librarything key:</label> {{ form.librarything_key }} </p>
<p class="fields is-grouped"><label class="label"for="id_goodreads_key">Goodreads key:</label> {{ form.goodreads_key }} </p>
</div>
<div class="column">
<div class="block">
<h3 class="title is-4">Cover</h3>
<p>{{ form.cover }} </p> <p>{{ form.cover }} </p>
</div> </div>
<h3>Book Identifiers</h2> <div class="block">
<div> <h3 class="title is-4">Physical Properties</h3>
<p><label for="id_isbn_13">ISBN 13:</label> {{ form.isbn_13 }} </p> <p class="fields is-grouped"><label class="label"for="id_physical_format">Format:</label> {{ form.physical_format }} </p>
<p><label for="id_isbn_10">ISBN 10:</label> {{ form.isbn_10 }} </p> <p class="fields is-grouped"><label class="label"for="id_pages">Pages:</label> {{ form.pages }} </p>
<p><label for="id_openlibrary_key">Openlibrary key:</label> {{ form.openlibrary_key }} </p> </div>
<p><label for="id_librarything_key">Librarything key:</label> {{ form.librarything_key }} </p> </div>
<p><label for="id_goodreads_key">Goodreads key:</label> {{ form.goodreads_key }} </p>
</div> </div>
<h3>Physical Properties</h3> <div class="block">
<div> <h3 class="title is-4">Metadata</h3>
<p><label for="id_physical_format">Format:</label> {{ form.physical_format }} </p> <p class="fields is-grouped"><label class="label"for="id_title">Title:</label> {{ form.title }} </p>
<p><label for="id_pages">Pages:</label> {{ form.pages }} </p> <p class="fields is-grouped"><label class="label"for="id_sort_title">Sort title:</label> {{ form.sort_title }} </p>
<p class="fields is-grouped"><label class="label"for="id_subtitle">Subtitle:</label> {{ form.subtitle }} </p>
<p class="fields is-grouped"><label class="label"for="id_description">Description:</label> {{ form.description }} </p>
<p class="fields is-grouped"><label class="label"for="id_series">Series:</label> {{ form.series }} </p>
<p class="fields is-grouped"><label class="label"for="id_series_number">Series number:</label> {{ form.series_number }} </p>
<p class="fields is-grouped"><label class="label"for="id_first_published_date">First published date:</label> {{ form.first_published_date }} </p>
<p class="fields is-grouped"><label class="label"for="id_published_date">Published date:</label> {{ form.published_date }} </p>
</div> </div>
<div class="block">
<h3>Metadata</h3> <button class="button is-primary" type="submit">Save</button>
<div>
<p><label for="id_title">Title:</label> {{ form.title }} </p>
<p><label for="id_sort_title">Sort title:</label> {{ form.sort_title }} </p>
<p><label for="id_subtitle">Subtitle:</label> {{ form.subtitle }} </p>
<p><label for="id_description">Description:</label> {{ form.description }} </p>
<p><label for="id_series">Series:</label> {{ form.series }} </p>
<p><label for="id_series_number">Series number:</label> {{ form.series_number }} </p>
<p><label for="id_first_published_date">First published date:</label> {{ form.first_published_date }} </p>
<p><label for="id_published_date">Published date:</label> {{ form.published_date }} </p>
</div>
<div>
<button type="submit">Save</button>
</div> </div>
</form> </form>

View file

@ -1,16 +1,11 @@
{% extends 'layout.html' %} {% extends 'layout.html' %}
{% block content %} {% block content %}
<div class="content-container"> <div class="block">
<div class="user-profile"> <h2 class="title">Edit Profile</h2>
<h2>Edit Profile</h2>
<p>{% include 'snippets/avatar.html' with user=user %} {% if user.localname %}{{ user.localname }}{% else %}{{ user.username }}{% endif %}</p>
<form name="avatar" action="/edit_profile/" method="post" enctype="multipart/form-data"> <form name="avatar" action="/edit_profile/" method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form.as_p }}
<button type="submit">Update profile</button> <button class="button is-primary" type="submit">Update profile</button>
</form> </form>
</div>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -144,7 +144,7 @@ def resolve_book(request):
def edit_book(request, book_id): def edit_book(request, book_id):
''' edit a book cool ''' ''' edit a book cool '''
if not request.method == 'POST': if not request.method == 'POST':
return redirect('/book/%s' % request.user.localname) return redirect('/book/%s' % book_id)
try: try:
book = models.Edition.objects.get(id=book_id) book = models.Edition.objects.get(id=book_id)

View file

@ -458,7 +458,6 @@ def book_page(request, book_id, tab='friends'):
{'id': 'local', 'display': 'Local'}, {'id': 'local', 'display': 'Local'},
{'id': 'federated', 'display': 'Federated'} {'id': 'federated', 'display': 'Federated'}
], ],
'active_tab': tab,
'path': '/book/%s' % book_id, 'path': '/book/%s' % book_id,
'cover_form': forms.CoverForm(instance=book), 'cover_form': forms.CoverForm(instance=book),
'info_fields': [ 'info_fields': [