Add the NSFW filter parameter within the user settings

This commit is contained in:
Rodolphe Breard 2018-11-08 21:09:17 +01:00
parent 428bd941e2
commit 1e894853c8
11 changed files with 181 additions and 105 deletions

View file

@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 1.0\n" "Project-Id-Version: 1.0\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: 2018-02-04 01:03+0100\n"
"Last-Translator: Khaganat <assoc@khaganat.net>\n" "Last-Translator: Khaganat <assoc@khaganat.net>\n"
"Language-Team: Khaganat <assoc@khaganat.net>\n" "Language-Team: Khaganat <assoc@khaganat.net>\n"
@ -12,23 +12,23 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: forms.py:16 forms.py:41 #: forms.py:18 forms.py:54
msgid "current_password" msgid "current_password"
msgstr "Please provide your current password" msgstr "Please provide your current password"
#: forms.py:17 #: forms.py:22
msgid "new_password" msgid "new_password"
msgstr "Please set a new password" msgstr "Please set a new password"
#: forms.py:18 #: forms.py:26
msgid "new_password_confirm" msgid "new_password_confirm"
msgstr "Please confirm the new password" msgstr "Please confirm the new password"
#: forms.py:31 #: forms.py:41
msgid "The new password does not match its confirmation." msgid "The new password does not match its confirmation."
msgstr "" msgstr ""
#: forms.py:37 forms.py:52 #: forms.py:48 forms.py:67
msgid "The current password is incorrect." msgid "The current password is incorrect."
msgstr "" msgstr ""
@ -195,10 +195,35 @@ msgid "take_me_home"
msgstr "Take me home" msgstr "Take me home"
#: templates/neluser/settings/base.html:8 #: 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 #: templates/neluser/settings/security/base.html:8
msgid "security" msgid "security"
msgstr "" 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 #: templates/neluser/settings/security/delete_account.html:5
msgid "delete_account" msgid "delete_account"
msgstr "Delete account" msgstr "Delete account"
@ -211,6 +236,6 @@ msgstr ""
msgid "Password" msgid "Password"
msgstr "" msgstr ""
#: views.py:70 #: views.py:80
msgid "Your account has been deleted." msgid "Your account has been deleted."
msgstr "" msgstr ""

View file

@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 1.0\n" "Project-Id-Version: 1.0\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: 2018-02-04 01:03+0100\n"
"Last-Translator: Khaganat <assoc@khaganat.net>\n" "Last-Translator: Khaganat <assoc@khaganat.net>\n"
"Language-Team: Khaganat <assoc@khaganat.net>\n" "Language-Team: Khaganat <assoc@khaganat.net>\n"
@ -12,23 +12,23 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: forms.py:16 forms.py:41 #: forms.py:18 forms.py:54
msgid "current_password" msgid "current_password"
msgstr "Veuillez indiquer votre mot de passe actuel" msgstr "Veuillez indiquer votre mot de passe actuel"
#: forms.py:17 #: forms.py:22
msgid "new_password" msgid "new_password"
msgstr "Veuillez indiquer un nouveau mot de passe" msgstr "Veuillez indiquer un nouveau mot de passe"
#: forms.py:18 #: forms.py:26
msgid "new_password_confirm" msgid "new_password_confirm"
msgstr "Veuillez confirmer le nouveau mot de passe" msgstr "Veuillez confirmer le nouveau mot de passe"
#: forms.py:31 #: forms.py:41
msgid "The new password does not match its confirmation." msgid "The new password does not match its confirmation."
msgstr "Le nouveau mot de passe ne correspond pas avec sa 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." msgid "The current password is incorrect."
msgstr "Le mot de passe actuel est incorrect." msgstr "Le mot de passe actuel est incorrect."
@ -200,10 +200,36 @@ msgid "take_me_home"
msgstr "Retour à l'accueil" msgstr "Retour à l'accueil"
#: templates/neluser/settings/base.html:8 #: 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 #: templates/neluser/settings/security/base.html:8
msgid "security" msgid "security"
msgstr "sécurité" 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 #: templates/neluser/settings/security/delete_account.html:5
msgid "delete_account" msgid "delete_account"
msgstr "Suppression du compte" msgstr "Suppression du compte"
@ -216,43 +242,6 @@ msgstr "Définitivement supprimer mon compte"
msgid "Password" msgid "Password"
msgstr "Mot de passe" msgstr "Mot de passe"
#: views.py:70 #: views.py:80
msgid "Your account has been deleted." msgid "Your account has been deleted."
msgstr "Votre compte a été supprimé." 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"

View file

@ -5,6 +5,8 @@
{% block content %} {% block content %}
<div class="tabs"> <div class="tabs">
<ul> <ul>
<!-- {% trans "preferences" %} -->
{% include "neluser/settings/tab.html" with tabname="preferences" lnk="set_nsfw" %}
<!-- {% trans "security" %} --> <!-- {% trans "security" %} -->
{% include "neluser/settings/tab.html" with tabname="security" lnk="password_change" %} {% include "neluser/settings/tab.html" with tabname="security" lnk="password_change" %}
</ul> </ul>

View file

@ -0,0 +1,17 @@
{% extends "neluser/settings/base.html" %}
{% load i18n %}
{% block panel %}
<div class="columns">
<div class="column is-one-quarter">
<nav class="panel">
<p class="panel-heading">{% trans "preferences"|capfirst %}</p>
<!-- {% trans "nsfw_filter" %} -->
{% include "neluser/settings/block.html" with blockname="nsfw_filter" lnk="nsfw" %}
</nav>
</div>
<div class="column">
{% block inner_panel %}{% endblock %}
</div>
</div>
{% endblock %}

View file

@ -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 %}
<p>{% trans "Safe mode is disabled, you may see not safe for work content." %}</p>
<p>
<a href="{% url 'disable_nsfw' %}?next={{ current_url }}">{% trans "Enable safe mode" %}</a>.
</p>
{% else %}
<p>{% trans "Safe mode enabled, not safe for work content is hidden." %}</p>
{% include "nsfw/duration.html" with not_current="true" next_url=current_url %}
{% endif %}
{% endblock %}

View file

