From 1e894853c8a6ea1c59529225a59994ca8021d866 Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Thu, 8 Nov 2018 21:09:17 +0100 Subject: [PATCH] Add the NSFW filter parameter within the user settings --- neluser/locale/en/LC_MESSAGES/django.po | 39 ++++++++-- neluser/locale/fr/LC_MESSAGES/django.po | 77 ++++++++----------- neluser/templates/neluser/settings/base.html | 2 + .../neluser/settings/preferences/base.html | 17 ++++ .../neluser/settings/preferences/nsfw.html | 17 ++++ neluser/urls.py | 3 + neluser/views.py | 13 +++- nsfw/locale/en/LC_MESSAGES/django.po | 48 ++++++------ nsfw/locale/fr/LC_MESSAGES/django.po | 52 +++++++------ nsfw/templates/nsfw/alert.html | 8 +- nsfw/templates/nsfw/duration.html | 10 +++ 11 files changed, 181 insertions(+), 105 deletions(-) create mode 100644 neluser/templates/neluser/settings/preferences/base.html create mode 100644 neluser/templates/neluser/settings/preferences/nsfw.html create mode 100644 nsfw/templates/nsfw/duration.html diff --git a/neluser/locale/en/LC_MESSAGES/django.po b/neluser/locale/en/LC_MESSAGES/django.po index c578295..09dfabd 100644 --- a/neluser/locale/en/LC_MESSAGES/django.po +++ b/neluser/locale/en/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-11-08 15:03+0100\n" +"POT-Creation-Date: 2018-11-08 21:03+0100\n" "PO-Revision-Date: 2018-02-04 01:03+0100\n" "Last-Translator: Khaganat \n" "Language-Team: Khaganat \n" @@ -12,23 +12,23 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: forms.py:16 forms.py:41 +#: forms.py:18 forms.py:54 msgid "current_password" msgstr "Please provide your current password" -#: forms.py:17 +#: forms.py:22 msgid "new_password" msgstr "Please set a new password" -#: forms.py:18 +#: forms.py:26 msgid "new_password_confirm" msgstr "Please confirm the new password" -#: forms.py:31 +#: forms.py:41 msgid "The new password does not match its confirmation." msgstr "" -#: forms.py:37 forms.py:52 +#: forms.py:48 forms.py:67 msgid "The current password is incorrect." msgstr "" @@ -195,10 +195,35 @@ msgid "take_me_home" msgstr "Take me home" #: templates/neluser/settings/base.html:8 +#: templates/neluser/settings/preferences/base.html:8 +msgid "preferences" +msgstr "" + +#: templates/neluser/settings/base.html:10 #: templates/neluser/settings/security/base.html:8 msgid "security" msgstr "" +#: templates/neluser/settings/preferences/base.html:9 +msgid "nsfw_filter" +msgstr "NSFW filter" + +#: templates/neluser/settings/preferences/nsfw.html:5 +msgid "NSFW content" +msgstr "" + +#: templates/neluser/settings/preferences/nsfw.html:9 +msgid "Safe mode is disabled, you may see not safe for work content." +msgstr "" + +#: templates/neluser/settings/preferences/nsfw.html:11 +msgid "Enable safe mode" +msgstr "" + +#: templates/neluser/settings/preferences/nsfw.html:14 +msgid "Safe mode enabled, not safe for work content is hidden." +msgstr "" + #: templates/neluser/settings/security/delete_account.html:5 msgid "delete_account" msgstr "Delete account" @@ -211,6 +236,6 @@ msgstr "" msgid "Password" msgstr "" -#: views.py:70 +#: views.py:80 msgid "Your account has been deleted." msgstr "" diff --git a/neluser/locale/fr/LC_MESSAGES/django.po b/neluser/locale/fr/LC_MESSAGES/django.po index ba08856..b3d11d1 100644 --- a/neluser/locale/fr/LC_MESSAGES/django.po +++ b/neluser/locale/fr/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-11-08 15:03+0100\n" +"POT-Creation-Date: 2018-11-08 21:03+0100\n" "PO-Revision-Date: 2018-02-04 01:03+0100\n" "Last-Translator: Khaganat \n" "Language-Team: Khaganat \n" @@ -12,23 +12,23 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: forms.py:16 forms.py:41 +#: forms.py:18 forms.py:54 msgid "current_password" msgstr "Veuillez indiquer votre mot de passe actuel" -#: forms.py:17 +#: forms.py:22 msgid "new_password" msgstr "Veuillez indiquer un nouveau mot de passe" -#: forms.py:18 +#: forms.py:26 msgid "new_password_confirm" msgstr "Veuillez confirmer le nouveau mot de passe" -#: forms.py:31 +#: forms.py:41 msgid "The new password does not match its confirmation." msgstr "Le nouveau mot de passe ne correspond pas avec sa confirmation." -#: forms.py:37 forms.py:52 +#: forms.py:48 forms.py:67 msgid "The current password is incorrect." msgstr "Le mot de passe actuel est incorrect." @@ -200,10 +200,36 @@ msgid "take_me_home" msgstr "Retour à l'accueil" #: templates/neluser/settings/base.html:8 +#: templates/neluser/settings/preferences/base.html:8 +msgid "preferences" +msgstr "préférences" + +#: templates/neluser/settings/base.html:10 #: templates/neluser/settings/security/base.html:8 msgid "security" msgstr "sécurité" +#: templates/neluser/settings/preferences/base.html:9 +msgid "nsfw_filter" +msgstr "Navigation filtrée" + +#: templates/neluser/settings/preferences/nsfw.html:5 +msgid "NSFW content" +msgstr "Contenu sensible" + +#: templates/neluser/settings/preferences/nsfw.html:9 +msgid "Safe mode is disabled, you may see not safe for work content." +msgstr "" +"La navigation filtrée est désactivée, vous pouvez voir le contenu sensible." + +#: templates/neluser/settings/preferences/nsfw.html:11 +msgid "Enable safe mode" +msgstr "Activer la navigation filtrée" + +#: templates/neluser/settings/preferences/nsfw.html:14 +msgid "Safe mode enabled, not safe for work content is hidden." +msgstr "La navigation filtrée est activée, le contenu sensible est masqué." + #: templates/neluser/settings/security/delete_account.html:5 msgid "delete_account" msgstr "Suppression du compte" @@ -216,43 +242,6 @@ msgstr "Définitivement supprimer mon compte" msgid "Password" msgstr "Mot de passe" -#: views.py:70 +#: views.py:80 msgid "Your account has been deleted." msgstr "Votre compte a été supprimé." - -#~ msgid "NSFW content" -#~ msgstr "Contenu sensible" - -#~ msgid "" -#~ "The content you were about to see is flagged as sensitive and therefore " -#~ "cannot be seen while the safe mode is activated." -#~ msgstr "" -#~ "Le contenu que vous vous apprêtiez à consulter est indiqué comme pouvant " -#~ "choquer la sensibilité et ne peut donc pas être affiché tant que la " -#~ "navigation filtrée est activée." - -#~ msgid "Permanently disable safe mode" -#~ msgstr "Définitivement désactiver la navigation filtrée" - -#~ msgid "Or disable safe mode for:" -#~ msgstr "Ou désactiver la navigation filtrée pour :" - -#~ msgid "5 minutes" -#~ msgstr "5 minutes" - -#~ msgid "1 hour" -#~ msgstr "1 heure" - -#~ msgid "1 day" -#~ msgstr "1 jour" - -#~ msgid "" -#~ "This page contains sensitive content which is displayed because you " -#~ "disabled the safe mode." -#~ msgstr "" -#~ "Cette page contient du contenu indiqué comme pouvant heurter la " -#~ "sensibilité. Ce contenu est affiché car vous avez désactivé la navigation " -#~ "filtrée." - -#~ msgid "Enable safe mode" -#~ msgstr "Activer la navigation filtrée" diff --git a/neluser/templates/neluser/settings/base.html b/neluser/templates/neluser/settings/base.html index 3d6e241..166ce93 100644 --- a/neluser/templates/neluser/settings/base.html +++ b/neluser/templates/neluser/settings/base.html @@ -5,6 +5,8 @@ {% block content %}
    + + {% include "neluser/settings/tab.html" with tabname="preferences" lnk="set_nsfw" %} {% include "neluser/settings/tab.html" with tabname="security" lnk="password_change" %}
