restrict min level constraints for forum topics to mod+admin and restrict options based on current user's level. check privileges for visiblity in forum posts and topics. deprecate serializable_hash (undocumented, internal) for as_json, refactor to use hidden_attributes and method_attributes #2658
This commit is contained in:
@@ -3,18 +3,26 @@ module Danbooru
|
||||
module ActiveRecordApi
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def serializable_hash(options = {})
|
||||
def as_json(options = {})
|
||||
options ||= {}
|
||||
options[:except] ||= []
|
||||
options[:except] += hidden_attributes
|
||||
|
||||
options[:methods] ||= []
|
||||
options[:methods] += method_attributes
|
||||
|
||||
super(options)
|
||||
end
|
||||
|
||||
def to_xml(options = {}, &block)
|
||||
# to_xml ignores serializable_hash
|
||||
options ||= {}
|
||||
|
||||
options[:except] ||= []
|
||||
options[:except] += hidden_attributes
|
||||
|
||||
options[:methods] ||= []
|
||||
options[:methods] += method_attributes
|
||||
|
||||
super(options, &block)
|
||||
end
|
||||
|
||||
@@ -22,6 +30,10 @@ module Danbooru
|
||||
def hidden_attributes
|
||||
[:uploader_ip_addr, :updater_ip_addr, :creator_ip_addr, :ip_addr]
|
||||
end
|
||||
|
||||
def method_attributes
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user