Adds warnings for missing privacy policies and codes of conduct

This commit is contained in:
Mouse Reeve 2022-07-08 11:58:55 -07:00
parent 4a2e191d92
commit ba7ae46c75
4 changed files with 53 additions and 0 deletions

View file

@ -45,6 +45,22 @@
{% include 'settings/dashboard/warnings/update_version.html' with warning_level="warning" fullwidth=True %}
{% endif %}
{% if missing_privacy or missing_conduct %}
<div class="column is-12 columns m-0 p-0">
{% if missing_privacy %}
{% include 'settings/dashboard/warnings/missing_privacy.html' with warning_level="danger" %}
{% endif %}
{% if missing_conduct %}
{% include 'settings/dashboard/warnings/missing_conduct.html' with warning_level="warning" %}
{% endif %}
</div>
{% endif %}
{% if current_version %}
{% include 'settings/dashboard/warnings/update_version.html' with warning_level="warning" fullwidth=True %}
{% endif %}
{% if reports %}
{% include 'settings/dashboard/warnings/reports.html' with warning_level="warning" %}
{% endif %}

View file

@ -0,0 +1,12 @@
{% extends 'settings/dashboard/warnings/layout.html' %}
{% load i18n %}
{% block warning_link %}
{% url 'settings-site' %}#instance-info
{% endblock %}
{% block warning_text %}
{% trans "Your instance is missing a code of conduct." %}
{% endblock %}

View file

@ -0,0 +1,12 @@
{% extends 'settings/dashboard/warnings/layout.html' %}
{% load i18n %}
{% block warning_link %}
{% url 'settings-site' %}#instance-info
{% endblock %}
{% block warning_text %}
{% trans "Your instance is missing a privacy policy." %}
{% endblock %}

View file

@ -42,6 +42,19 @@ class Dashboard(View):
"email_sender"
] = f"{settings.EMAIL_SENDER_NAME}@{settings.EMAIL_SENDER_DOMAIN}"
site = models.SiteSettings.objects.get()
# other warnings
data["missing_conduct"] = (
not site.code_of_conduct
or site.code_of_conduct
== site._meta.get_field("code_of_conduct").get_default()
)
data["missing_privacy"] = (
not site.privacy_policy
or site.privacy_policy
== site._meta.get_field("privacy_policy").get_default()
)
# check version
try:
release = get_data(settings.RELEASE_API, timeout=3)