dynamicweb/membership/admin.py

22 lines
591 B
Python
Raw Permalink Normal View History

2016-03-03 21:55:23 +00:00
from django.contrib import admin
2016-12-13 15:54:05 +00:00
from .models import CustomUser, StripeCustomer
from django.contrib.auth.hashers import make_password
2016-03-03 21:55:23 +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)
2016-12-13 15:54:05 +00:00
admin.site.register(StripeCustomer)