'Return whether user is enabled or not.'

@hybrid_property
def enabled(self):

    if self._enabled:
        max_days = CONF.security_compliance.disable_user_account_days_inactive
        last_active = self.last_active_at
        if ((not last_active) and self.created_at):
            last_active = self.created_at.date()
        if (max_days and last_active):
            now = datetime.datetime.utcnow().date()
            days_inactive = (now - last_active).days
            if (days_inactive >= max_days):
                self._enabled = False
    return self._enabled
