diff --git a/bookwyrm/migrations/0167_auto_20221125_1900.py b/bookwyrm/migrations/0167_auto_20221125_1900.py new file mode 100644 index 000000000..db258b7c5 --- /dev/null +++ b/bookwyrm/migrations/0167_auto_20221125_1900.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.16 on 2022-11-25 19:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0166_sitesettings_imports_enabled"), + ] + + operations = [ + migrations.AddField( + model_name="sitesettings", + name="impressum", + field=models.TextField(default="Add a impressum here."), + ), + migrations.AddField( + model_name="sitesettings", + name="show_impressum", + field=models.BooleanField(default=False), + ), + ] diff --git a/bookwyrm/models/site.py b/bookwyrm/models/site.py index 9e97ede9a..533a37b30 100644 --- a/bookwyrm/models/site.py +++ b/bookwyrm/models/site.py @@ -62,6 +62,8 @@ class SiteSettings(SiteModel): ) code_of_conduct = models.TextField(default="Add a code of conduct here.") privacy_policy = models.TextField(default="Add a privacy policy here.") + impressum = models.TextField(default="Add a impressum here.") + show_impressum = models.BooleanField(default=False) # registration allow_registration = models.BooleanField(default=False) diff --git a/bookwyrm/templates/about/layout.html b/bookwyrm/templates/about/layout.html index e921fcd29..22237508c 100644 --- a/bookwyrm/templates/about/layout.html +++ b/bookwyrm/templates/about/layout.html @@ -47,6 +47,14 @@ {% trans "Privacy Policy" %} + {% if site.show_impressum %} +
  • + {% url 'impressum' as path %} + + {% trans "Impressum" %} + +
  • + {% endif %} diff --git a/bookwyrm/templates/settings/site.html b/bookwyrm/templates/settings/site.html index 4fd147834..4cfa531e5 100644 --- a/bookwyrm/templates/settings/site.html +++ b/bookwyrm/templates/settings/site.html @@ -68,6 +68,19 @@ {{ site_form.privacy_policy }} + +
    + + {{ site_form.impressum }} +
    +
    +
    + +
    +
    + {{ site_form.show_impressum }} +
    +
    diff --git a/bookwyrm/templates/snippets/footer.html b/bookwyrm/templates/snippets/footer.html index 77be88bfe..a1f13a5b8 100644 --- a/bookwyrm/templates/snippets/footer.html +++ b/bookwyrm/templates/snippets/footer.html @@ -29,6 +29,11 @@

    {% trans "Privacy Policy" %}

    + {% if site.show_impressum %} +

    + {% trans "Impressum" %} +

    + {% endif %}
    {% if site.support_link %} diff --git a/bookwyrm/tests/views/admin/test_site.py b/bookwyrm/tests/views/admin/test_site.py index 85f785027..8eda6a2fb 100644 --- a/bookwyrm/tests/views/admin/test_site.py +++ b/bookwyrm/tests/views/admin/test_site.py @@ -14,6 +14,7 @@ from bookwyrm.tests.validate_html import validate_html class SiteSettingsViews(TestCase): """Edit site settings""" + # pylint: disable=invalid-name def setUp(self): """we need basic test data and mocks""" self.factory = RequestFactory() @@ -56,6 +57,8 @@ class SiteSettingsViews(TestCase): form.data["invite_request_text"] = "blah" form.data["code_of_conduct"] = "blah" form.data["privacy_policy"] = "blah" + form.data["show_impressum"] = False + form.data["impressum"] = "bleh" request = self.factory.post("", form.data) request.user = self.local_user diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index daf05e10e..90d0d0edc 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -318,6 +318,7 @@ urlpatterns = [ re_path(r"^about/?$", views.about, name="about"), re_path(r"^privacy/?$", views.privacy, name="privacy"), re_path(r"^conduct/?$", views.conduct, name="conduct"), + re_path(r"^impressum/?$", views.impressum, name="impressum"), path("", views.Home.as_view(), name="landing"), re_path(r"^discover/?$", views.Discover.as_view(), name="discover"), re_path(r"^notifications/?$", views.Notifications.as_view(), name="notifications"), diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 21e33450c..bc70490c5 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -60,7 +60,7 @@ from .books.editions import Editions, switch_edition from .books.links import BookFileLinks, AddFileLink, delete_link # landing -from .landing.about import about, privacy, conduct +from .landing.about import about, privacy, conduct, impressum from .landing.landing import Home, Landing from .landing.login import Login, Logout from .landing.register import Register diff --git a/bookwyrm/views/landing/about.py b/bookwyrm/views/landing/about.py index 7016dfcdb..0bcdfd836 100644 --- a/bookwyrm/views/landing/about.py +++ b/bookwyrm/views/landing/about.py @@ -1,5 +1,6 @@ """ non-interactive pages """ from dateutil.relativedelta import relativedelta +from django.http import Http404 from django.template.response import TemplateResponse from django.utils import timezone from django.views.decorators.http import require_GET @@ -36,3 +37,12 @@ def conduct(request): def privacy(request): """more information about the instance""" return TemplateResponse(request, "about/privacy.html") + + +@require_GET +def impressum(request): + """more information about the instance""" + site = models.SiteSettings.objects.get() + if not site.show_impressum: + raise Http404() + return TemplateResponse(request, "about/impressum.html")