def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(Configuration, args) fb.set_equals_filters(['language_id']) try: fb.set_and_or_filter('s', 'or', [{ 'field': 'title', 'type': 'like' }, { 'field': 'description', 'type': 'like' }]) except Exception as e: raise BadRequestError(str(e)) query = self.session.query(Configuration).filter( *fb.get_filter()).order_by(*fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = ConfigurationSchema(many=True, exclude=self.get_exclude_fields( args, ['language', 'socials'])) return self.handle_success(result, schema, 'get', 'Configuration')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(Term, args) fb.set_like_filters(['parent_id', 'taxonomy_id', 'language_id']) try: fb.set_and_or_filter('s', 'or', [{ 'field': 'name', 'type': 'like' }, { 'field': 'display_name', 'type': 'like' }, { 'field': 'description', 'type': 'like' }]) except Exception as e: raise BadRequestError(str(e)) query = self.session.query(Term).filter(*fb.get_filter()).order_by( *fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = TermSchema( many=True, exclude=self.get_exclude_fields( args, ['language', 'parent', 'children', 'taxonomy'])) return self.handle_success(result, schema, 'get', 'Term')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(Field, args) fb.set_equals_filters(['type', 'grouper_id', 'post_id']) try: fb.set_and_or_filter('s', 'or', [{ 'field': 'name', 'type': 'like' }, { 'field': 'description', 'type': 'like' }]) except Exception as e: raise BadRequestError(str(e)) self.set_protection_to_child_post(fb) query = self.session.query(Field).join( *self.joins, isouter=True).filter(*fb.get_filter()).order_by(*fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = FieldSchema(many=True, exclude=self.get_exclude_fields( args, ['post', 'grouper'])) return self.handle_success(result, schema, 'get', 'Field')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(Comment, args) fb.set_like_filters(['comment', 'origin_ip', 'origin_agent']) fb.set_equals_filters( ['status', 'parent_id', 'user_id', 'post_id', 'language_id']) try: fb.set_date_filter('created', date_modifier=args['date_modifier']) fb.set_between_dates_filter( 'created', not_between=args['not_between'], compare_date_time_one=args['compare_date_time_one'], compare_date_time_two=args['compare_date_time_two']) except Exception as e: raise BadRequestError(str(e)) query = self.session.query(Comment).filter(*fb.get_filter()).order_by( *fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = CommentSchema( many=True, exclude=self.get_exclude_fields( args, ['user', 'language', 'parent', 'children', 'post'])) return self.handle_success(result, schema, 'get', 'Comment')
def setUp(self): session = Session() query = session.query(Post.id) self.result = Paginate(query, 1, 10) self.keys = [ 'prev', 'next', 'has_prev', 'has_next', 'size', 'pages', 'total', 'current' ]
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(Blacklist, args) fb.set_equals_filters(['type', 'target']) fb.set_like_filters(['value']) query = self.session.query(Blacklist).filter(*fb.get_filter()).order_by(*fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = BlacklistSchema(many=True) return self.handle_success(result, schema, 'get', 'Blacklist')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(Capability, args) fb.set_equals_filters(['type', 'target_id', 'can_write', 'can_read', 'can_delete', 'only_themselves']) fb.set_like_filters(['description']) query = self.session.query(Capability).join(*self.joins).filter(*fb.get_filter()).order_by(*fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = CapabilitySchema(many=True, exclude=self.get_exclude_fields(args, ['roles'])) return self.handle_success(result, schema, 'get', 'Capability')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(MenuItem, args) fb.set_equals_filters(['type', 'behavior', 'url', 'menu_id', 'parent_id']) fb.set_like_filters(['title']) query = self.session.query(MenuItem).filter(*fb.get_filter()).order_by(*fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = MenuItemSchema(many=True, exclude=self.get_exclude_fields(args, ['parent', 'children', 'menu'])) return self.handle_success(result, schema, 'get', 'MenuItem')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(FieldContent, args) fb.set_like_filters(['content']) fb.set_equals_filters(['field_id', 'grouper_id', 'post_id']) self.set_protection_to_child_post(fb) query = self.session.query(FieldContent).join(*self.joins, isouter=True).filter(*fb.get_filter()).order_by(*fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = FieldContentSchema(many=True) return self.handle_success(result, schema, 'get', 'FieldContent')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(Social, args) fb.set_like_filters(['name']) fb.set_equals_filters(['origin', 'user_id']) query = self.session.query(Social).filter(*fb.get_filter()).order_by( *fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = SocialSchema(many=True, exclude=self.get_exclude_fields( args, ['user', 'configuration'])) return self.handle_success(result, schema, 'get', 'Social')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(PostType, args) fb.set_like_filters(['name']) fb.set_equals_filters(['type']) query = self.session.query(PostType).filter(*fb.get_filter()).order_by( *fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = PostTypeSchema(many=True, exclude=self.get_exclude_fields( args, ['template', 'nests', 'taxonomies'])) return self.handle_success(result, schema, 'get', 'PostType')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(Variable, args) try: fb.set_and_or_filter('s', 'or', [{'field':'key', 'type':'like'}, {'field':'value', 'type':'like'}]) except Exception as e: raise BadRequestError(str(e)) query = self.session.query(Variable).filter(*fb.get_filter()).order_by(*fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = VariableSchema(many=True) return self.handle_success(result, schema, 'get', 'Variable')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(Role, args) fb.set_equals_filters(['can_access_admin']) fb.set_like_filters(['name', 'description']) if (args['capability_description'] and args['capability_description'] != ''): fb.set_like_filter('capability_description', joined=Capability, joined_key='description') self.joins.append(Role.capabilities) query = self.session.query(Role).join(*self.joins).filter(*fb.get_filter()).order_by(*fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = RoleSchema(many=True, exclude=self.get_exclude_fields(args, ['capabilities'])) return self.handle_success(result, schema, 'get', 'Role')
def get(self, args): """Returns a list of data recovered from model. Before applies the received query params arguments.""" fb = FilterBuilder(Post, args) fb.set_equals_filters(['status', 'user_id', 'parent_id', 'post_type_id', 'language_id']) self.joins.append(FieldContent) self.joins.append(FieldText) if (args['term_id'] and args['term_id'] != '' and Checker().can_be_integer(args['term_id'])): fb.set_like_filter('term_id', joined=Term, joined_key='id') self.joins.append(Post.terms) try: fb.set_date_filter('created', date_modifier=args['date_modifier']) fb.set_between_dates_filter( 'created', not_between=args['not_between'], compare_date_time_one=args['compare_date_time_one'], compare_date_time_two=args['compare_date_time_two'] ) fb.set_and_or_filter('s', 'or', [ {'field': 'name', 'type': 'like'}, {'field': 'title', 'type': 'like'}, {'field': 'description', 'type': 'like'}, {'field': 'content', 'type': 'like', 'kwargs': {'joined': FieldContent}}, {'field': 'content', 'type': 'like', 'kwargs': {'joined': FieldText}} ]) if not self.the_logged_user: fb.set_range_of_dates_filter() fb.filter += (Post.status == 'publish',) self.set_can_see_protected() if not self.can_see_protected: fb.filter += (Post.is_protected != True,) except Exception as e: raise BadRequestError(str(e)) query = self.session.query(Post).join(*self.joins, isouter=True).filter(*fb.get_filter()).order_by(*fb.get_order_by()) result = Paginate(query, fb.get_page(), fb.get_limit()) schema = PostSchema(many=True, exclude=self.get_exclude_fields(args, [ 'user', 'language', 'parent', 'children', 'post_type', 'nests', 'groupers', 'terms'])) return self.handle_success(result, schema, 'get', 'Post')