forked from mirrors/bookwyrm
Don't use book absolute ids for nav
This commit is contained in:
parent
2fd7792f34
commit
1dffe425e0
10 changed files with 45 additions and 16 deletions
21
fedireads/migrations/0037_auto_20200504_0049.py
Normal file
21
fedireads/migrations/0037_auto_20200504_0049.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Generated by Django 3.0.3 on 2020-05-04 00:49
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('fedireads', '0036_auto_20200503_2007'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='author',
|
||||||
|
name='fedireads_key',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='book',
|
||||||
|
name='fedireads_key',
|
||||||
|
),
|
||||||
|
]
|
|
@ -94,9 +94,10 @@ class Book(FedireadsModel):
|
||||||
@property
|
@property
|
||||||
def absolute_id(self):
|
def absolute_id(self):
|
||||||
''' constructs the absolute reference to any db object '''
|
''' constructs the absolute reference to any db object '''
|
||||||
|
if self.sync and self.remote_id:
|
||||||
|
return self.remote_id
|
||||||
base_path = 'https://%s' % DOMAIN
|
base_path = 'https://%s' % DOMAIN
|
||||||
model_name = type(self).__name__.lower()
|
return '%s/book/%d' % (base_path, self.id)
|
||||||
return '%s/book/%s' % (base_path, self.openlibrary_key)
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
''' can't be abstract for query reasons, but you shouldn't USE it '''
|
''' can't be abstract for query reasons, but you shouldn't USE it '''
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="book-grid row shrink wrap">
|
<div class="book-grid row shrink wrap">
|
||||||
{% for book in books %}
|
{% for book in books %}
|
||||||
<div class="book-preview">
|
<div class="book-preview">
|
||||||
<a href="{{ book.absolute_id }}">
|
<a href="/book/{{ book.id }}">
|
||||||
{% include 'snippets/book_cover.html' with book=book %}
|
{% include 'snippets/book_cover.html' with book=book %}
|
||||||
</a>
|
</a>
|
||||||
{% include 'snippets/shelve_button.html' with book=book %}
|
{% include 'snippets/shelve_button.html' with book=book %}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="book-grid row wrap shrink">
|
<div class="book-grid row wrap shrink">
|
||||||
{% for book in books %}
|
{% for book in books %}
|
||||||
<div class="cover-container">
|
<div class="cover-container">
|
||||||
<a href="{{ book.absolute_id }}">
|
<a href="/book/{{ book.id }}">
|
||||||
{% include 'snippets/book_cover.html' with book=book %}
|
{% include 'snippets/book_cover.html' with book=book %}
|
||||||
</a>
|
</a>
|
||||||
{% include 'snippets/shelve_button.html' with book=book %}
|
{% include 'snippets/shelve_button.html' with book=book %}
|
||||||
|
|
|
@ -5,9 +5,15 @@
|
||||||
<h2>Editions of <a href="/book/{{ work.id }}">"{{ work.title }}"</a></h2>
|
<h2>Editions of <a href="/book/{{ work.id }}">"{{ work.title }}"</a></h2>
|
||||||
<ol class="book-grid row wrap">
|
<ol class="book-grid row wrap">
|
||||||
{% for book in editions %}
|
{% for book in editions %}
|
||||||
|
<<<<<<< HEAD
|
||||||
<li class="book-preview">
|
<li class="book-preview">
|
||||||
<a href="{{ book.absolute_id }}">
|
<a href="{{ book.absolute_id }}">
|
||||||
{% include 'snippets/book_cover.html' with book=book %}
|
{% include 'snippets/book_cover.html' with book=book %}
|
||||||
|
=======
|
||||||
|
<div class="book-preview">
|
||||||
|
<a href="/book/{{ book.id }}">
|
||||||
|
{% include 'snippets/book_cover.html' with book=book %}
|
||||||
|
>>>>>>> Don't use book absolute ids for nav
|
||||||
</a>
|
</a>
|
||||||
{% include 'snippets/shelve_button.html' with book=book %}
|
{% include 'snippets/shelve_button.html' with book=book %}
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% if item.book %}
|
{% if item.book %}
|
||||||
<a href="{{ item.book.absolute_id }}">
|
<a href="/book/{{ item.book.id }}">
|
||||||
{% include 'snippets/book_cover.html' with book=item.book size='small' %}
|
{% include 'snippets/book_cover.html' with book=item.book size='small' %}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
<div class="tabs secondary">
|
<div class="tabs secondary">
|
||||||
<div class="tab active" data-id="tab-review-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
<div class="tab active" data-id="tab-review-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
||||||
<a href="{{ book.absolute_id }}/review" onclick="tabChange(event)">Review</a>
|
<a href="/book/{{ book.id }}/review" onclick="tabChange(event)">Review</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab" data-id="tab-comment-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
<div class="tab" data-id="tab-comment-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
||||||
<a href="{{ book.absolute_id }}/comment" onclick="tabChange(event)">Comment</a>
|
<a href="/book/{{ book.id }}/comment" onclick="tabChange(event)">Comment</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab" data-id="tab-quotation-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
<div class="tab" data-id="tab-quotation-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
||||||
<a href="{{ book.absolute_id }}/quotation" onclick="tabChange(event)">Quote</a>
|
<a href="/book/{{ book.id }}/quotation" onclick="tabChange(event)">Quote</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
{% if status.status_type == 'Update' %}
|
{% if status.status_type == 'Update' %}
|
||||||
{{ status.content | safe }}
|
{{ status.content | safe }}
|
||||||
{% elif status.status_type == 'Review' and not status.name and not status.content%}
|
{% elif status.status_type == 'Review' and not status.name and not status.content%}
|
||||||
rated <a href="{{ status.book.absolute_id }}">{{ status.book.title }}</a>
|
rated <a href="/book/{{ status.book.id }}">{{ status.book.title }}</a>
|
||||||
{% elif status.status_type == 'Review' %}
|
{% elif status.status_type == 'Review' %}
|
||||||
reviewed <a href="{{ status.book.absolute_id }}">{{ status.book.title }}</a>
|
reviewed <a href="/book/{{ status.book.id }}">{{ status.book.title }}</a>
|
||||||
{% elif status.status_type == 'Comment' %}
|
{% elif status.status_type == 'Comment' %}
|
||||||
commented on <a href="{{ status.book.absolute_id }}">{{ status.book.title }}</a>
|
commented on <a href="/book/{{ status.book.id }}">{{ status.book.title }}</a>
|
||||||
{% elif status.status_type == 'Quotation' %}
|
{% elif status.status_type == 'Quotation' %}
|
||||||
quoted <a href="{{ status.book.absolute_id }}">{{ status.book.title }}</a>
|
quoted <a href="/book/{{ status.book.id }}">{{ status.book.title }}</a>
|
||||||
{% elif status.status_type == 'Boost' %}
|
{% elif status.status_type == 'Boost' %}
|
||||||
boosted
|
boosted
|
||||||
{% elif status.reply_parent %}
|
{% elif status.reply_parent %}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="book-grid row wrap shrink">
|
<div class="book-grid row wrap shrink">
|
||||||
{% for book in books.all %}
|
{% for book in books.all %}
|
||||||
<div class="cover-container">
|
<div class="cover-container">
|
||||||
<a href="{{ book.absolute_id }}">
|
<a href="/book/{{ book.id }}">
|
||||||
{% include 'snippets/book_cover.html' with book=book %}
|
{% include 'snippets/book_cover.html' with book=book %}
|
||||||
</a>
|
</a>
|
||||||
{% include 'snippets/rate_action.html' with user=request.user book=book %}
|
{% include 'snippets/rate_action.html' with user=request.user book=book %}
|
||||||
|
|
|
@ -4,6 +4,7 @@ from django.db.models import Avg, Q
|
||||||
from django.http import HttpResponseBadRequest, HttpResponseNotFound,\
|
from django.http import HttpResponseBadRequest, HttpResponseNotFound,\
|
||||||
JsonResponse
|
JsonResponse
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
from django.shortcuts import redirect
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
|
||||||
|
@ -366,15 +367,15 @@ def edit_profile_page(request):
|
||||||
|
|
||||||
def book_page(request, book_id, tab='friends'):
|
def book_page(request, book_id, tab='friends'):
|
||||||
''' info about a book '''
|
''' info about a book '''
|
||||||
key = 'id'
|
|
||||||
connector_id = None
|
|
||||||
if ':' in book_id:
|
if ':' in book_id:
|
||||||
try:
|
try:
|
||||||
connector_id, key, book_id = book_id.split(':')
|
connector_id, key, book_id = book_id.split(':')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return HttpResponseNotFound()
|
return HttpResponseNotFound()
|
||||||
book = get_or_create_book(book_id, key=key, connector_id=connector_id)
|
book = get_or_create_book(book_id, key=key, connector_id=connector_id)
|
||||||
|
return redirect('/book/%d' % book.id)
|
||||||
|
|
||||||
|
book = get_or_create_book(book_id)
|
||||||
if is_api_request(request):
|
if is_api_request(request):
|
||||||
return JsonResponse(activitypub.get_book(book))
|
return JsonResponse(activitypub.get_book(book))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue