def create( meal, user, val ): """ Constructor for Vote class. Input: meal & user should be Obj refs & value should be an int Output: returns the new Vote obj. """ uuid = generate_uuid( 10 ) # Error check the val. it must be in range [1, 10] if val < 1: val = 1 elif val > 10: val = 10 # Only 1 Vote per {user, meal} allowed! if Vote.get_by_user_and_meal( user, meal ) is None: vote = Vote( key_name = uuid, uuid = uuid, meal = meal, user = user, value = val ) vote.put() return vote return None
def create( ): """ Constructor for Stats class. Input: Output: returns the new Stats obj. """ uuid = generate_uuid( 10 ) stats = Stats( key_name = uuid, uuid = uuid, ) stats.put() return stats
def create( url_, token ): url_ = get_shopify_url( url_ ) logging.info('url :%s ' % url_) uuid = generate_uuid( 16 ) store = ShopifyStore( key_name = uuid, uuid = uuid, url = url_, token = token ) store.fetch_store_info( ) return store
def create( type, menu ): """ Constructor for Meal class. Input: Output: returns the new Meal obj. """ uuid = generate_uuid( 10 ) meal = Meal( key_name = uuid, uuid = uuid, type = type, menu = menu, items = menu.split(' ') ) meal.put() return meal
def create( meal, user ): """ Constructor for Checkin class. Input: meal & user should be Obj refs Output: returns the new Checkin obj. """ uuid = generate_uuid( 10 ) # Only 1 Checkin per {user, meal} allowed! if Checkin.get_by_user_and_meal( user, meal ) is None: checkin = Checkin( key_name = uuid, uuid = uuid, meal = meal, user = user ) checkin.put() return checkin return None
def create( first_name, last_name, email ): """ Constructor for User class. Input: name & img should both be strings. Output: returns the new User obj. """ uuid = generate_uuid( 10 ) # Santization lite lol first_name = first_name.strip() last_name = last_name.strip() email = email.strip() user = User( key_name = "%s%s_%s" % (first_name, last_name, uuid), uuid = uuid, first_name = first_name, last_name = last_name, email = email, notification = (email is not "") ) user.put() return user
def __init__(self, *args, **kwargs): """ Initialize this model """ self._memcache_key = generate_uuid(16) super(Feedback, self).__init__(*args, **kwargs)