mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 09:31:08 +00:00
Merge pull request #2450 from bookwyrm-social/impressum
Adds database fields for legal page/impressum
This commit is contained in:
commit
5172f67c35
9 changed files with 66 additions and 1 deletions
23
bookwyrm/migrations/0167_auto_20221125_1900.py
Normal file
23
bookwyrm/migrations/0167_auto_20221125_1900.py
Normal file
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
|
|
@ -47,6 +47,14 @@
|
|||
{% 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>
|
||||
|
||||
|
|
|
@ -68,6 +68,19 @@
|
|||
<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>
|
||||
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue