def get_event(event_id): args = args_parser.parse({ 'with_name': Arg(bool, allow_missing=True), 'with_records': Arg(bool, allow_missing=True), }) event = event_service.get_event(event_id, **args) _format_event(event) return event
def query_events(): args = args_parser.parse({ 'id': Arg(int), 'status': Arg(int), 'category_l1': Arg(int), 'user_type': Arg(int), 'priority': Arg(int), 'source': Arg(int), 'is_my_event': Arg(int, allow_missing=True), 'is_to_compensate': Arg(int, allow_missing=True), 'begin_date': Arg(str), 'end_date': Arg(str), 'phone': Arg(str), 'with_name': Arg(int, allow_missing=True), 'with_records': Arg(int, allow_missing=True), }) event_id = args.pop('id', None) if event_id is not None: events = [] try: event = event_service.get_event(event_id) except UserExc: event = None if event: events.append(event) return { 'events': events, 'count': len(events) } offset, limit = get_paging_params(db_style=True) args.update({'offset': offset, 'limit': limit}) is_my_event = args.pop('is_my_event', None) if is_my_event is not None: if is_my_event: args.update(handler_id=current_user.id) else: args.update(not_handler_id=current_user.id) events = event_service.query_events(**args) count = event_service.count_events(**args) _format_event(events) return { 'events': events, 'count': count }
def query_events(): args = args_parser.parse({ 'id': Arg(int), 'status': Arg(int), 'category_l1': Arg(int), 'user_type': Arg(int), 'priority': Arg(int), 'source': Arg(int), 'is_my_event': Arg(int, allow_missing=True), 'is_to_compensate': Arg(int, allow_missing=True), 'begin_date': Arg(str), 'end_date': Arg(str), 'phone': Arg(str), 'with_name': Arg(int, allow_missing=True), 'with_records': Arg(int, allow_missing=True), }) event_id = args.pop('id', None) if event_id is not None: events = [] try: event = event_service.get_event(event_id) except UserExc: event = None if event: events.append(event) return {'events': events, 'count': len(events)} offset, limit = get_paging_params(db_style=True) args.update({'offset': offset, 'limit': limit}) is_my_event = args.pop('is_my_event', None) if is_my_event is not None: if is_my_event: args.update(handler_id=current_user.id) else: args.update(not_handler_id=current_user.id) events = event_service.query_events(**args) count = event_service.count_events(**args) _format_event(events) return {'events': events, 'count': count}