Adapt backend to enable flagging/unflagging investments
This commit is contained in:
@@ -3,18 +3,32 @@ module FlagActions
|
||||
|
||||
def flag
|
||||
Flag.flag(current_user, flaggable)
|
||||
|
||||
if controller_name == 'investments'
|
||||
respond_with flaggable, template: "budgets/#{controller_name}/_refresh_flag_actions"
|
||||
else
|
||||
respond_with flaggable, template: "#{controller_name}/_refresh_flag_actions"
|
||||
end
|
||||
end
|
||||
|
||||
def unflag
|
||||
Flag.unflag(current_user, flaggable)
|
||||
|
||||
if controller_name == 'investments'
|
||||
respond_with flaggable, template: "budgets/#{controller_name}/_refresh_flag_actions"
|
||||
else
|
||||
respond_with flaggable, template: "#{controller_name}/_refresh_flag_actions"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def flaggable
|
||||
if resource_model.to_s == 'Budget::Investment'
|
||||
instance_variable_get("@investment")
|
||||
else
|
||||
instance_variable_get("@#{resource_model.to_s.downcase}")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -23,6 +23,7 @@ class Budget
|
||||
include Relationable
|
||||
include Notifiable
|
||||
include Filterable
|
||||
include Flaggable
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||
belongs_to :heading
|
||||
|
||||
@@ -182,6 +182,7 @@ class User < ActiveRecord::Base
|
||||
debates_ids = Debate.where(author_id: id).pluck(:id)
|
||||
comments_ids = Comment.where(user_id: id).pluck(:id)
|
||||
proposal_ids = Proposal.where(author_id: id).pluck(:id)
|
||||
investment_ids = Budget::Investment.where(author_id: id).pluck(:id)
|
||||
proposal_notification_ids = ProposalNotification.where(author_id: id).pluck(:id)
|
||||
|
||||
hide
|
||||
@@ -189,6 +190,7 @@ class User < ActiveRecord::Base
|
||||
Debate.hide_all debates_ids
|
||||
Comment.hide_all comments_ids
|
||||
Proposal.hide_all proposal_ids
|
||||
Budget::Investment.hide_all investment_ids
|
||||
ProposalNotification.hide_all proposal_notification_ids
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user