Add user management

This commit is contained in:
Rodolphe Breard 2019-07-24 18:45:09 +02:00
parent 073dc542ff
commit 7f1e07503a
3 changed files with 67 additions and 9 deletions

View file

@ -1,3 +1,29 @@
from django.utils.translation import ugettext_lazy as _
from django.contrib import admin 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)

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 21:03+0100\n" "POT-Creation-Date: 2019-07-24 18:35+0200\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,6 +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"
#: 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 #: forms.py:18 forms.py:54
msgid "current_password" msgid "current_password"
msgstr "Please provide your current password" msgstr "Please provide your current password"
@ -194,12 +210,12 @@ msgstr ""
msgid "take_me_home" msgid "take_me_home"
msgstr "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 #: templates/neluser/settings/preferences/base.html:8
msgid "preferences" msgid "preferences"
msgstr "" msgstr ""
#: templates/neluser/settings/base.html:10 #: templates/neluser/settings/base.html:11
#: templates/neluser/settings/security/base.html:8 #: templates/neluser/settings/security/base.html:8
msgid "security" msgid "security"
msgstr "" msgstr ""
@ -236,6 +252,6 @@ msgstr ""
msgid "Password" msgid "Password"
msgstr "" msgstr ""
#: views.py:80 #: views.py:82
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 21:03+0100\n" "POT-Creation-Date: 2019-07-24 18:35+0200\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,6 +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"
#: 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 #: 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"
@ -199,12 +215,12 @@ msgstr ""
msgid "take_me_home" msgid "take_me_home"
msgstr "Retour à l'accueil" msgstr "Retour à l'accueil"
#: templates/neluser/settings/base.html:8 #: templates/neluser/settings/base.html:9
#: templates/neluser/settings/preferences/base.html:8 #: templates/neluser/settings/preferences/base.html:8
msgid "preferences" msgid "preferences"
msgstr "préférences" msgstr "préférences"
#: templates/neluser/settings/base.html:10 #: templates/neluser/settings/base.html:11
#: templates/neluser/settings/security/base.html:8 #: templates/neluser/settings/security/base.html:8
msgid "security" msgid "security"
msgstr "sécurité" msgstr "sécurité"
@ -242,6 +258,6 @@ msgstr "Définitivement supprimer mon compte"
msgid "Password" msgid "Password"
msgstr "Mot de passe" msgstr "Mot de passe"
#: views.py:80 #: views.py:82
msgid "Your account has been deleted." msgid "Your account has been deleted."
msgstr "Votre compte a été supprimé." msgstr "Votre compte a été supprimé."