From 7f1e07503afd08e8eed7fdc295668e9381fa3e89 Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Wed, 24 Jul 2019 18:45:09 +0200 Subject: [PATCH] Add user management --- neluser/admin.py | 28 ++++++++++++++++++++++++- neluser/locale/en/LC_MESSAGES/django.po | 24 +++++++++++++++++---- neluser/locale/fr/LC_MESSAGES/django.po | 24 +++++++++++++++++---- 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/neluser/admin.py b/neluser/admin.py index 8c38f3f..3096a9f 100644 --- a/neluser/admin.py +++ b/neluser/admin.py @@ -1,3 +1,29 @@ +from django.utils.translation import ugettext_lazy as _ from django.contrib import admin +from .models import NelUser +from .views import send_activation_email -# Register your models here. + +class NelUserAdmin(admin.ModelAdmin): + list_display = ('email', 'date_joined', 'last_login', 'is_active', 'is_staff', 'is_superuser') + readonly_fields = ('date_joined', 'last_login') + list_filter = ('is_active', 'is_staff', 'is_superuser') + search_fields = ('email', ) + fieldsets = [ + (_('info'), {'fields': ['is_active', 'email', 'date_joined', 'last_login']}), + (_('user_permissions'), {'fields': ['is_staff', 'is_superuser', 'groups', 'user_permissions']}), + (_('misc'), {'fields': ['nsfw_allowed']}), + ] + actions = ['resend_activation_link'] + + def save_model(self, request, obj, form, change): + super().save_model(request, obj, form, change) + send_activation_email(request, obj) + + def resend_activation_link(self, request, queryset): + for user in queryset: + if not user.is_active: + send_activation_email(request, user) + resend_activation_link.short_description = _('resend_activation_link') + +admin.site.register(NelUser, NelUserAdmin) diff --git a/neluser/locale/en/LC_MESSAGES/django.po b/neluser/locale/en/LC_MESSAGES/django.po index 09dfabd..a408cbf 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 21:03+0100\n" +"POT-Creation-Date: 2019-07-24 18:35+0200\n" "PO-Revision-Date: 2018-02-04 01:03+0100\n" "Last-Translator: Khaganat \n" "Language-Team: Khaganat \n" @@ -12,6 +12,22 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: admin.py:13 +msgid "info" +msgstr "Information" + +#: admin.py:14 +msgid "user_permissions" +msgstr "Permissions" + +#: admin.py:15 +msgid "misc" +msgstr "Misc" + +#: admin.py:27 +msgid "resend_activation_link" +msgstr "Resend activation link" + #: forms.py:18 forms.py:54 msgid "current_password" msgstr "Please provide your current password" @@ -194,12 +210,12 @@ msgstr "" msgid "take_me_home" msgstr "Take me home" -#: templates/neluser/settings/base.html:8 +#: templates/neluser/settings/base.html:9 #: templates/neluser/settings/preferences/base.html:8 msgid "preferences" msgstr "" -#: templates/neluser/settings/base.html:10 +#: templates/neluser/settings/base.html:11 #: templates/neluser/settings/security/base.html:8 msgid "security" msgstr "" @@ -236,6 +252,6 @@ msgstr "" msgid "Password" msgstr "" -#: views.py:80 +#: views.py:82 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 b3d11d1..d45a44f 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 21:03+0100\n" +"POT-Creation-Date: 2019-07-24 18:35+0200\n" "PO-Revision-Date: 2018-02-04 01:03+0100\n" "Last-Translator: Khaganat \n" "Language-Team: Khaganat \n" @@ -12,6 +12,22 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +#: admin.py:13 +msgid "info" +msgstr "Informations" + +#: admin.py:14 +msgid "user_permissions" +msgstr "Droits d'accès" + +#: admin.py:15 +msgid "misc" +msgstr "Divers" + +#: admin.py:27 +msgid "resend_activation_link" +msgstr "Ré-envoyer le lien d'activation" + #: forms.py:18 forms.py:54 msgid "current_password" msgstr "Veuillez indiquer votre mot de passe actuel" @@ -199,12 +215,12 @@ msgstr "" msgid "take_me_home" msgstr "Retour à l'accueil" -#: templates/neluser/settings/base.html:8 +#: templates/neluser/settings/base.html:9 #: templates/neluser/settings/preferences/base.html:8 msgid "preferences" msgstr "préférences" -#: templates/neluser/settings/base.html:10 +#: templates/neluser/settings/base.html:11 #: templates/neluser/settings/security/base.html:8 msgid "security" msgstr "sécurité" @@ -242,6 +258,6 @@ msgstr "Définitivement supprimer mon compte" msgid "Password" msgstr "Mot de passe" -#: views.py:80 +#: views.py:82 msgid "Your account has been deleted." msgstr "Votre compte a été supprimé."