-
Notifications
You must be signed in to change notification settings - Fork 16
589: add privacy policy and imprint links #955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
sascha11110
wants to merge
1
commit into
main
Choose a base branch
from
589-privacy-policy-and-imprint-links
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ db.sqlite3 | |
| build | ||
| dist | ||
| .vscode | ||
| .idea | ||
| .idea/dataSources.xml | ||
| .idea/misc.xml | ||
| .coverage | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| {% load i18n %} | ||
| {% if privacy_policy_url or imprint_url %} | ||
| <span class="legal-links"> | ||
| {% if privacy_policy_url %} | ||
| <a href="{{ privacy_policy_url }}" target="_blank" rel="noopener noreferrer">{% translate "Privacy policy" %}</a> | ||
| {% endif %} | ||
| {% if privacy_policy_url and imprint_url %} | ||
| <span aria-hidden="true">·</span> | ||
| {% endif %} | ||
| {% if imprint_url %} | ||
| <a href="{{ imprint_url }}" target="_blank" rel="noopener noreferrer">{% translate "Imprint" %}</a> | ||
| {% endif %} | ||
| </span> | ||
| {% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| {% extends "admin/login.html" %} | ||
|
|
||
| {# Appends the legal links below the login form. Jazzmin's login template only #} | ||
| {# defines the "content" block, so the form itself is reused via block.super. #} | ||
| {% block content %} | ||
| {{ block.super }} | ||
| <div class="text-center mt-3"> | ||
| {% include "admin/includes/legal_links.html" %} | ||
| </div> | ||
| {% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| """ | ||
| Tests for the privacy policy and imprint links. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
| from django.contrib.auth.models import User | ||
| from django.test import Client | ||
| from django.test.utils import override_settings | ||
| from django.urls import reverse | ||
|
|
||
| from lunes_cms.core.utils import legal_menu_links | ||
|
|
||
| PRIVACY_POLICY_URL = "https://lunes.app/datenschutz" | ||
| IMPRINT_URL = "https://www.tuerantuer.org/impressum" | ||
|
|
||
|
|
||
| @pytest.mark.django_db | ||
| @override_settings(PRIVACY_POLICY_URL=PRIVACY_POLICY_URL, IMPRINT_URL=IMPRINT_URL) | ||
| def test_login_page_shows_legal_links(client: Client) -> None: | ||
| """Both links have to be reachable without being logged in.""" | ||
| content = client.get(reverse("admin:login")).content.decode() | ||
| assert PRIVACY_POLICY_URL in content | ||
| assert IMPRINT_URL in content | ||
|
|
||
|
|
||
| @pytest.mark.django_db | ||
| @override_settings(PRIVACY_POLICY_URL="", IMPRINT_URL="") | ||
| def test_login_page_without_configured_urls_shows_no_legal_links( | ||
| client: Client, | ||
| ) -> None: | ||
| """Without configured URLs, no empty links may be rendered.""" | ||
| content = client.get(reverse("admin:login")).content.decode() | ||
| assert "legal-links" not in content | ||
|
|
||
|
|
||
| @pytest.mark.django_db | ||
| @override_settings(PRIVACY_POLICY_URL=PRIVACY_POLICY_URL, IMPRINT_URL=IMPRINT_URL) | ||
| def test_admin_footer_shows_legal_links(client: Client) -> None: | ||
| """The admin footer carries the links on every page of the admin.""" | ||
| user = User.objects.create_superuser("legal-test", "legal@example.com", "password") | ||
| client.force_login(user) | ||
| content = client.get(reverse("admin:index")).content.decode() | ||
| assert PRIVACY_POLICY_URL in content | ||
| assert IMPRINT_URL in content | ||
|
|
||
|
|
||
| def test_legal_menu_links_skips_unconfigured_urls() -> None: | ||
| """A link without a URL must not end up in the user menu.""" | ||
| assert legal_menu_links("", "") == [] | ||
| links = legal_menu_links(PRIVACY_POLICY_URL, "") | ||
| assert [link["url"] for link in links] == [PRIVACY_POLICY_URL] | ||
|
|
||
|
|
||
| def test_legal_menu_links_open_in_new_window() -> None: | ||
| """Both links leave the admin, so they must not replace the current tab.""" | ||
| links = legal_menu_links(PRIVACY_POLICY_URL, IMPRINT_URL) | ||
| assert [link["url"] for link in links] == [PRIVACY_POLICY_URL, IMPRINT_URL] | ||
| assert all(link["new_window"] for link in links) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODOs: