2016-03-03 21:55:23 +00:00
|
|
|
from django.contrib import admin
|
2016-05-16 13:48:26 +00:00
|
|
|
from .models import CustomUser
|
2016-06-24 02:32:51 +00:00
|
|
|
from django.contrib.auth.hashers import make_password
|
2016-03-03 21:55:23 +00:00
|
|
|
|
2016-06-24 02:32:51 +00:00
|
|
|
|
|
|
|
class CustomUserAdmin(admin.ModelAdmin):
|
|
|
|
fields = ('password', 'user_permissions', 'email', 'is_admin')
|
|
|
|
|
|
|
|
def save_model(self, request, obj, form, change):
|
|
|
|
password = form.cleaned_data.get('password')
|
|
|
|
|
|
|
|
if not change:
|
|
|
|
obj.validation_slug = make_password(None)
|
|
|
|
|
|
|
|
obj.set_password(password)
|
|
|
|
obj.save()
|
|
|
|
return obj
|
|
|
|
|
|
|
|
|
|
|
|
admin.site.register(CustomUser, CustomUserAdmin)
|