Exemplo n.º 1
0
    def get_customers_of_user(user_name=None):

        if not user_name:
            return None

        customers = []

        try:

            if user_name == AdminUser:

                all_customers = actions.db_get_all(
                    Collection.Customers
                )

            else:

                all_customers = actions.get_customers_of_user(
                    user_name=user_name
                )

            for c in all_customers:
                try:
                    customer = Customer(
                        c[CustomerKey.CustomerName],
                        c[CustomerKey.Properties],
                    )

                    customers.append(customer)

                except Exception as e:
                    logger.error('Skipping customer `%s`' % u)
                    logger.exception(e)

        except Exception as e:

            logger.error(
                'Could not get customers of user `%s` .'
                % user_name
            )
            logger.exception(e)

        return customers
Exemplo n.º 2
0
def get_all_customers():

    customers = []
    try:

        cs = actions.db_get_all(
            collection=Collection.Customers,
        )

        for c in cs:

            customers.append(
                Customer(
                    c[CustomerKey.CustomerName],
                    c[CustomerKey.Properties]
                )
            )

    except Exception as e:

        logger.error("Unable to get all customers")
        logger.exception(e)

    return customers