app/models/decidim/initiative.rb in decidim-initiatives-0.20.1 vs app/models/decidim/initiative.rb in decidim-initiatives-0.21.0

- old
+ new

@@ -66,11 +66,11 @@ allow_blank: true, case_sensitive: false scope :open, lambda { published - .where.not(state: [:discarded, :rejected, :accepted]) + .where.not(state: [:discarded, :rejected, :accepted, :created]) .where("signature_start_date <= ?", Date.current) .where("signature_end_date >= ?", Date.current) } scope :closed, lambda { published @@ -330,10 +330,17 @@ # RETURNS boolean def validate_sms_code_on_votes? organization.available_authorizations.include?("sms") && type.validate_sms_code_on_votes? end + # Public: Returns an empty object. This method should be implemented by + # `ParticipatorySpaceResourceable`, but for some reason this model does not + # implement this interface. + def user_role_config_for(_user, _role_name) + Decidim::ParticipatorySpaceRoleConfig::Base.new(:empty_role_name) + end + private def signature_type_allowed return if published? @@ -349,7 +356,17 @@ def notify_creation notifier = Decidim::Initiatives::StatusChangeNotifier.new(initiative: self) notifier.notify end + + # Allow ransacker to search for a key in a hstore column (`title`.`en`) + [:title, :description].each do |column| + ransacker column do |parent| + Arel::Nodes::InfixOperation.new("->>", parent.table[column], Arel::Nodes.build_quoted(I18n.locale.to_s)) + end + end + + # Allow ransacker to search on an Enum Field + ransacker :state, formatter: proc { |int| states[int] } end end