mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-15 11:45:27 +00:00
Null state for links
This commit is contained in:
parent
8ba3a4ab00
commit
d610115a5b
5 changed files with 47 additions and 10 deletions
|
@ -3,7 +3,7 @@ from django.core.management.base import BaseCommand
|
||||||
from django.contrib.auth.models import Group, Permission
|
from django.contrib.auth.models import Group, Permission
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
|
||||||
from bookwyrm.models import Connector, FederatedServer, SiteSettings, User
|
from bookwyrm import models
|
||||||
|
|
||||||
|
|
||||||
def init_groups():
|
def init_groups():
|
||||||
|
@ -55,7 +55,7 @@ def init_permissions():
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
content_type = ContentType.objects.get_for_model(User)
|
content_type = models.ContentType.objects.get_for_model(User)
|
||||||
for permission in permissions:
|
for permission in permissions:
|
||||||
permission_obj = Permission.objects.create(
|
permission_obj = Permission.objects.create(
|
||||||
codename=permission["codename"],
|
codename=permission["codename"],
|
||||||
|
@ -72,7 +72,7 @@ def init_permissions():
|
||||||
|
|
||||||
def init_connectors():
|
def init_connectors():
|
||||||
"""access book data sources"""
|
"""access book data sources"""
|
||||||
Connector.objects.create(
|
models.Connector.objects.create(
|
||||||
identifier="bookwyrm.social",
|
identifier="bookwyrm.social",
|
||||||
name="BookWyrm dot Social",
|
name="BookWyrm dot Social",
|
||||||
connector_file="bookwyrm_connector",
|
connector_file="bookwyrm_connector",
|
||||||
|
@ -84,7 +84,7 @@ def init_connectors():
|
||||||
priority=2,
|
priority=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
Connector.objects.create(
|
models.Connector.objects.create(
|
||||||
identifier="inventaire.io",
|
identifier="inventaire.io",
|
||||||
name="Inventaire",
|
name="Inventaire",
|
||||||
connector_file="inventaire",
|
connector_file="inventaire",
|
||||||
|
@ -96,7 +96,7 @@ def init_connectors():
|
||||||
priority=3,
|
priority=3,
|
||||||
)
|
)
|
||||||
|
|
||||||
Connector.objects.create(
|
models.Connector.objects.create(
|
||||||
identifier="openlibrary.org",
|
identifier="openlibrary.org",
|
||||||
name="OpenLibrary",
|
name="OpenLibrary",
|
||||||
connector_file="openlibrary",
|
connector_file="openlibrary",
|
||||||
|
@ -113,7 +113,7 @@ def init_federated_servers():
|
||||||
"""big no to nazis"""
|
"""big no to nazis"""
|
||||||
built_in_blocks = ["gab.ai", "gab.com"]
|
built_in_blocks = ["gab.ai", "gab.com"]
|
||||||
for server in built_in_blocks:
|
for server in built_in_blocks:
|
||||||
FederatedServer.objects.create(
|
models.FederatedServer.objects.create(
|
||||||
server_name=server,
|
server_name=server,
|
||||||
status="blocked",
|
status="blocked",
|
||||||
)
|
)
|
||||||
|
@ -121,12 +121,36 @@ def init_federated_servers():
|
||||||
|
|
||||||
def init_settings():
|
def init_settings():
|
||||||
"""info about the instance"""
|
"""info about the instance"""
|
||||||
SiteSettings.objects.create(
|
models.SiteSettings.objects.create(
|
||||||
support_link="https://www.patreon.com/bookwyrm",
|
support_link="https://www.patreon.com/bookwyrm",
|
||||||
support_title="Patreon",
|
support_title="Patreon",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def init_link_domains(*_):
|
||||||
|
"""safe book links"""
|
||||||
|
models.LinkDomain.objects.create(
|
||||||
|
domain="www.gutenberg.org",
|
||||||
|
name="Project Gutenberg",
|
||||||
|
status="approved",
|
||||||
|
)
|
||||||
|
models.LinkDomain.objects.create(
|
||||||
|
domain="archive.org",
|
||||||
|
name="Internet Archive",
|
||||||
|
status="approved",
|
||||||
|
)
|
||||||
|
models.LinkDomain.objects.create(
|
||||||
|
domain="openlibrary.org",
|
||||||
|
name="Open Library",
|
||||||
|
status="approved",
|
||||||
|
)
|
||||||
|
models.LinkDomain.objects.create(
|
||||||
|
domain="theanarchistlibrary.org",
|
||||||
|
name="The Anarchist Library",
|
||||||
|
status="approved",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = "Initializes the database with starter data"
|
help = "Initializes the database with starter data"
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import bookwyrm.models.fields
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
from bookwyrm.management.commands.initdb import init_link_domains
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
@ -123,4 +125,5 @@ class Migration(migrations.Migration):
|
||||||
},
|
},
|
||||||
bases=("bookwyrm.link",),
|
bases=("bookwyrm.link",),
|
||||||
),
|
),
|
||||||
|
migrations.RunPython(init_link_domains, reverse_code=migrations.RunPython.noop),
|
||||||
]
|
]
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
{% load utilities %}
|
{% load utilities %}
|
||||||
|
|
||||||
{% get_book_file_links book as links %}
|
{% get_book_file_links book as links %}
|
||||||
|
{% if links.exists or request.user.is_authenticated %}
|
||||||
<header class="columns is-mobile mb-0">
|
<header class="columns is-mobile mb-0">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<h2 class="title is-5">{% trans "Get a copy" %}</h2>
|
<h2 class="title is-5">{% trans "Get a copy" %}</h2>
|
||||||
|
@ -34,8 +35,12 @@
|
||||||
{% join "verify" link.id as verify_modal %}
|
{% join "verify" link.id as verify_modal %}
|
||||||
{% include "book/link_verification_modal.html" with id=verify_modal %}
|
{% include "book/link_verification_modal.html" with id=verify_modal %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<em>{% trans "No links available" %}</em>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if can_edit_book %}
|
{% if can_edit_book %}
|
||||||
{% include 'book/file_link_modal.html' with book=book id="edit-links" %}
|
{% include 'book/file_link_modal.html' with book=book id="edit-links" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
|
@ -17,15 +17,15 @@
|
||||||
<ul>
|
<ul>
|
||||||
{% url 'settings-link-domain' status='pending' as url %}
|
{% url 'settings-link-domain' status='pending' as url %}
|
||||||
<li {% if request.path in url %}class="is-active" aria-current="page"{% endif %}>
|
<li {% if request.path in url %}class="is-active" aria-current="page"{% endif %}>
|
||||||
<a href="{{ url }}">{% trans "Pending" %}</a>
|
<a href="{{ url }}">{% trans "Pending" %} ({{ counts.pending }})</a>
|
||||||
</li>
|
</li>
|
||||||
{% url 'settings-link-domain' status='approved' as url %}
|
{% url 'settings-link-domain' status='approved' as url %}
|
||||||
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
|
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
|
||||||
<a href="{{ url }}">{% trans "Approved" %}</a>
|
<a href="{{ url }}">{% trans "Approved" %} ({{ counts.approved }})</a>
|
||||||
</li>
|
</li>
|
||||||
{% url 'settings-link-domain' status='blocked' as url %}
|
{% url 'settings-link-domain' status='blocked' as url %}
|
||||||
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
|
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
|
||||||
<a href="{{ url }}">{% trans "Blocked" %}</a>
|
<a href="{{ url }}">{% trans "Blocked" %} ({{ counts.blocked }})</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -23,6 +23,11 @@ class LinkDomain(View):
|
||||||
"domains": models.LinkDomain.objects.filter(status=status).prefetch_related(
|
"domains": models.LinkDomain.objects.filter(status=status).prefetch_related(
|
||||||
"links"
|
"links"
|
||||||
),
|
),
|
||||||
|
"counts": {
|
||||||
|
"pending": models.LinkDomain.objects.filter(status="pending").count(),
|
||||||
|
"approved": models.LinkDomain.objects.filter(status="approved").count(),
|
||||||
|
"blocked": models.LinkDomain.objects.filter(status="blocked").count(),
|
||||||
|
},
|
||||||
"form": forms.EmailBlocklistForm(),
|
"form": forms.EmailBlocklistForm(),
|
||||||
"status": status,
|
"status": status,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue