From e15d6654e3ec0b461e8955a1f005e5b53dc05673 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Apr 2021 10:42:27 -0700 Subject: [PATCH 1/4] 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 9033249d4..da7dac005 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 000000000..4aa8384f0 --- /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 193cffb7a..2c5a21642 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 84482cdfc..104b5a7e6 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 28009e1a8..1b9424527 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 }} +
From f747babb4366948352a4b904e2c28bc1b3e47473 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Apr 2021 11:03:36 -0700 Subject: [PATCH 2/4] Changes column spacing --- bookwyrm/templates/layout.html | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index 104b5a7e6..d208989ec 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -190,7 +190,7 @@
-
+ +
+ {% if site.support_link %} +

+ + {% blocktrans with site_name=site.name support_link=site.support_link support_title=site.support_title %}Support {{ site_name }} on {{ support_title }}{% endblocktrans %} +

+ {% endif %} +

+ {% trans 'BookWyrm is open source software. You can contribute or report issues on GitHub.' %} +

{% if site.footer_item %}

{{ site.footer_item|safe }}

{% endif %} - {% if site.support_link %} -
- - {% blocktrans with site_name=site.name support_link=site.support_link support_title=site.support_title %}Support {{ site_name }} on {{ support_title }}{% endblocktrans %} -
- {% endif %} -
- {% trans 'BookWyrm is open source software. You can contribute or report issues on GitHub.' %} -
From 00815b3105dd71bb1f3595c8538282bcf95dfc27 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Apr 2021 11:09:06 -0700 Subject: [PATCH 3/4] Python formatting --- bookwyrm/management/commands/initdb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/management/commands/initdb.py b/bookwyrm/management/commands/initdb.py index da7dac005..2e88ce5d8 100644 --- a/bookwyrm/management/commands/initdb.py +++ b/bookwyrm/management/commands/initdb.py @@ -15,7 +15,7 @@ def init_groups(): def init_permissions(): - """ permissin types """ + """permissin types""" permissions = [ { "codename": "edit_instance_settings", @@ -134,7 +134,7 @@ def init_federated_servers(): def init_settings(): - """ info about the instance """ + """info about the instance""" SiteSettings.objects.create( support_link="https://www.patreon.com/bookwyrm", support_title="Patreon", From 9fea07039889c9962eb0e842dad375ebdcd78f3e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Apr 2021 12:53:57 -0700 Subject: [PATCH 4/4] Update bookwyrm/management/commands/initdb.py Co-authored-by: Joachim --- bookwyrm/management/commands/initdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/management/commands/initdb.py b/bookwyrm/management/commands/initdb.py index 2e88ce5d8..71ac511a0 100644 --- a/bookwyrm/management/commands/initdb.py +++ b/bookwyrm/management/commands/initdb.py @@ -15,7 +15,7 @@ def init_groups(): def init_permissions(): - """permissin types""" + """permission types""" permissions = [ { "codename": "edit_instance_settings",