mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +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.")
|
code_of_conduct = models.TextField(default="Add a code of conduct here.")
|
||||||
privacy_policy = models.TextField(default="Add a privacy policy 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
|
# registration
|
||||||
allow_registration = models.BooleanField(default=False)
|
allow_registration = models.BooleanField(default=False)
|
||||||
|
|
|
@ -47,6 +47,14 @@
|
||||||
{% trans "Privacy Policy" %}
|
{% trans "Privacy Policy" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</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>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,19 @@
|
||||||
<label class="label" for="id_privacy_policy">{% trans "Privacy Policy:" %}</label>
|
<label class="label" for="id_privacy_policy">{% trans "Privacy Policy:" %}</label>
|
||||||
{{ site_form.privacy_policy }}
|
{{ site_form.privacy_policy }}
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,11 @@
|
||||||
<p>
|
<p>
|
||||||
<a href ="{% url 'privacy' %}">{% trans "Privacy Policy" %}</a>
|
<a href ="{% url 'privacy' %}">{% trans "Privacy Policy" %}</a>
|
||||||
</p>
|
</p>
|
||||||
|
{% if site.show_impressum %}
|
||||||
|
<p>
|
||||||
|
<a href ="{% url 'impressum' %}">{% trans "Impressum" %}</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="column content">
|
<div class="column content">
|
||||||
{% if site.support_link %}
|
{% if site.support_link %}
|
||||||
|
|
|
@ -14,6 +14,7 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class SiteSettingsViews(TestCase):
|
class SiteSettingsViews(TestCase):
|
||||||
"""Edit site settings"""
|
"""Edit site settings"""
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
|
@ -56,6 +57,8 @@ class SiteSettingsViews(TestCase):
|
||||||
form.data["invite_request_text"] = "blah"
|
form.data["invite_request_text"] = "blah"
|
||||||
form.data["code_of_conduct"] = "blah"
|
form.data["code_of_conduct"] = "blah"
|
||||||
form.data["privacy_policy"] = "blah"
|
form.data["privacy_policy"] = "blah"
|
||||||
|
form.data["show_impressum"] = False
|
||||||
|
form.data["impressum"] = "bleh"
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
|
|
|
@ -318,6 +318,7 @@ urlpatterns = [
|
||||||
re_path(r"^about/?$", views.about, name="about"),
|
re_path(r"^about/?$", views.about, name="about"),
|
||||||
re_path(r"^privacy/?$", views.privacy, name="privacy"),
|
re_path(r"^privacy/?$", views.privacy, name="privacy"),
|
||||||
re_path(r"^conduct/?$", views.conduct, name="conduct"),
|
re_path(r"^conduct/?$", views.conduct, name="conduct"),
|
||||||
|
re_path(r"^impressum/?$", views.impressum, name="impressum"),
|
||||||
path("", views.Home.as_view(), name="landing"),
|
path("", views.Home.as_view(), name="landing"),
|
||||||
re_path(r"^discover/?$", views.Discover.as_view(), name="discover"),
|
re_path(r"^discover/?$", views.Discover.as_view(), name="discover"),
|
||||||
re_path(r"^notifications/?$", views.Notifications.as_view(), name="notifications"),
|
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
|
from .books.links import BookFileLinks, AddFileLink, delete_link
|
||||||
|
|
||||||
# landing
|
# landing
|
||||||
from .landing.about import about, privacy, conduct
|
from .landing.about import about, privacy, conduct, impressum
|
||||||
from .landing.landing import Home, Landing
|
from .landing.landing import Home, Landing
|
||||||
from .landing.login import Login, Logout
|
from .landing.login import Login, Logout
|
||||||
from .landing.register import Register
|
from .landing.register import Register
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
""" non-interactive pages """
|
""" non-interactive pages """
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
|
from django.http import Http404
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.views.decorators.http import require_GET
|
from django.views.decorators.http import require_GET
|
||||||
|
@ -36,3 +37,12 @@ def conduct(request):
|
||||||
def privacy(request):
|
def privacy(request):
|
||||||
"""more information about the instance"""
|
"""more information about the instance"""
|
||||||
return TemplateResponse(request, "about/privacy.html")
|
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