Skip to content

Commit

Permalink
Merge pull request #2450 from bookwyrm-social/impressum
Browse files Browse the repository at this point in the history
Adds database fields for legal page/impressum
  • Loading branch information
mouse-reeve committed Dec 4, 2022
2 parents c4d2527 + b7b7b26 commit 5172f67
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 1 deletion.
23 changes: 23 additions & 0 deletions bookwyrm/migrations/0167_auto_20221125_1900.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
2 changes: 2 additions & 0 deletions bookwyrm/models/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions bookwyrm/templates/about/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ <h2 class="menu-label">{% blocktrans with site_name=site.name %}About {{ site_na
{% trans "Privacy Policy" %}
</a>
</li>
{% if site.show_impressum %}
<li>
{% url 'impressum' as path %}
<a href="{{ path }}" {% if request.path in path %}class="is-active"{% endif %}>
{% trans "Impressum" %}
</a>
</li>
{% endif %}
</ul>
</nav>

Expand Down
13 changes: 13 additions & 0 deletions bookwyrm/templates/settings/site.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ <h2 class="title is-4">{% trans "Instance Info" %}</h2>
<label class="label" for="id_privacy_policy">{% trans "Privacy Policy:" %}</label>
{{ site_form.privacy_policy }}
</div>

<div class="field">
<label class="label" for="id_impressum">{% trans "Impressum:" %}</label>
{{ site_form.impressum }}
</div>
<div class="field is-horizontal">
<div class="field mr-2">
<label class="label" for="id_show_impressum">{% trans "Include impressum:" %}</label>
</div>
<div class="control">
{{ site_form.show_impressum }}
</div>
</div>
</div>
</section>

Expand Down
5 changes: 5 additions & 0 deletions bookwyrm/templates/snippets/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<p>
<a href ="{% url 'privacy' %}">{% trans "Privacy Policy" %}</a>
</p>
{% if site.show_impressum %}
<p>
<a href ="{% url 'impressum' %}">{% trans "Impressum" %}</a>
</p>
{% endif %}
</div>
<div class="column content">
{% if site.support_link %}
Expand Down
3 changes: 3 additions & 0 deletions bookwyrm/tests/views/admin/test_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
class SiteSettingsViews(TestCase):
"""Edit site settings"""

# pylint: disable=invalid-name
def setUp(self):
"""we need basic test data and mocks"""
self.factory = RequestFactory()
Expand Down Expand Up @@ -56,6 +57,8 @@ def test_site_post(self):
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

Expand Down
1 change: 1 addition & 0 deletions bookwyrm/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@
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"),
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
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
Expand Down
10 changes: 10 additions & 0 deletions bookwyrm/views/landing/about.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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")

0 comments on commit 5172f67

Please sign in to comment.