Sha256: 9c689f6517ae54809420ff44097deaad6073d433cf10ec959a7033ed9fffd438

Contents?: true

Size: 1.25 KB

Versions: 45

Compression:

Stored size: 1.25 KB

Contents

module RailsConnector
  #
  # This helper provides methods for use with ratings.
  module DefaultRatingsHelper
    # Determines whether the current user has rated a CMS object.
    def rated_by_current_user?(obj)
      session[:rated_objs] && session[:rated_objs][obj.id]
    end

    # Builds the HTML markup for the ratings section.
    def stars_for_rating(obj)
      stars = "".html_safe
      (Rating::MINIMUM..Rating::MAXIMUM).collect do |score|
        stars << content_tag(:li, link_a_star(score, obj))
      end
      stars
    end

    private

    def link_a_star(score, obj)
      css_classes = ["", "one-star", "two-stars", "three-stars", "four-stars", "five-stars"]
      descriptions = ["",
        t(:"rails_connector.helpers.ratings.bad"),
        t(:"rails_connector.helpers.ratings.mediocre"),
        t(:"rails_connector.helpers.ratings.average"),
        t(:"rails_connector.helpers.ratings.good"),
        t(:"rails_connector.helpers.ratings.very_good")
      ]
      html_options = {
        :title => "#{score} von #{Rating::MAXIMUM} Sternen",
        :class => css_classes[score],
        "data-description" => descriptions[score]
      }
      link_to(score.to_s, ratings_url(:action => :rate, :id => obj.id, :score => score), html_options)
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
infopark_rails_connector-6.8.0.356.19698103 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.348.160665197 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.328.4a753fc app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.322.c003f11 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.210.ed204b0 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.110.6570b45 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.72.d18d096 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.23.da7f96b app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.16.def5e85 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.15.a24f5ff app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.beta.200.891.647580e app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.beta.200.889.d503e42 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.beta.200.883.f5f063b app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.beta.200.884.4bd86e6 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.beta.200.869.9609b39 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.beta.200.856.8c0fec5 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.beta.200.809.bdfa8c3 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.beta.200.785.05d4af9 app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.beta.200.744.99f67fc app/helpers/rails_connector/default_ratings_helper.rb
infopark_rails_connector-6.8.0.beta.200.720.44fbabd app/helpers/rails_connector/default_ratings_helper.rb