def test_send_email(self):
     with self.app.app_context():
         with self.app.mail.record_messages() as outbox:
             assert len(outbox) == 0
             send_user_status_changed_email(['*****@*****.**'], 'created')
             assert len(outbox) == 1
             assert outbox[0].subject == 'Your Superdesk account is created'
 def test_send_email(self):
     with self.app.app_context():
         with self.app.mail.record_messages() as outbox:
             assert len(outbox) == 0
             send_user_status_changed_email(['*****@*****.**'], 'created')
             assert len(outbox) == 1
             assert outbox[0].subject == 'Your Superdesk account is created'
示例#3
0
 def handle_status_changed(self, updates, user):
     status = updates.get('is_active', None)
     if status is not None and status != self.user_is_active(user):
         if not status:
             # remove active tokens
             get_resource_service('auth').delete_action({'username': user.get('username')})
         # send email notification
         send_email = get_resource_service('preferences').email_notification_is_enabled(user['_id'])
         if send_email:
             send_user_status_changed_email([user['email']], status)
示例#4
0
 def handle_status_changed(self, updates, user):
     status = updates.get('is_active', None)
     if status is not None and status != self.user_is_active(user):
         if not status:
             # remove active tokens
             get_resource_service('auth').delete_action(
                 {'username': user.get('username')})
         # send email notification
         send_email = get_resource_service(
             'preferences').email_notification_is_enabled(user['_id'])
         if send_email:
             send_user_status_changed_email([user['email']], status)
示例#5
0
    def __handle_status_changed(self, updates, user):
        enabled = updates.get('is_enabled', None)
        active = updates.get('is_active', None)

        if enabled is not None or active is not None:
            get_resource_service('auth').delete_action({'username': user.get('username')})  # remove active tokens

            # send email notification
            can_send_mail = get_resource_service('preferences').email_notification_is_enabled(user_id=user['_id'])

            status = ''

            if enabled is not None:
                status = 'enabled' if enabled else 'disabled'

            if (status == '' or status == 'enabled') and active is not None:
                status = 'enabled and active' if active else 'enabled but inactive'

            if can_send_mail:
                send_user_status_changed_email([user['email']], status)
示例#6
0
    def __handle_status_changed(self, updates, user):
        enabled = updates.get('is_enabled', None)
        active = updates.get('is_active', None)

        if enabled is not None or active is not None:
            get_resource_service('auth').delete_action({'username': user.get('username')})  # remove active tokens
            updates['session_preferences'] = {}

            # send email notification
            can_send_mail = get_resource_service('preferences').email_notification_is_enabled(user_id=user['_id'])

            status = ''

            if enabled is not None:
                status = 'enabled' if enabled else 'disabled'

            if (status == '' or status == 'enabled') and active is not None:
                status = 'enabled and active' if active else 'enabled but inactive'

            if can_send_mail:
                send_user_status_changed_email([user.get('email')], status)
示例#7
0
    def __handle_status_changed(self, updates, user):
        enabled = updates.get("is_enabled", None)
        active = updates.get("is_active", None)

        if enabled is not None or active is not None:
            get_resource_service("auth").delete_action(
                {"username": user.get("username")})  # remove active tokens
            updates["session_preferences"] = {}

            # send email notification
            can_send_mail = get_resource_service(
                "preferences").email_notification_is_enabled(
                    user_id=user["_id"])

            status = ""

            if enabled is not None:
                status = "enabled" if enabled else "disabled"

            if (status == "" or status == "enabled") and active is not None:
                status = "enabled and active" if active else "enabled but inactive"

            if can_send_mail:
                send_user_status_changed_email([user.get("email")], status)