fix password change by admin
This commit is contained in:
parent
5c7c494908
commit
15091803d6
2 changed files with 19 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth import admin as auth_admin
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from forum.models import Category, Forum, Topic, Post, Profile, Reputation,\
|
||||
Report, Ban
|
||||
|
@ -37,7 +39,17 @@ class BanAdmin(admin.ModelAdmin):
|
|||
list_display = ['user', 'ban_start', 'ban_end', 'reason']
|
||||
raw_id_fields = ['user']
|
||||
|
||||
class UserAdmin(auth_admin.UserAdmin):
|
||||
def get_urls(self):
|
||||
from django.conf.urls.defaults import patterns, url
|
||||
return patterns('',
|
||||
url(r'^(\d+)/password/$', self.admin_site.admin_view(self.user_change_password), name='user_change_password'),
|
||||
) + super(auth_admin.UserAdmin, self).get_urls()
|
||||
|
||||
|
||||
admin.site.unregister(User)
|
||||
|
||||
admin.site.register(User, UserAdmin)
|
||||
admin.site.register(Category, CategoryAdmin)
|
||||
admin.site.register(Forum, ForumAdmin)
|
||||
admin.site.register(Topic, TopicAdmin)
|
||||
|
|
|
@ -21,7 +21,13 @@
|
|||
{{ form.fields.username.initial }}
|
||||
{% endif %}
|
||||
<br></label>
|
||||
<p><a href="{% url auth_password_change %}">{% trans "Change password" %}</a></p>
|
||||
<p>
|
||||
{% if request.user.is_superuser %}
|
||||
<a href="{% url admin:user_change_password profile.id %}">{% trans "Change password" %}</a>
|
||||
{% else %}
|
||||
<a href="{% url auth_password_change %}">{% trans "Change password" %}</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
|
|
Reference in a new issue