diff --git a/neluser/templates/neluser/settings/preferences/base.html b/neluser/templates/neluser/settings/preferences/base.html new file mode 100644 index 0000000..3cd971f --- /dev/null +++ b/neluser/templates/neluser/settings/preferences/base.html @@ -0,0 +1,17 @@ +{% extends "neluser/settings/base.html" %} +{% load i18n %} + +{% block panel %} +
+
+ +
+
+ {% block inner_panel %}{% endblock %} +
+
+{% endblock %} diff --git a/neluser/templates/neluser/settings/preferences/nsfw.html b/neluser/templates/neluser/settings/preferences/nsfw.html new file mode 100644 index 0000000..3491056 --- /dev/null +++ b/neluser/templates/neluser/settings/preferences/nsfw.html @@ -0,0 +1,17 @@ +{% extends "neluser/settings/preferences/base.html" %} +{% load bulma_tags %} +{% load i18n %} + +{% block title %}{% trans "NSFW content" %}{% endblock %} + +{% block inner_panel %} +{% if nsfw_allowed %} +

{% trans "Safe mode is disabled, you may see not safe for work content." %}

+

+ {% trans "Enable safe mode" %}. +

+{% else %} +

{% trans "Safe mode enabled, not safe for work content is hidden." %}

+{% include "nsfw/duration.html" with not_current="true" next_url=current_url %} +{% endif %} +{% endblock %} diff --git a/neluser/urls.py b/neluser/urls.py index 3e1899c..dfddd0b 100644 --- a/neluser/urls.py +++ b/neluser/urls.py @@ -58,6 +58,9 @@ urlpatterns = [ # -------- path('settings/', views.settings_default, name='settings'), + # Preferences + path('settings/preferences/nsfw/', views.set_nsfw, name='set_nsfw'), + # Security path( 'settings/security/password/', diff --git a/neluser/views.py b/neluser/views.py index 1215b02..e67f324 100644 --- a/neluser/views.py +++ b/neluser/views.py @@ -20,10 +20,21 @@ from .models import NelUser @login_required def settings_default(request): - next_page = reverse_lazy('password_change') + next_page = reverse_lazy('set_nsfw') return redirect(next_page) +@login_required +def set_nsfw(request): + ctx = { + 'nsfw_allowed': request.user.nsfw_allowed, + 'current_url': reverse_lazy('set_nsfw'), + 'tab': 'preferences', + 'active_block': 'nsfw_filter' + } + return render(request, 'neluser/settings/preferences/nsfw.html', ctx) + + class ChangePasswordView(LoginRequiredMixin, FormView): template_name = 'neluser/settings/security/password.html' form_class = ChangePasswordForm diff --git a/nsfw/locale/en/LC_MESSAGES/django.po b/nsfw/locale/en/LC_MESSAGES/django.po index 427b789..0dd5bb1 100644 --- a/nsfw/locale/en/LC_MESSAGES/django.po +++ b/nsfw/locale/en/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-06-03 23:12+0200\n" +"POT-Creation-Date: 2018-11-08 21:03+0100\n" "PO-Revision-Date: 2018-06-03 23:12+0200\n" "Last-Translator: Khaganat \n" "Language-Team: Khaganat \n" @@ -12,38 +12,22 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: templates/nsfw/alert.html:3 templates/nsfw/redirect_page.html:4 +#: templates/nsfw/alert.html:4 templates/nsfw/redirect_page.html:4 msgid "NSFW content" msgstr "" -#: templates/nsfw/alert.html:6 +#: templates/nsfw/alert.html:7 msgid "" "The content you were about to see is flagged as sensitive and therefore " "cannot be seen while the safe mode is activated." msgstr "" -#: templates/nsfw/alert.html:9 -msgid "Go back home" -msgstr "" - -#: templates/nsfw/alert.html:10 -msgid "Permanently disable safe mode" +#: templates/nsfw/alert.html:11 +msgid "Go back" msgstr "" #: templates/nsfw/alert.html:13 -msgid "Or disable safe mode for:" -msgstr "" - -#: templates/nsfw/alert.html:14 -msgid "5 minutes" -msgstr "" - -#: templates/nsfw/alert.html:15 -msgid "1 hour" -msgstr "" - -#: templates/nsfw/alert.html:16 -msgid "1 day" +msgid "Go back home" msgstr "" #: templates/nsfw/disabled_alert.html:2 @@ -55,3 +39,23 @@ msgstr "" #: templates/nsfw/disabled_alert.html:3 msgid "Enable safe mode" msgstr "" + +#: templates/nsfw/duration.html:3 +msgid "Disable safe mode until further notice" +msgstr "" + +#: templates/nsfw/duration.html:6 +msgid "Or disable safe mode for:" +msgstr "" + +#: templates/nsfw/duration.html:7 +msgid "5 minutes" +msgstr "" + +#: templates/nsfw/duration.html:8 +msgid "1 hour" +msgstr "" + +#: templates/nsfw/duration.html:9 +msgid "1 day" +msgstr "" diff --git a/nsfw/locale/fr/LC_MESSAGES/django.po b/nsfw/locale/fr/LC_MESSAGES/django.po index 2a71ac2..678c3a4 100644 --- a/nsfw/locale/fr/LC_MESSAGES/django.po +++ b/nsfw/locale/fr/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-06-03 23:12+0200\n" +"POT-Creation-Date: 2018-11-08 21:03+0100\n" "PO-Revision-Date: 2018-06-03 23:12+0200\n" "Last-Translator: Khaganat \n" "Language-Team: Khaganat \n" @@ -12,11 +12,11 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: templates/nsfw/alert.html:3 templates/nsfw/redirect_page.html:4 +#: templates/nsfw/alert.html:4 templates/nsfw/redirect_page.html:4 msgid "NSFW content" msgstr "Contenu sensible" -#: templates/nsfw/alert.html:6 +#: templates/nsfw/alert.html:7 msgid "" "The content you were about to see is flagged as sensitive and therefore " "cannot be seen while the safe mode is activated." @@ -25,29 +25,13 @@ msgstr "" "choquer la sensibilité et ne peut donc pas être affiché tant que la " "navigation filtrée est activée." -#: templates/nsfw/alert.html:9 -msgid "Go back home" -msgstr "Retourner à l'accueil" - -#: templates/nsfw/alert.html:10 -msgid "Permanently disable safe mode" -msgstr "Définitivement désactiver la navigation filtrée" +#: templates/nsfw/alert.html:11 +msgid "Go back" +msgstr "Retour" #: templates/nsfw/alert.html:13 -msgid "Or disable safe mode for:" -msgstr "Ou désactiver la navigation filtrée pour :" - -#: templates/nsfw/alert.html:14 -msgid "5 minutes" -msgstr "5 minutes" - -#: templates/nsfw/alert.html:15 -msgid "1 hour" -msgstr "1 heure" - -#: templates/nsfw/alert.html:16 -msgid "1 day" -msgstr "1 jour" +msgid "Go back home" +msgstr "Retourner à l'accueil" #: templates/nsfw/disabled_alert.html:2 msgid "" @@ -60,3 +44,23 @@ msgstr "" #: templates/nsfw/disabled_alert.html:3 msgid "Enable safe mode" msgstr "Activer la navigation filtrée" + +#: templates/nsfw/duration.html:3 +msgid "Disable safe mode until further notice" +msgstr "Désactiver la navigation filtrée jusqu'à nouvel ordre" + +#: templates/nsfw/duration.html:6 +msgid "Or disable safe mode for:" +msgstr "Ou désactiver la navigation filtrée pour :" + +#: templates/nsfw/duration.html:7 +msgid "5 minutes" +msgstr "5 minutes" + +#: templates/nsfw/duration.html:8 +msgid "1 hour" +msgstr "1 heure" + +#: templates/nsfw/duration.html:9 +msgid "1 day" +msgstr "1 jour" diff --git a/nsfw/templates/nsfw/alert.html b/nsfw/templates/nsfw/alert.html index 109f507..50fe004 100644 --- a/nsfw/templates/nsfw/alert.html +++ b/nsfw/templates/nsfw/alert.html @@ -12,14 +12,8 @@ {% elif go_home %} {% trans "Go back home" %} {% endif %} - {% trans "Permanently disable safe mode" %} -

-

- {% trans "Or disable safe mode for:" %}
- {% trans "5 minutes" %} - {% trans "1 hour" %} - {% trans "1 day" %}

+ {% include "nsfw/duration.html" %}
diff --git a/nsfw/templates/nsfw/duration.html b/nsfw/templates/nsfw/duration.html new file mode 100644 index 0000000..8d94a84 --- /dev/null +++ b/nsfw/templates/nsfw/duration.html @@ -0,0 +1,10 @@ +{% load i18n %} +

+ {% trans "Disable safe mode until further notice" %} +

+

+ {% trans "Or disable safe mode for:" %}
+ {% trans "5 minutes" %} + {% trans "1 hour" %} + {% trans "1 day" %} +