@ -58,6 +58,9 @@ urlpatterns = [
# -------- # --------
path('settings/', views.settings_default, name='settings'), path('settings/', views.settings_default, name='settings'),
# Preferences
path('settings/preferences/nsfw/', views.set_nsfw, name='set_nsfw'),
# Security # Security
path( path(
'settings/security/password/', 'settings/security/password/',

View file

@ -20,10 +20,21 @@ from .models import NelUser
@login_required @login_required
def settings_default(request): def settings_default(request):
next_page = reverse_lazy('password_change') next_page = reverse_lazy('set_nsfw')
return redirect(next_page) 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): class ChangePasswordView(LoginRequiredMixin, FormView):
template_name = 'neluser/settings/security/password.html' template_name = 'neluser/settings/security/password.html'
form_class = ChangePasswordForm form_class = ChangePasswordForm

View file

@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 1.0\n" "Project-Id-Version: 1.0\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: 2018-06-03 23:12+0200\n"
"Last-Translator: Khaganat <assoc@khaganat.net>\n" "Last-Translator: Khaganat <assoc@khaganat.net>\n"
"Language-Team: Khaganat <assoc@khaganat.net>\n" "Language-Team: Khaganat <assoc@khaganat.net>\n"
@ -12,38 +12,22 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\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" msgid "NSFW content"
msgstr "" msgstr ""
#: templates/nsfw/alert.html:6 #: templates/nsfw/alert.html:7
msgid "" msgid ""
"The content you were about to see is flagged as sensitive and therefore " "The content you were about to see is flagged as sensitive and therefore "
"cannot be seen while the safe mode is activated." "cannot be seen while the safe mode is activated."
msgstr "" msgstr ""
#: templates/nsfw/alert.html:9 #: templates/nsfw/alert.html:11
msgid "Go back home" msgid "Go back"
msgstr ""
#: templates/nsfw/alert.html:10
msgid "Permanently disable safe mode"
msgstr "" msgstr ""
#: templates/nsfw/alert.html:13 #: templates/nsfw/alert.html:13
msgid "Or disable safe mode for:" msgid "Go back home"
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"
msgstr "" msgstr ""
#: templates/nsfw/disabled_alert.html:2 #: templates/nsfw/disabled_alert.html:2
@ -55,3 +39,23 @@ msgstr ""
#: templates/nsfw/disabled_alert.html:3 #: templates/nsfw/disabled_alert.html:3
msgid "Enable safe mode" msgid "Enable safe mode"
msgstr "" 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 ""

View file

@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 1.0\n" "Project-Id-Version: 1.0\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: 2018-06-03 23:12+0200\n"
"Last-Translator: Khaganat <assoc@khaganat.net>\n" "Last-Translator: Khaganat <assoc@khaganat.net>\n"
"Language-Team: Khaganat <assoc@khaganat.net>\n" "Language-Team: Khaganat <assoc@khaganat.net>\n"
@ -12,11 +12,11 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\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" msgid "NSFW content"
msgstr "Contenu sensible" msgstr "Contenu sensible"
#: templates/nsfw/alert.html:6 #: templates/nsfw/alert.html:7
msgid "" msgid ""
"The content you were about to see is flagged as sensitive and therefore " "The content you were about to see is flagged as sensitive and therefore "
"cannot be seen while the safe mode is activated." "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 " "choquer la sensibilité et ne peut donc pas être affiché tant que la "
"navigation filtrée est activée." "navigation filtrée est activée."
#: templates/nsfw/alert.html:9 #: templates/nsfw/alert.html:11
msgid "Go back home" msgid "Go back"
msgstr "Retourner à l'accueil" msgstr "Retour"
#: templates/nsfw/alert.html:10
msgid "Permanently disable safe mode"
msgstr "Définitivement désactiver la navigation filtrée"
#: templates/nsfw/alert.html:13 #: templates/nsfw/alert.html:13
msgid "Or disable safe mode for:" msgid "Go back home"
msgstr "Ou désactiver la navigation filtrée pour :" msgstr "Retourner à l'accueil"
#: 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"
#: templates/nsfw/disabled_alert.html:2 #: templates/nsfw/disabled_alert.html:2
msgid "" msgid ""
@ -60,3 +44,23 @@ msgstr ""
#: templates/nsfw/disabled_alert.html:3 #: templates/nsfw/disabled_alert.html:3
msgid "Enable safe mode" msgid "Enable safe mode"
msgstr "Activer la navigation filtrée" 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"

View file

@ -12,14 +12,8 @@
{% elif go_home %} {% elif go_home %}
<a class="button is-link" href="{% url "index" %}" role="button">{% trans "Go back home" %}</a> <a class="button is-link" href="{% url "index" %}" role="button">{% trans "Go back home" %}</a>
{% endif %} {% endif %}
<a class="button is-danger" href="{% url "enable_nsfw" "0" %}?next={{ next_url }}" role="button">{% trans "Permanently disable safe mode" %}</a>
</p>
<p>
{% trans "Or disable safe mode for:" %}<br>
<a class="button is-warning" href="{% url "enable_nsfw" "300" %}?next={{ next_url }}">{% trans "5 minutes" %}</a>
<a class="button is-warning" href="{% url "enable_nsfw" "3600" %}?next={{ next_url }}">{% trans "1 hour" %}</a>
<a class="button is-warning" href="{% url "enable_nsfw" "86400" %}?next={{ next_url }}">{% trans "1 day" %}</a>
</p> </p>
{% include "nsfw/duration.html" %}
</div> </div>
</div> </div>
</article> </article>

View file

@ -0,0 +1,10 @@
{% load i18n %}
<p>
<a class="button is-danger" href="{% url "enable_nsfw" "0" %}?next={{ next_url }}" role="button">{% trans "Disable safe mode until further notice" %}</a>
</p>
<p>
{% trans "Or disable safe mode for:" %}<br>
<a class="button is-warning" href="{% url "enable_nsfw" "300" %}?next={{ next_url }}">{% trans "5 minutes" %}</a>
<a class="button is-warning" href="{% url "enable_nsfw" "3600" %}?next={{ next_url }}">{% trans "1 hour" %}</a>
<a class="button is-warning" href="{% url "enable_nsfw" "86400" %}?next={{ next_url }}">{% trans "1 day" %}</a>
</p>