fixes to post/pool apis
This commit is contained in:
@@ -34,6 +34,9 @@ class PostQueryBuilder
|
|||||||
|
|
||||||
when :lte
|
when :lte
|
||||||
relation.where(["#{field} <= ?", arr[1]])
|
relation.where(["#{field} <= ?", arr[1]])
|
||||||
|
|
||||||
|
when :in
|
||||||
|
relation.where(["#{field} in (?)", arr[1]])
|
||||||
|
|
||||||
when :between
|
when :between
|
||||||
relation.where(["#{field} BETWEEN ? AND ?", arr[1], arr[2]])
|
relation.where(["#{field} BETWEEN ? AND ?", arr[1], arr[2]])
|
||||||
|
|||||||
@@ -114,6 +114,10 @@ class Pool < ActiveRecord::Base
|
|||||||
name.tr("_", " ")
|
name.tr("_", " ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def creator_name
|
||||||
|
User.id_to_name(creator_id)
|
||||||
|
end
|
||||||
|
|
||||||
def normalize_post_ids
|
def normalize_post_ids
|
||||||
self.post_ids = self.class.normalize_post_ids(post_ids)
|
self.post_ids = self.class.normalize_post_ids(post_ids)
|
||||||
end
|
end
|
||||||
@@ -237,4 +241,27 @@ class Pool < ActiveRecord::Base
|
|||||||
@neighbor_posts = nil
|
@neighbor_posts = nil
|
||||||
clear_post_id_array
|
clear_post_id_array
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_xml(options = {}, &block)
|
||||||
|
# to_xml ignores the serializable_hash method
|
||||||
|
options ||= {}
|
||||||
|
options[:methods] = [:creator_name]
|
||||||
|
super(options, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def serializable_hash(options = {})
|
||||||
|
return {
|
||||||
|
"created_at" => created_at,
|
||||||
|
"creator_id" => creator_id,
|
||||||
|
"creator_name" => creator_name,
|
||||||
|
"description" => description,
|
||||||
|
"id" => id,
|
||||||
|
"is_active" => is_active?,
|
||||||
|
"is_deleted" => is_deleted?,
|
||||||
|
"name" => name,
|
||||||
|
"post_count" => post_count,
|
||||||
|
"post_ids" => post_ids,
|
||||||
|
"updated_at" => updated_at
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -817,6 +817,7 @@ class Post < ActiveRecord::Base
|
|||||||
def to_xml(options = {}, &block)
|
def to_xml(options = {}, &block)
|
||||||
# to_xml ignores the serializable_hash method
|
# to_xml ignores the serializable_hash method
|
||||||
options ||= {}
|
options ||= {}
|
||||||
|
options[:methods] = [:uploader_name]
|
||||||
options[:except] ||= []
|
options[:except] ||= []
|
||||||
options[:except] += hidden_attributes
|
options[:except] += hidden_attributes
|
||||||
super(options, &block)
|
super(options, &block)
|
||||||
|
|||||||
@@ -199,6 +199,9 @@ class Tag < ActiveRecord::Base
|
|||||||
|
|
||||||
when /\A>(.+)/
|
when /\A>(.+)/
|
||||||
return [:gt, parse_cast($1, type)]
|
return [:gt, parse_cast($1, type)]
|
||||||
|
|
||||||
|
when /,/
|
||||||
|
return [:in, range.split(/,/)]
|
||||||
|
|
||||||
else
|
else
|
||||||
return [:eq, parse_cast(range, type)]
|
return [:eq, parse_cast(range, type)]
|
||||||
|
|||||||
Reference in New Issue
Block a user