Permalink
Browse files

Rename rating -> re_rating

  • Loading branch information...
joki1987
joki1987 committed Nov 10, 2014
1 parent e3a7f22 commit 6af75f45fbf1df793ec5ae068bee1622826252b0
@@ -1,10 +1,10 @@
class RatingsController < ApplicationController
class ReRatingsController < ApplicationController
unloadable
def create
@rap = ReArtifactProperties.find_by_id(params[:re_artifact_properties_id])
@rating = Rating.find_or_create_by_re_artifact_properties_id(params[:re_artifact_properties_id])
@rating.value = params[:rating][:value]
@rating = ReRating.find_or_create_by_re_artifact_properties_id(params[:re_artifact_properties_id])
@rating.value = params[:re_rating][:value]
@rating.user_id = User.current.id
respond_to do |format|
@@ -19,8 +19,8 @@ def create
def update
@rap = ReArtifactProperties.find_by_id(params[:re_artifact_properties_id])
@rating = User.current.ratings.find_by_re_artifact_properties_id(@rap.id)
if @rating.update_attributes(params[:rating])
@rating = User.current.re_ratings.find_by_re_artifact_properties_id(@rap.id)
if @rating.update_attributes(params[:re_rating])
respond_to do |format|
format.html { redirect_to @rap, :notice => "Your rating has been updated" }
format.js
@@ -32,10 +32,10 @@ def format_expansions_field_name (field_html, use_case_step_id)
end
def rate
if @rating = User.current.ratings.find_by_re_artifact_properties_id(params[:id])
@rating
if @re_rating = User.current.re_ratings.find_by_re_artifact_properties_id(params[:id])
@re_rating
else
@re_artifact_properties.ratings.new
@re_artifact_properties.re_ratings.new
end
end
end
@@ -9,9 +9,9 @@ class ReArtifactProperties < ActiveRecord::Base
{:conditions => {:project_id => project_id}}
}
has_many :ratings, :dependent => :destroy
has_many :re_ratings, :dependent => :destroy
has_many :raters, :through => :ratings, :source => :users
has_many :raters, :through => :re_ratings, :source => :users
has_many :comments, :as => :commented, :dependent => :destroy, :order => "created_on asc"
has_many :realizations, :dependent => :destroy
has_many :issues, :through => :realizations, :uniq => true
@@ -283,11 +283,11 @@ def siblings
def average_rating
@value = 0.to_f
unless self.ratings.empty?
self.ratings.each do |rating|
unless self.re_ratings.empty?
self.re_ratings.each do |rating|
@value = @value + rating.value
end
@total = self.ratings.size
@total = self.re_ratings.size
@value = @value.to_f / @total.to_f
end
@value
@@ -1,4 +1,4 @@
class Rating < ActiveRecord::Base
class ReRating < ActiveRecord::Base
unloadable
attr_accessible :value
@@ -1,18 +0,0 @@
<div class="ratings">
<%= form_for(rating, :remote => true, :html => {:class => 'rating'}) do |f| %>
<%= f.label('value_1', content_tag(:span, '1'), {:class => 'rating', :id => '1'}) %>
<%= radio_button_tag('rating[value]', 1, rating.value == 1, :class => 'rating_button') %>
<%= f.label('value_2', content_tag(:span, '2'), {:class => 'rating', :id => '2'}) %>
<%= radio_button_tag('rating[value]', 2, rating.value == 2, :class => 'rating_button') %>
<%= f.label('value_3', content_tag(:span, '3'), {:class => 'rating', :id => '3'}) %>
<%= radio_button_tag('rating[value]', 3, rating.value == 3, :class => 'rating_button') %>
<%= f.label('value_4', content_tag(:span, '4'), {:class => 'rating', :id => '4'}) %>
<%= radio_button_tag('rating[value]', 4, rating.value == 4, :class => 'rating_button') %>
<%= f.label('value_5', content_tag(:span, '5'), {:class => 'rating', :id => '5'}) %>
<%= radio_button_tag('rating[value]', 5, rating.value == 5, :class => 'rating_button') %>
<%= hidden_field_tag('re_artifact_properties_id', rating.re_artifact_properties_id) %>
<%= f.submit :Submit %>
<% end %>
<div class="average_rating">&oslash;&nbsp;<%= rating.re_artifact_properties.average_rating %></div>
</div>
<%= javascript_include_tag 'ratings.js', :plugin => 'redmine_re', :cache => true %>
@@ -0,0 +1,18 @@
<div class="ratings">
<%= form_for(re_rating, :remote => true, :html => {:class => 'rating'}) do |f| %>
<%= f.label('value_1', content_tag(:span, '1'), {:class => 'rating', :id => '1'}) %>
<%= radio_button_tag('re_rating[value]', 1, re_rating.value == 1, :class => 'rating_button') %>
<%= f.label('value_2', content_tag(:span, '2'), {:class => 'rating', :id => '2'}) %>
<%= radio_button_tag('re_rating[value]', 2, re_rating.value == 2, :class => 'rating_button') %>
<%= f.label('value_3', content_tag(:span, '3'), {:class => 'rating', :id => '3'}) %>
<%= radio_button_tag('re_rating[value]', 3, re_rating.value == 3, :class => 'rating_button') %>
<%= f.label('value_4', content_tag(:span, '4'), {:class => 'rating', :id => '4'}) %>
<%= radio_button_tag('re_rating[value]', 4, re_rating.value == 4, :class => 'rating_button') %>
<%= f.label('value_5', content_tag(:span, '5'), {:class => 'rating', :id => '5'}) %>
<%= radio_button_tag('re_rating[value]', 5, re_rating.value == 5, :class => 'rating_button') %>
<%= hidden_field_tag('re_artifact_properties_id', re_rating.re_artifact_properties_id) %>
<%= f.submit :Submit %>
<% end %>
<div class="average_rating">&oslash;&nbsp;<%= re_rating.re_artifact_properties.average_rating %></div>
</div>
<%= javascript_include_tag 'ratings.js', :plugin => 'redmine_re', :cache => true %>
View
@@ -70,7 +70,7 @@ de:
re_pandoc_error_first: 'Redmine_re nutzt '
re_pandoc_error_second: ', um Artefakte in unterschiedliche Ausgabeformate zu exportieren. Bitte stellen sie sicher, das pandoc installiert ist.'
re_export_error: "Beim Exportieren trat ein Fehler auf. Bitte stellen Sie sicher, das pandoc installiert und ein Ausgabeformat in den Einstellungen konfiguriert ist."
re_conf_add_relation: "Relation hinzufügen"
View
@@ -61,6 +61,7 @@ en:
re_last_update: 'last update'
re_by: 'by'
re_at: 'at'
re_directed: 'directed'
# Configuration
re_administrate: 'Administration'
@@ -76,6 +77,7 @@ en:
re_fields: 'Fields'
re_configs_saved: 'Configurations saved sucessfully'
re_display_order: 'Display order'
re_conf_internal_name: 'Internal Name'
re_conf_artifact_display_order: 'Use Drag and Drop to change the display order (e.g. in the side menu or the index page)'
re_use: 'Use'
re_conf_artifact_in_use: 'Do you want do use (show) this artifact type in this project (existing artifacts will not be deleted)?'
@@ -91,6 +93,7 @@ en:
re_artifact_type_description_configuration: 'Configuration of description of artifact type %{artifact_type}'
re_artifact_type_description: 'Artifact type description'
re_description_updated_successfully: 'Description was updated successfully'
re_conf_add_relation: "Add relation"
# re_artifact_properties
re_artifact_name: 'Name'
View
@@ -1,5 +1,5 @@
RedmineApp::Application.routes.draw do
resources :ratings
resources :re_ratings
match 'projects/:project_id/requirements' => 'requirements#index', :via => :get
match 'projects/:project_id/requirements/settings/firstload' => 're_settings#configure', :firstload => '1'
@@ -20,7 +20,7 @@ def self.up
end
def self.down
raise ActiveRecord::IrreversibleMigration, "There is no down Migration for configaration of Attachments. Open Configuration page and click on save to make Attachments work!"
say ActiveRecord::IrreversibleMigration, "There is no down Migration for configaration of Attachments. Open Configuration page and click on save to make Attachments work!"
end
end
@@ -0,0 +1,31 @@
class Rating < ActiveRecord::Base
end
class ReRating < ActiveRecord::Base
end
class DeleteRatingsAndCreateReRatings < ActiveRecord::Migration
def self.up
create_table :re_ratings do |t|
t.string :user_id
t.string :re_artifact_properties_id
t.integer :value
end
if table_exists?(:ratings)
if column_exists?(:ratings, :re_artifact_properties_id)
Rating.all.each do |p|
new_rating = ReRating.new
new_rating.user_id = p.user_id
new_rating.re_artifact_properties_id = p.re_artifact_properties_id
new_rating.value = p.value
new_rating.save
end
drop_table :ratings
end
end
end
def self.down
drop_table :re_ratings
end
end
View
@@ -3,8 +3,8 @@
module UserPatch
def self.included(base)
base.class_eval do
has_many :ratings
has_many :rated_properties, :through => :ratings, :source => :re_artifact_properties
has_many :re_ratings
has_many :rated_properties, :through => :re_ratings, :source => :re_artifact_properties
end
end
end
@@ -1,6 +1,6 @@
require File.expand_path('../../test_helper', __FILE__)
class RatingsControllerTest < ActionController::TestCase
class ReRatingsControllerTest < ActionController::TestCase
# Replace this with your real tests.
def test_truth
assert true

0 comments on commit 6af75f4

Please sign in to comment.