widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #14954
[Merge] lp:~widelands-dev/widelands-website/privacy_policy into lp:widelands-website
kaputtnik has proposed merging lp:~widelands-dev/widelands-website/privacy_policy into lp:widelands-website.
Commit message:
Add app for Privacy policies
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1780536 in Widelands Website: "Add a GDPR (german: DSGVO) to the website"
https://bugs.launchpad.net/widelands-website/+bug/1780536
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands-website/privacy_policy/+merge/356282
This branch adds a Database entry for storing privacy policies. This makes it possible to have policies for different languages.
Each language will be shown in its own page, rendered through markdown. If more than one language is available there will be a sentence shown on op of the site, saying: "This site is also available in: language1, language2 and language3".
Calling the url /privacy will try to load 'english' at first time. If this isn't available, the first entry stored in the Database is shown. If no privacy can be found the String "No policy created yet!" is shown.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/privacy_policy into lp:widelands-website.
=== added directory 'privacy_policy'
=== added file 'privacy_policy/__init__.py'
=== added file 'privacy_policy/admin.py'
--- privacy_policy/admin.py 1970-01-01 00:00:00 +0000
+++ privacy_policy/admin.py 2018-10-08 18:04:16 +0000
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.contrib import admin
+from privacy_policy.models import PrivacyPolicy
+
+
+class PrivacyPolicyAdmin(admin.ModelAdmin):
+ prepopulated_fields = {"slug": ("language",)}
+ list_display = ('language',)
+
+
+admin.site.register(PrivacyPolicy, PrivacyPolicyAdmin)
=== added file 'privacy_policy/apps.py'
--- privacy_policy/apps.py 1970-01-01 00:00:00 +0000
+++ privacy_policy/apps.py 2018-10-08 18:04:16 +0000
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.apps import AppConfig
+
+
+class PrivacyPolicyConfig(AppConfig):
+ name = 'privacy_policy'
=== added directory 'privacy_policy/migrations'
=== added file 'privacy_policy/migrations/0001_initial.py'
--- privacy_policy/migrations/0001_initial.py 1970-01-01 00:00:00 +0000
+++ privacy_policy/migrations/0001_initial.py 2018-10-08 18:04:16 +0000
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.12 on 2018-10-08 18:23
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='PrivacyPolicy',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('language', models.CharField(default='English', help_text='Will be displayed as a level 1 header', max_length=30, unique=True)),
+ ('policy_text', models.TextField(help_text='Text will be rendered using markdown syntax')),
+ ('slug', models.SlugField(unique=True)),
+ ],
+ options={
+ 'ordering': ['language'],
+ },
+ ),
+ ]
=== added file 'privacy_policy/migrations/__init__.py'
=== added file 'privacy_policy/models.py'
--- privacy_policy/models.py 1970-01-01 00:00:00 +0000
+++ privacy_policy/models.py 2018-10-08 18:04:16 +0000
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models
+from django.urls import reverse
+
+
+class PrivacyPolicy(models.Model):
+
+ language = models.CharField(default='English', max_length=30,
+ help_text='Will be displayed as a level 1 header',
+ unique=True)
+ policy_text = models.TextField(
+ help_text='Text will be rendered using markdown syntax')
+ slug = models.SlugField(unique=True)
+
+ class Meta:
+ ordering = ['language']
+
+ def __unicode__(self):
+ return self.language
+
+ def get_absolute_url(self):
+ return reverse('policy_translated', kwargs={'lang': self.language})
\ No newline at end of file
=== added file 'privacy_policy/urls.py'
--- privacy_policy/urls.py 1970-01-01 00:00:00 +0000
+++ privacy_policy/urls.py 2018-10-08 18:04:16 +0000
@@ -0,0 +1,7 @@
+from django.conf.urls import *
+from privacy_policy import views
+
+urlpatterns = [
+ url(r'^$', views.privacy_policy, name='privacy_policy'),
+ url(r'^(?P<slug>[-\w]+)/', views.privacy_policy, name='policy_translated'),
+]
=== added file 'privacy_policy/views.py'
--- privacy_policy/views.py 1970-01-01 00:00:00 +0000
+++ privacy_policy/views.py 2018-10-08 18:04:16 +0000
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.shortcuts import render
+from django.core.exceptions import ObjectDoesNotExist
+
+from privacy_policy.models import PrivacyPolicy
+
+
+def _format_text(language, text):
+ return '[TOC]\n\n#{}\n{}'.format(language, text)
+
+
+def privacy_policy(request, *args, **kwargs):
+ """Creates the text of a policy and prepare it for markdown.
+
+ We handle here also a link with no slug (/privacy). In this case try
+ to load english, else load the first entry in the DB.
+ """
+
+ # Default is 'english'
+ slug = kwargs.pop('slug', 'english')
+ policies = PrivacyPolicy.objects.all()
+
+ if policies.count():
+ try:
+ policy = policies.get(slug=slug)
+ except ObjectDoesNotExist:
+ policy = policies.all()[0]
+ slug = policy.slug
+
+ text = _format_text(policy.language, policy.policy_text)
+ languages = [(x.language, x.slug) for x in policies.exclude(slug=slug)]
+ current_lang = policy.language
+ else:
+ text = 'No Policy created yet!'
+ languages = ''
+ current_lang = ''
+
+ context = {
+ 'text': text,
+ 'languages': languages,
+ 'cur_lang': current_lang,
+ }
+ return render(request, 'privacy_policy.html', context)
=== modified file 'settings.py'
--- settings.py 2018-10-01 16:41:29 +0000
+++ settings.py 2018-10-08 18:04:16 +0000
@@ -95,6 +95,7 @@
'wlscheduling',
'check_input.apps.CheckInput',
'documentation',
+ 'privacy_policy.apps.PrivacyPolicyConfig',
'haystack', # search engine; see option HAYSTACK_CONNECTIONS
# Modified 3rd party apps
=== modified file 'templates/footer.html'
--- templates/footer.html 2018-02-11 14:48:26 +0000
+++ templates/footer.html 2018-10-08 18:04:16 +0000
@@ -9,4 +9,6 @@
<div id="footer">
Copyright © 2009 - {% current_year %} By the Widelands Development Team<br />
<a class="small" href="{% url 'legal_notice' %}">Legal notice (contact)</a>
+ <span class="small"> ● </span>
+ <a class="small" href="{% url 'privacy_policy'%}">Privacy Policy</a>
</div>
=== added file 'templates/privacy_policy.html'
--- templates/privacy_policy.html 1970-01-01 00:00:00 +0000
+++ templates/privacy_policy.html 2018-10-08 18:04:16 +0000
@@ -0,0 +1,30 @@
+{% extends "base.html" %}
+{% load wl_markdown %}
+
+{% block title %}Privacy policy {{ cur_lang }} {{ block.super }}{% endblock %}
+
+{% block extra_head %}
+{{ block.super}}
+<link rel="stylesheet" type="text/css" media="all" href="{{ MEDIA_URL }}css/wiki.css" />
+{% endblock %}
+
+{% block content %}
+<h1>Privacy Policy</h1>
+
+<div class="blogEntry">
+ {% with languages|length as count %}
+ {% if count > 0 %}
+ <p>
+ This site is also available in:
+ {% for lang, slug in languages %}
+ {# The if statement has to be directly after the link, otherwise we have unwanted spaces #}
+ <a href="{% url 'policy_translated' slug %}">{{ lang }}</a>{% if count > 1 and forloop.revcounter0 == 1 %} and
+ {% elif count > 1 and forloop.revcounter0 != 0 %}, {% endif %}
+ {% endfor %}
+ </p>
+ {% endif %}
+ {% endwith %}
+
+ {{ text|wl_markdown }}
+</div>
+{% endblock %}
=== modified file 'urls.py'
--- urls.py 2018-09-12 07:45:35 +0000
+++ urls.py 2018-10-08 18:04:16 +0000
@@ -58,6 +58,7 @@
url(r'^ggz/', include('wlggz.urls')),
url(r'^moderated/', include('check_input.urls')),
url(r'^scheduling/', include('wlscheduling.urls')),
+ url(r'privacy/', include('privacy_policy.urls')),
]
try:
Follow ups