mirror of
https://github.com/discourse/discourse.git
synced 2025-02-19 18:11:18 +00:00
Extract ListController#list_target_user
This commit is contained in:
parent
edbaafdd7b
commit
6f19cb7252
@ -8,10 +8,7 @@ class ListController < ApplicationController
|
|||||||
[:latest, :hot, :favorited, :read, :posted, :unread, :new].each do |filter|
|
[:latest, :hot, :favorited, :read, :posted, :unread, :new].each do |filter|
|
||||||
define_method(filter) do
|
define_method(filter) do
|
||||||
list_opts = build_topic_list_options
|
list_opts = build_topic_list_options
|
||||||
user = current_user
|
user = list_target_user
|
||||||
if params[:user_id] && guardian.is_staff?
|
|
||||||
user = User.find(params[:user_id].to_i)
|
|
||||||
end
|
|
||||||
list = TopicQuery.new(user, list_opts).public_send("list_#{filter}")
|
list = TopicQuery.new(user, list_opts).public_send("list_#{filter}")
|
||||||
list.more_topics_url = url_for(self.public_send "#{filter}_path".to_sym, list_opts.merge(format: 'json', page: next_page))
|
list.more_topics_url = url_for(self.public_send "#{filter}_path".to_sym, list_opts.merge(format: 'json', page: next_page))
|
||||||
|
|
||||||
@ -133,4 +130,12 @@ class ListController < ApplicationController
|
|||||||
exclude_category: (params[:exclude_category] || menu_item.try(:filter))
|
exclude_category: (params[:exclude_category] || menu_item.try(:filter))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def list_target_user
|
||||||
|
if params[:user_id] && guardian.is_staff?
|
||||||
|
User.find(params[:user_id].to_i)
|
||||||
|
else
|
||||||
|
current_user
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user