def fetch_user_orders(self, username='', email='', user_id='', filters=None): if filters and not isinstance(filters, dict): raise OrderingProviderException('filters must be dict') if username: usearch = {'username': username} elif email: usearch = {'email': email} elif user_id: usearch = {'id': user_id} user = User.where(usearch) if len(user) != 1: return list() else: user = user.pop() if filters: params = dict(filters) params.update({'user_id': user.id}) else: params = {'user_id': user.id} resp = Order.where(params) return resp
def fetch_user_orders(self, uid, filters=None): # deal with unicode uid if isinstance(uid, basestring): uid = str(uid) try: user = User.where({'username': uid}).pop() except IndexError: try: user = User.where({'email': uid}).pop() except IndexError: return {'msg': 'sorry, no user matched {0}'.format(uid)} if filters and not isinstance(filters, dict): raise OrderingProviderException('filters param must be of type dict') elif filters: params = dict(filters) params.update({'user_id': user.id}) else: params = {'user_id': user.id} return {'orders': [o.orderid for o in Order.where(params)]}
def get(version, email=None): filters = request.get_json(force=True, silent=True) search = dict(username=auth.username(), filters=filters) if email: # Allow user collaboration for usearch in ('email', 'username'): user = User.where({usearch: email}) if len(user): break if not len(user): response = MessagesResponse(warnings=["Username/email {} not found" .format(email)], code=200) return response() else: search = {'filters': filters, usearch: email} response = OrdersResponse(espa.fetch_user_orders(**search)) response.limit = ('orderid',) response.code = 200 return response()
def contact_ids_list(self): users = User.where({'id >': 0}) return [u.contactid for u in users]
def contact_ids_list(self): users = User.where({'id >': 0}) return [u.contactid for u in users]
def get(cls, *args): user = User.where({'username': '******'})[0] return (user.username, user.email, user.first_name, user.last_name, user.contactid)
def get(cls, *args): user = User.where({'username': '******'})[0] return (user.username, user.email, user.first_name, user.last_name, user.contactid)