decidim-proposals/app/controllers/concerns/decidim/proposals/orderable.rb in decidim-0.2.0 vs decidim-proposals/app/controllers/concerns/decidim/proposals/orderable.rb in decidim-0.3.0

- old
+ new

@@ -20,24 +20,28 @@ # Available orders based on enabled settings def available_orders @available_orders ||= begin available_orders = %w(random recent) - available_orders << "most_voted" if votes_visible? + available_orders << "most_voted" if most_voted_order_available? available_orders end end def default_order - if current_settings.votes_blocked? + if order_by_votes? detect_order("most_voted") else "random" end end - def votes_visible? + def most_voted_order_available? current_settings.votes_enabled? && !current_settings.votes_hidden? + end + + def order_by_votes? + most_voted_order_available? && current_settings.votes_blocked? end # Returns: A random float number between -1 and 1 to be used as a random seed at the database. def random_seed @random_seed ||= (params[:random_seed] ? params[:random_seed].to_f : (rand * 2 - 1))