def create_or_update(self, name=None, passes=None): # TODO: passes should be both pass slug and location name/code code = name.lower().replace(' ','-') pass_list = PassList.get_by_key_name(code) if not pass_list: pass_list = PassList(key_name=code, code=code) pass_list.name = name pass_list.passes = passes pass_list.region_code = 'san-francisco' return pass_list
def create_or_update(self, name=None, passes=None): # TODO: passes should be both pass slug and location name/code code = name.lower().replace(' ', '-') pass_list = PassList.get_by_key_name(code) if not pass_list: pass_list = PassList(key_name=code, code=code) pass_list.name = name pass_list.passes = passes pass_list.region_code = 'san-francisco' return pass_list
def get_passes(): # TODO: this should be cached! from model.passes import PassTemplate, PassList pass_dict = {'listings': [], 'tickets': [], 'coupons': []} all_lists = PassList.all().fetch(1000) for pass_list in all_lists: logging.info('getting %s passes for list %s:' % (len(pass_list.passes), pass_list.name)) if pass_list.key().name() in pass_dict.keys(): # this is only for curated chosen lists list_passes = [ p for p in PassTemplate.get_by_key_name(pass_list.passes) if p ] pass_dict[pass_list.key().name()] = list_passes for p in pass_dict[pass_list.key().name()]: logging.info(p.name) return pass_dict
def get_passes(): # TODO: this should be cached! from model.passes import PassTemplate, PassList pass_dict = { 'listings': [], 'tickets': [], 'coupons': [] } all_lists = PassList.all().fetch(1000) for pass_list in all_lists: logging.info('getting %s passes for list %s:' % (len(pass_list.passes), pass_list.name) ) if pass_list.key().name() in pass_dict.keys(): # this is only for curated chosen lists list_passes = [ p for p in PassTemplate.get_by_key_name(pass_list.passes) if p] pass_dict[pass_list.key().name()] = list_passes for p in pass_dict[pass_list.key().name()]: logging.info(p.name) return pass_dict
def find(self, query=None): if query: # todo: search pass pass_lists = PassList.all().fetch(1000) return pass_lists