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