def put(city_id): arg_spec = { 'date_from': Arg(str, required=True), 'date_end': Arg(str, required=True), } args = args_parser.parse(arg_spec) return trs_query_cfg_service.add_or_update(city_id, strptime_to_date(args['date_from']), strptime_to_date(args['date_end']))
def gets(cls): args_spec = { 'city_id': Arg(int, allow_missing=True), 'name': Arg(str, allow_missing=True), 'is_valid': Arg(bool, allow_missing=True), 'is_expire': Arg(int, allow_missing=True), } args = args_parser.parse(args_spec) is_expire=args.pop('is_expire',2) city_id = args.pop('city_id', None) if city_id: args['regions'] = {city_id: {}} banners, total_num = banner_client.query(args) newbanners=[] if is_expire!=2: today=datetime.date.today() for banner in banners: end_date=strptime_to_date(banner.end_date) if end_date=='': newbanners.append(banner) elif is_expire==1 and end_date<today: newbanners.append(banner) elif is_expire==0 and end_date>today: newbanners.append(banner) else: pass else: newbanners=banners total_num=len(newbanners) banners = paging(newbanners) return { 'banners': banners, 'total_num': total_num }
def _overdue(act, today): end_date = strptime_to_date(act.end_date) return today > end_date