From: yomguy Date: Tue, 29 Mar 2011 16:56:02 +0000 (+0200) Subject: hide some user fields for basic users X-Git-Tag: 1.1~317 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=3f8407df8464548af4b450262a2f904667844c0b;p=telemeta.git hide some user fields for basic users --- diff --git a/telemeta/locale/fr/LC_MESSAGES/django.mo b/telemeta/locale/fr/LC_MESSAGES/django.mo index f3360341..9f04b7d0 100644 Binary files a/telemeta/locale/fr/LC_MESSAGES/django.mo and b/telemeta/locale/fr/LC_MESSAGES/django.mo differ diff --git a/telemeta/locale/fr/LC_MESSAGES/django.po b/telemeta/locale/fr/LC_MESSAGES/django.po index 1766ebc5..fe0827ca 100644 --- a/telemeta/locale/fr/LC_MESSAGES/django.po +++ b/telemeta/locale/fr/LC_MESSAGES/django.po @@ -836,3 +836,47 @@ msgstr "Énumérations" #: web.base.py:955 msgid "Access not allowed" msgstr "Accès non autorisé" + +#: templates/telemeta_default/profile_detail.html:11 +msgid "User profile" +msgstr "Profil utilisateur" + +#: templates/telemeta_default/profile_detail.html:12 +msgid "Institution" +msgstr "Institution" + +#: templates/telemeta_default/profile_detail.html:13 +msgid "Function" +msgstr "Fonction" + +#: templates/telemeta_default/profile_detail.html:14 +msgid "Address" +msgstr "Adresse" + +#: templates/telemeta_default/profile_detail.html:15 +msgid "Telephone" +msgstr "Téléphone" + +#: templates/telemeta_default/profile_detail.html:16 +msgid "Last Name" +msgstr "Nom" + +#: templates/telemeta_default/profile_detail.html:17 +msgid "First Name" +msgstr "Prénom" + +#: templates/telemeta_default/profile_detail.html:18 +msgid "Expiration date" +msgstr "Date d'expiration" + +#: templates/telemeta_default/profile_detail.html:19 +msgid "Is admin" +msgstr "Est admin" + +#: templates/telemeta_default/profile_detail.html:20 +msgid "Is superuser" +msgstr "Est superuser" + +#: templates/telemeta_default/profile_detail.html:21 +msgid "Last login" +msgstr "Dernière connexion" diff --git a/telemeta/models/system.py b/telemeta/models/system.py index 1d5beaa1..5452c9e6 100644 --- a/telemeta/models/system.py +++ b/telemeta/models/system.py @@ -79,7 +79,7 @@ class UserProfile(django.db.models.Model): institution = CharField(_('institution')) function = CharField(_('function')) address = TextField(_('address')) - telephone = CharField(_('function')) + telephone = CharField(_('telephone')) expiration_date = DateField(_('expiration_date')) class Meta(MetaCore): diff --git a/telemeta/templates/telemeta_default/profile_edit.html b/telemeta/templates/telemeta_default/profile_edit.html index 5e92b5f1..d94e0f54 100644 --- a/telemeta/templates/telemeta_default/profile_edit.html +++ b/telemeta/templates/telemeta_default/profile_edit.html @@ -12,27 +12,20 @@
{% csrf_token %} - - {% for field in user_form %} - - - - - {% endfor %} - - - {% for field in profile_form %} - {% if field.html_name != "user" %} + {% for form in forms %} + {% for field in form %} + {% if not field.html_name in hidden_fields %} - + {% else %} - - + + {% endif %} {% endfor %} + {% endfor %}
{{ field.errors }}
{{ field.label_tag }}: {{ field }}
{{ field.errors }}
{{ field.label_tag }}: {{ field }}{% trans field.label_tag %}:{{ field }}
{{ field.label_tag }}: {{ field }}
{{ field.label_tag.as_hidden }}{{ field.as_hidden }}
{% trans "Cancel" %} diff --git a/telemeta/web/base.py b/telemeta/web/base.py index 5738d4a3..25bd6533 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -1023,6 +1023,13 @@ class WebView(object): return render(request, template, {'profile' : profile, 'usr': user}) def profile_edit(self, request, username, template='telemeta/profile_edit.html'): + if request.user.is_staff: + user_hidden_fields = [] + else: + user_hidden_fields = ['user-username', 'user-is_staff', 'profile-user', 'user-is_active', + 'user-password', 'user-last_login', 'user-date_joined', 'user-groups', + 'user-user_permissions', 'user-is_superuser', 'profile-expiration_date'] + user = User.objects.get(username=username) if user != request.user and not request.user.is_staff: return HttpResponseRedirect('/accounts/'+username+'/not_allowed/') @@ -1043,5 +1050,6 @@ class WebView(object): else: user_form = UserChangeForm(instance=user, prefix='user') profile_form = UserProfileForm(instance=profile, prefix='profile') - return render(request, template, {"user_form": user_form, "profile_form": profile_form, 'usr': user}) + forms = [user_form, profile_form] + return render(request, template, {'forms': forms, 'usr': user, 'hidden_fields': user_hidden_fields})