From e15d6654e3ec0b461e8955a1f005e5b53dc05673 Mon Sep 17 00:00:00 2001
From: Mouse Reeve
Date: Fri, 30 Apr 2021 10:42:27 -0700
Subject: [PATCH] Free text field for the site footer
---
bookwyrm/management/commands/initdb.py | 12 ++++++++++--
.../0073_sitesettings_footer_item.py | 18 ++++++++++++++++++
bookwyrm/models/site.py | 9 +++++++++
bookwyrm/templates/layout.html | 5 +++++
bookwyrm/templates/settings/site.html | 12 ++++++++----
5 files changed, 50 insertions(+), 6 deletions(-)
create mode 100644 bookwyrm/migrations/0073_sitesettings_footer_item.py
diff --git a/bookwyrm/management/commands/initdb.py b/bookwyrm/management/commands/initdb.py
index 9033249d..da7dac00 100644
--- a/bookwyrm/management/commands/initdb.py
+++ b/bookwyrm/management/commands/initdb.py
@@ -1,4 +1,5 @@
-from django.core.management.base import BaseCommand, CommandError
+""" What you need in the database to make it work """
+from django.core.management.base import BaseCommand
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
@@ -7,12 +8,14 @@ from bookwyrm.settings import DOMAIN
def init_groups():
+ """permission levels"""
groups = ["admin", "moderator", "editor"]
for group in groups:
Group.objects.create(name=group)
def init_permissions():
+ """ permissin types """
permissions = [
{
"codename": "edit_instance_settings",
@@ -69,6 +72,7 @@ def init_permissions():
def init_connectors():
+ """access book data sources"""
Connector.objects.create(
identifier=DOMAIN,
name="Local",
@@ -130,7 +134,11 @@ def init_federated_servers():
def init_settings():
- SiteSettings.objects.create()
+ """ info about the instance """
+ SiteSettings.objects.create(
+ support_link="https://www.patreon.com/bookwyrm",
+ support_title="Patreon",
+ )
class Command(BaseCommand):
diff --git a/bookwyrm/migrations/0073_sitesettings_footer_item.py b/bookwyrm/migrations/0073_sitesettings_footer_item.py
new file mode 100644
index 00000000..4aa8384f
--- /dev/null
+++ b/bookwyrm/migrations/0073_sitesettings_footer_item.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.2 on 2021-04-30 17:25
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("bookwyrm", "0072_remove_work_default_edition"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="sitesettings",
+ name="footer_item",
+ field=models.TextField(blank=True, null=True),
+ ),
+ ]
diff --git a/bookwyrm/models/site.py b/bookwyrm/models/site.py
index 193cffb7..2c5a2164 100644
--- a/bookwyrm/models/site.py
+++ b/bookwyrm/models/site.py
@@ -19,19 +19,28 @@ class SiteSettings(models.Model):
max_length=150, default="Social Reading and Reviewing"
)
instance_description = models.TextField(default="This instance has no description.")
+
+ # about page
registration_closed_text = models.TextField(
default="Contact an administrator to get an invite"
)
code_of_conduct = models.TextField(default="Add a code of conduct here.")
privacy_policy = models.TextField(default="Add a privacy policy here.")
+
+ # registration
allow_registration = models.BooleanField(default=True)
allow_invite_requests = models.BooleanField(default=True)
+
+ # images
logo = models.ImageField(upload_to="logos/", null=True, blank=True)
logo_small = models.ImageField(upload_to="logos/", null=True, blank=True)
favicon = models.ImageField(upload_to="logos/", null=True, blank=True)
+
+ # footer
support_link = models.CharField(max_length=255, null=True, blank=True)
support_title = models.CharField(max_length=100, null=True, blank=True)
admin_email = models.EmailField(max_length=255, null=True, blank=True)
+ footer_item = models.TextField(null=True, blank=True)
@classmethod
def get(cls):
diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html
index 84482cdf..104b5a7e 100644
--- a/bookwyrm/templates/layout.html
+++ b/bookwyrm/templates/layout.html
@@ -200,6 +200,11 @@
{% endif %}
+ {% if site.footer_item %}
+
+
{{ site.footer_item|safe }}
+
+ {% endif %}
{% if site.support_link %}
diff --git a/bookwyrm/templates/settings/site.html b/bookwyrm/templates/settings/site.html
index 28009e1a..1b942452 100644
--- a/bookwyrm/templates/settings/site.html
+++ b/bookwyrm/templates/settings/site.html
@@ -37,16 +37,16 @@
{% trans "Images" %}
-
-
+
+
{{ site_form.logo }}
-
+
{{ site_form.logo_small }}
-
+
{{ site_form.favicon }}
@@ -69,6 +69,10 @@
{{ site_form.admin_email }}
+
+
+ {{ site_form.footer_item }}
+