Files
mayan-edms/mayan/apps/autoadmin/handlers.py
Roberto Rosario 8039dfa30a Autoadmin: Incorporate the autoadmin app
Incorporate the external django-autoadmin app as a core app
and convert it into a Mayan app. This change adds the new
settings: "COMMON_AUTOADMIN_EMAIL", "AUTOADMIN_PASSWORD", and
"AUTOADMIN_USERNAME".

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
2018-12-07 03:09:59 -04:00

21 lines
732 B
Python

from __future__ import unicode_literals
from django.apps import apps
def handler_auto_admin_account_password_change(sender, instance, **kwargs):
AutoAdminSingleton = apps.get_model(
app_label='autoadmin', model_name='AutoAdminSingleton'
)
auto_admin_properties, created = AutoAdminSingleton.objects.get_or_create()
if instance == auto_admin_properties.account and \
instance.password != auto_admin_properties.password_hash:
# Only delete the auto admin properties when the password
# has been changed
auto_admin_properties.account = None
auto_admin_properties.password = None
auto_admin_properties.password_hash = None
auto_admin_properties.save()