diff --git a/bookwyrm/management/commands/remove_editions.py b/bookwyrm/management/commands/remove_editions.py new file mode 100644 index 00000000..c5153f44 --- /dev/null +++ b/bookwyrm/management/commands/remove_editions.py @@ -0,0 +1,34 @@ +''' PROCEED WITH CAUTION: this permanently deletes book data ''' +from django.core.management.base import BaseCommand +from django.db.models import Count, Q +from bookwyrm import models + + +def remove_editions(): + ''' combine duplicate editions and update related models ''' + # not in use + filters = {'%s__isnull' % r.name: True \ + for r in models.Edition._meta.related_objects} + # no cover, no identifying fields + filters['cover'] = '' + null_fields = {'%s__isnull' % f: True for f in \ + ['isbn_10', 'isbn_13', 'oclc_number']} + + editions = models.Edition.objects.filter( + Q(languages=[]) | Q(languages__contains=['English']), + **filters, **null_fields + ).annotate(Count('parent_work__editions')).filter( + # mustn't be the only edition for the work + parent_work__editions__count__gt=1 + ) + print(editions.count()) + editions.delete() + + +class Command(BaseCommand): + ''' dedplucate allllll the book data models ''' + help = 'merges duplicate book data' + # pylint: disable=no-self-use,unused-argument + def handle(self, *args, **options): + ''' run deudplications ''' + remove_editions() diff --git a/bookwyrm/templates/components/inline_form.html b/bookwyrm/templates/components/inline_form.html new file mode 100644 index 00000000..6a244ffd --- /dev/null +++ b/bookwyrm/templates/components/inline_form.html @@ -0,0 +1,13 @@ + diff --git a/bookwyrm/templates/lists/create_form.html b/bookwyrm/templates/lists/create_form.html new file mode 100644 index 00000000..706dff08 --- /dev/null +++ b/bookwyrm/templates/lists/create_form.html @@ -0,0 +1,11 @@ +{% extends 'components/inline_form.html' %} + +{% block header %} +Create List +{% endblock %} + +{% block form %} +
+ {% include 'lists/form.html' %} +
+{% endblock %} diff --git a/bookwyrm/templates/lists/edit_form.html b/bookwyrm/templates/lists/edit_form.html new file mode 100644 index 00000000..55723b72 --- /dev/null +++ b/bookwyrm/templates/lists/edit_form.html @@ -0,0 +1,11 @@ +{% extends 'components/inline_form.html' %} + +{% block header %} +Edit List +{% endblock %} + +{% block form %} +
+ {% include 'lists/form.html' %} +
+{% endblock %} diff --git a/bookwyrm/templates/lists/list_items.html b/bookwyrm/templates/lists/list_items.html index 4560147f..942579ca 100644 --- a/bookwyrm/templates/lists/list_items.html +++ b/bookwyrm/templates/lists/list_items.html @@ -9,8 +9,8 @@
- {% for book in list.books.all|slice:5 %} - {% include 'snippets/book_cover.html' with book=book size="small" %} + {% for book in list.listitem_set.all|slice:5 %} + {% include 'snippets/book_cover.html' with book=book.book size="small" %} {% endfor %}
diff --git a/bookwyrm/templates/lists/list_layout.html b/bookwyrm/templates/lists/list_layout.html index 1887cd82..d3ff2c48 100644 --- a/bookwyrm/templates/lists/list_layout.html +++ b/bookwyrm/templates/lists/list_layout.html @@ -15,15 +15,9 @@ {% endif %} - +
+ {% include 'lists/edit_form.html' with controls_text="edit-list" %} +
{% block panel %}{% endblock %} diff --git a/bookwyrm/templates/lists/lists.html b/bookwyrm/templates/lists/lists.html index a0e18933..96ad8153 100644 --- a/bookwyrm/templates/lists/lists.html +++ b/bookwyrm/templates/lists/lists.html @@ -5,26 +5,20 @@

Lists

{% if request.user.is_authenticated and not lists.has_previous %} -
-
-
-

Your lists

-
-
- {% include 'snippets/toggle/open_button.html' with controls_text="create-list" icon="plus" text="Create new list" focus="create-list-header" %} -
-
+
+
+

Your lists

+
+
+ {% include 'snippets/toggle/open_button.html' with controls_text="create-list" icon="plus" text="Create new list" focus="create-list-header" %} +
+
- +
+ {% include 'lists/create_form.html' with controls_text="create-list" %} +
+
{% if request.user.list_set.exists %} {% include 'lists/list_items.html' with lists=request.user.list_set.all|slice:4 %} {% endif %} @@ -39,9 +33,7 @@ {% if lists %}

Recent Lists

- {% if request.user.list_set.exists %} {% include 'lists/list_items.html' with lists=lists %} - {% endif %}
{% include 'snippets/pagination.html' with page=lists path=path %} diff --git a/bookwyrm/templates/user/create_shelf_form.html b/bookwyrm/templates/user/create_shelf_form.html new file mode 100644 index 00000000..89f41fd8 --- /dev/null +++ b/bookwyrm/templates/user/create_shelf_form.html @@ -0,0 +1,26 @@ +{% extends 'components/inline_form.html' %} + +{% block header %} +Create New Shelf +{% endblock %} + +{% block form %} +
+ {% csrf_token %} + +
+ + +
+ +
+
+ {% include 'snippets/privacy_select.html' %} +
+
+ +
+
+
+{% endblock %} + diff --git a/bookwyrm/templates/user/edit_shelf_form.html b/bookwyrm/templates/user/edit_shelf_form.html new file mode 100644 index 00000000..b179be9f --- /dev/null +++ b/bookwyrm/templates/user/edit_shelf_form.html @@ -0,0 +1,31 @@ +{% extends 'components/inline_form.html' %} + +{% block header %} +Edit Shelf +{% endblock %} + +{% block form %} +
+ {% csrf_token %} + + {% if shelf.editable %} +
+ + +
+ {% else %} + + {% endif %} + +
+
+ {% include 'snippets/privacy_select.html' with current=shelf.privacy %} +
+
+ +
+
+
+{% endblock %} + + diff --git a/bookwyrm/templates/user/shelf.html b/bookwyrm/templates/user/shelf.html index add5e5db..5e2f532f 100644 --- a/bookwyrm/templates/user/shelf.html +++ b/bookwyrm/templates/user/shelf.html @@ -29,30 +29,13 @@ {% if is_self %}
- {% include 'snippets/toggle/open_button.html' with text="Create shelf" icon="plus" class="is-clickable" controls_text="create-shelf-form" %} + {% include 'snippets/toggle/open_button.html' with text="Create shelf" icon="plus" controls_text="create-shelf-form" focus="create-shelf-form-header" %}
{% endif %}
- -