diff --git a/bookwyrm/models/shelf.py b/bookwyrm/models/shelf.py index 739c0599..3209da5d 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -37,9 +37,13 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel): """ set the identifier """ super().save(*args, **kwargs) if not self.identifier: - slug = re.sub(r"[^\w]", "", self.name).lower() - self.identifier = "%s-%d" % (slug, self.id) - super().save(*args, **kwargs) + self.identifier = self.get_identifier() + super().save(*args, **kwargs, broadcast=False) + + def get_identifier(self): + """ custom-shelf-123 for the url """ + slug = re.sub(r"[^\w]", "", self.name).lower() + return "{:s}-{:d}".format(slug, self.id) @property def collection_queryset(self): @@ -49,7 +53,8 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel): def get_remote_id(self): """ shelf identifier instead of id """ base_path = self.user.remote_id - return "%s/shelf/%s" % (base_path, self.identifier) + identifier = self.identifier or self.get_identifier() + return "%s/books/%s" % (base_path, identifier) class Meta: """ user/shelf unqiueness """ diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 95cf86ad..3931ea5b 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -165,32 +165,11 @@ {% include 'snippets/readthrough.html' with readthrough=readthrough %} {% endfor %} - {% endif %} - {% if request.user.is_authenticated %}
{% include 'snippets/create_status.html' with book=book hide_cover=True %}
- -
-
- - {% csrf_token %} - - - -
-
{% endif %} - -
-
- {% for tag in tags %} - {% include 'snippets/tag.html' with book=book tag=tag user_tags=user_tags %} - {% endfor %} -
-
-
{% if book.subjects %} diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index f0f04b84..0937fcc3 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -55,7 +55,7 @@ diff --git a/bookwyrm/templates/user/books_header.html b/bookwyrm/templates/user/books_header.html new file mode 100644 index 00000000..8fea84c7 --- /dev/null +++ b/bookwyrm/templates/user/books_header.html @@ -0,0 +1,6 @@ +{% load i18n %} +{% if is_self %} +{% trans "Your books" %} +{% else %} +{% blocktrans with username=user.display_name %}{{ username }}'s books{% endblocktrans %} +{% endif %} diff --git a/bookwyrm/templates/user/shelf.html b/bookwyrm/templates/user/shelf.html index 4c60258c..8d23dce4 100644 --- a/bookwyrm/templates/user/shelf.html +++ b/bookwyrm/templates/user/shelf.html @@ -3,14 +3,14 @@ {% load humanize %} {% load i18n %} +{% block title %} +{% include 'user/books_header.html' %} +{% endblock %} + {% block header %}

- {% if is_self %} - {% trans "Your Shelves" %} - {% else %} - {% blocktrans with username=user.display_name %}{{ username }}: Shelves{% endblocktrans %} - {% endif %} + {% include 'user/books_header.html' %}

{% endblock %} @@ -20,10 +20,13 @@
@@ -50,7 +53,7 @@
- {% if is_self %} + {% if is_self and shelf.id %}
{% trans "Edit shelf" as button_text %} {% include 'snippets/toggle/open_button.html' with text=button_text icon="pencil" controls_text="edit-shelf-form" focus="edit-shelf-form-header" %} @@ -81,7 +84,6 @@ {% endif %} {% for book in books %} - {% with book=book.book %} {% include 'snippets/book_cover.html' with book=book size="small" %} @@ -113,13 +115,12 @@ {% endif %} - {% endwith %} {% endfor %}
{% else %}

{% trans "This shelf is empty." %}

- {% if shelf.editable %} + {% if shelf.id and shelf.editable %}
{% csrf_token %} diff --git a/bookwyrm/templates/user/user.html b/bookwyrm/templates/user/user.html index 52a91561..a54664ce 100644 --- a/bookwyrm/templates/user/user.html +++ b/bookwyrm/templates/user/user.html @@ -1,5 +1,6 @@ {% extends 'user/user_layout.html' %} {% load i18n %} +{% load bookwyrm_tags %} {% block title %}{{ user.display_name }}{% endblock %} @@ -23,12 +24,14 @@ {% block panel %} {% if user.bookwyrm_user %}
-

{% trans "Shelves" %}

+

+ {% include 'user/books_header.html' %} +

{% for shelf in shelves %} {% endif %} diff --git a/bookwyrm/templates/user/user_layout.html b/bookwyrm/templates/user/user_layout.html index d60db2a0..0c3e94e3 100644 --- a/bookwyrm/templates/user/user_layout.html +++ b/bookwyrm/templates/user/user_layout.html @@ -42,7 +42,7 @@ {% endif %}
{% with user|username as username %} -{% if 'user/'|add:username|add:'/shelf' not in request.path and 'user/'|add:username|add:'/shelves' not in request.path %} +{% if 'user/'|add:username|add:'/books' not in request.path and 'user/'|add:username|add:'/shelf' not in request.path %}