diff --git a/bookwyrm/models/fields.py b/bookwyrm/models/fields.py index 361079906..7d14f88f9 100644 --- a/bookwyrm/models/fields.py +++ b/bookwyrm/models/fields.py @@ -296,7 +296,7 @@ class ManyToManyField(ActivitypubFieldMixin, models.ManyToManyField): super().__init__(*args, **kwargs) def set_field_from_activity(self, instance, data, overwrite=True): - """helper function for assinging a value to the field""" + """helper function for assigning a value to the field""" if not overwrite and getattr(instance, self.name).exists(): return False @@ -398,7 +398,11 @@ class ImageField(ActivitypubFieldMixin, models.ImageField): if formatted is None or formatted is MISSING: return False - if not overwrite and hasattr(instance, self.name): + if ( + not overwrite + and hasattr(instance, self.name) + and getattr(instance, self.name) + ): return False getattr(instance, self.name).save(*formatted, save=save) diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index ebac78a91..4d92746d6 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -45,6 +45,13 @@ let BookWyrm = new class { 'change', this.disableIfTooLarge.bind(this) )); + + document.querySelectorAll('[data-duplicate]') + .forEach(node => node.addEventListener( + 'click', + this.duplicateInput.bind(this) + + )) } /** @@ -383,4 +390,24 @@ let BookWyrm = new class { "left=100,top=100,width=430,height=600" ); } + + duplicateInput (event ) { + const trigger = event.currentTarget; + const input_id = trigger.dataset['duplicate'] + const orig = document.getElementById(input_id); + const parent = orig.parentNode; + const new_count = parent.querySelectorAll("input").length + 1 + + let input = orig.cloneNode(); + + input.id += ("-" + (new_count)) + input.value = "" + + let label = parent.querySelector("label").cloneNode(); + + label.setAttribute("for", input.id) + + parent.appendChild(label) + parent.appendChild(input) + } }(); diff --git a/bookwyrm/static/js/status_cache.js b/bookwyrm/static/js/status_cache.js index 2a50bfcbe..418b7dee2 100644 --- a/bookwyrm/static/js/status_cache.js +++ b/bookwyrm/static/js/status_cache.js @@ -187,6 +187,7 @@ let StatusCache = new class { .forEach(item => BookWyrm.addRemoveClass(item, "is-hidden", false)); // Remove existing disabled states + button.querySelectorAll("[data-shelf-dropdown-identifier] button") .forEach(item => item.disabled = false); diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 36241ee26..713e7abee 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -153,12 +153,21 @@ {# user's relationship to the book #}
+ {% if user_shelfbooks.count > 0 %} +

+ {% trans "You have shelved this edition in:" %} +

+ + {% endif %} {% for shelf in other_edition_shelves %}

{% blocktrans with book_path=shelf.book.local_path shelf_path=shelf.shelf.local_path shelf_name=shelf.shelf.name %}A different edition of this book is on your {{ shelf_name }} shelf.{% endblocktrans %} diff --git a/bookwyrm/templates/book/edit/edit_book_form.html b/bookwyrm/templates/book/edit/edit_book_form.html index 982bb56d2..25d24e43d 100644 --- a/bookwyrm/templates/book/edit/edit_book_form.html +++ b/bookwyrm/templates/book/edit/edit_book_form.html @@ -119,10 +119,16 @@ {% endif %}

- - - {% trans "Separate multiple values with commas." %} + + {% for author in add_author %} + + + {% empty %} + + + {% endfor %}
+
diff --git a/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html index 3c1271600..a35ed9e0b 100644 --- a/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html @@ -9,10 +9,11 @@ Finish "{{ book_title }}" {% endblock %} {% block modal-form-open %} -
+ {% csrf_token %} + {% endblock %} {% block reading-dates %} diff --git a/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html index cd0b64f3b..423f77ebe 100644 --- a/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html @@ -9,8 +9,9 @@ Start "{{ book_title }}" {% endblock %} {% block modal-form-open %} - + + {% csrf_token %} {% endblock %} diff --git a/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html b/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html index d1f06d8f1..2fb976bf1 100644 --- a/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html @@ -9,8 +9,9 @@ Want to Read "{{ book_title }}" {% endblock %} {% block modal-form-open %} - + + {% csrf_token %} {% endblock %} diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index ca5a39f6e..4b32f5a8e 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -1,29 +1,88 @@ {% extends 'components/dropdown.html' %} {% load i18n %} +{% load bookwyrm_tags %} +{% load utilities %} + {% block dropdown-trigger %} {% trans "Move book" %} {% endblock %} {% block dropdown-list %} +{% with book.id|uuid as uuid %} +{% active_shelf book as active_shelf %} +{% latest_read_through book request.user as readthrough %} + {% for shelf in user_shelves %} + +{% if shelf.editable %}
+{% else%} +{% comparison_bool shelf.identifier active_shelf.shelf.identifier as is_current %} +{% with button_class="is-fullwidth is-small shelf-option is-radiusless is-white" %} + +{% endwith %} +{% endif %} {% endfor %} - + +{% if shelf.identifier == 'all' %} +{% for shelved_in in book.shelves.all %} + +{% endfor %} +{% else %} + + +{% endif %} + +{% include 'snippets/reading_modals/want_to_read_modal.html' with book=active_shelf.book controls_text="want_to_read" controls_uid=uuid move_from=current.id refresh=True %} + +{% include 'snippets/reading_modals/start_reading_modal.html' with book=active_shelf.book controls_text="start_reading" controls_uid=uuid move_from=current.id refresh=True %} + +{% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf.book controls_text="finish_reading" controls_uid=uuid move_from=current.id readthrough=readthrough refresh=True %} + +{% endwith %} {% endblock %} diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html index 32319f863..8c1881ce9 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html @@ -32,7 +32,7 @@ {% elif shelf.editable %} -
+ {% csrf_token %}