Merge pull request #2311 from consul/2299-budget_investments_related_content
Budget investments related content
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
class Budget
|
||||
class Investment < ActiveRecord::Base
|
||||
require 'csv'
|
||||
include Rails.application.routes.url_helpers
|
||||
include Measurable
|
||||
include Sanitizable
|
||||
include Taggable
|
||||
@@ -79,6 +80,10 @@ class Budget
|
||||
before_validation :set_responsible_name
|
||||
before_validation :set_denormalized_ids
|
||||
|
||||
def url
|
||||
budget_investment_path(budget, self)
|
||||
end
|
||||
|
||||
def self.filter_params(params)
|
||||
params.select{|x, _| %w{heading_id group_id administrator_id tag_name valuator_id}.include? x.to_s }
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
require 'numeric'
|
||||
class Debate < ActiveRecord::Base
|
||||
include Rails.application.routes.url_helpers
|
||||
include Flaggable
|
||||
include Taggable
|
||||
include Conflictable
|
||||
@@ -49,6 +50,10 @@ class Debate < ActiveRecord::Base
|
||||
|
||||
attr_accessor :link_required
|
||||
|
||||
def url
|
||||
debate_path(self)
|
||||
end
|
||||
|
||||
def self.recommendations(user)
|
||||
tagged_with(user.interests, any: true)
|
||||
.where("author_id != ?", user.id)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Proposal < ActiveRecord::Base
|
||||
include Rails.application.routes.url_helpers
|
||||
include Flaggable
|
||||
include Taggable
|
||||
include Conflictable
|
||||
@@ -71,6 +72,10 @@ class Proposal < ActiveRecord::Base
|
||||
scope :public_for_api, -> { all }
|
||||
scope :not_supported_by_user, ->(user) { where.not(id: user.find_voted_items(votable_type: "Proposal").compact.map(&:id)) }
|
||||
|
||||
def url
|
||||
proposal_path(self)
|
||||
end
|
||||
|
||||
def self.recommendations(user)
|
||||
tagged_with(user.interests, any: true)
|
||||
.where("author_id != ?", user.id)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class RelatedContent < ActiveRecord::Base
|
||||
RELATED_CONTENT_SCORE_THRESHOLD = Setting['related_content_score_threshold'].to_f
|
||||
RELATIONABLE_MODELS = %w{proposals debates}.freeze
|
||||
RELATIONABLE_MODELS = %w{proposals debates budgets investments}.freeze
|
||||
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
Reference in New Issue
Block a user