From 0c7ed580c795934949ed7ea330294d3dbd7c0853 Mon Sep 17 00:00:00 2001 From: Gabriel Silva Date: Fri, 13 Nov 2015 18:41:52 +0000 Subject: [PATCH] Organization Ratings plugin improvements --- app/views/tasks/_task.html.erb | 7 ++++--- plugins/organization_ratings/controllers/organization_ratings_plugin_profile_controller.rb | 21 ++++++++------------- plugins/organization_ratings/db/migrate/20151203121430_destroy_rejected_reports.rb | 14 ++++++++++++++ plugins/organization_ratings/lib/create_organization_rating_comment.rb | 57 ++++++++++++++++++--------------------------------------- plugins/organization_ratings/lib/organization_rating.rb | 12 ++++++++++++ plugins/organization_ratings/lib/organization_ratings_plugin.rb | 6 +++++- plugins/organization_ratings/test/functional/organization_ratings_plugin_profile_controller_test.rb | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- plugins/organization_ratings/test/unit/create_organization_rating_comment_test.rb | 44 ++++++++++++++++++++++++++++++++++++++++++++ plugins/organization_ratings/test/unit/organization_rating_test.rb | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------ plugins/organization_ratings/views/organization_ratings_plugin_profile/_new_rating_fields.html.erb | 41 +++++++++++++++++++---------------------- plugins/organization_ratings/views/shared/_user_rating_container.html.erb | 10 +++++++--- plugins/organization_ratings/views/tasks/_create_organization_rating_comment_accept_details.html.erb | 19 +++++++++++++++++-- public/stylesheets/tasks.scss | 1 + 13 files changed, 293 insertions(+), 172 deletions(-) create mode 100644 plugins/organization_ratings/db/migrate/20151203121430_destroy_rejected_reports.rb create mode 100644 plugins/organization_ratings/test/unit/create_organization_rating_comment_test.rb diff --git a/app/views/tasks/_task.html.erb b/app/views/tasks/_task.html.erb index d1a4cd2..6c3f1ed 100644 --- a/app/views/tasks/_task.html.erb +++ b/app/views/tasks/_task.html.erb @@ -2,6 +2,10 @@ <%= render :partial => 'task_icon', :locals => {:task => task} %> +
<%= show_time(task.created_at) %>
+ + <%= render :partial => 'task_title', :locals => {:task => task} %> + <% if !@view_only && profile.organization? && @responsible_candidates.present? %>
<%= _('Assign to:') %> @@ -41,9 +45,6 @@ <% end %>
-
<%= show_time(task.created_at) %>
- - <%= render :partial => 'task_title', :locals => {:task => task} %>
<%= task_information(task) %> diff --git a/plugins/organization_ratings/controllers/organization_ratings_plugin_profile_controller.rb b/plugins/organization_ratings/controllers/organization_ratings_plugin_profile_controller.rb index e1302c5..70cb01d 100644 --- a/plugins/organization_ratings/controllers/organization_ratings_plugin_profile_controller.rb +++ b/plugins/organization_ratings/controllers/organization_ratings_plugin_profile_controller.rb @@ -54,23 +54,18 @@ class OrganizationRatingsPluginProfileController < ProfileController end def create_rating_comment(rating) - if params[:comments] - comment_task = CreateOrganizationRatingComment.create!( - params[:comments].merge( - :requestor => rating.person, - :organization_rating_id => rating.id, - :target => rating.organization - ) + if params[:comments].present? && params[:comments][:body].present? + comment_task = CreateOrganizationRatingComment.create!( + params[:comments].merge( + :requestor => rating.person, + :organization_rating_id => rating.id, + :target => rating.organization ) - comment_task.finish if can_perform?(params) + ) + comment_task.finish unless env_organization_ratings_config.are_moderated end end - def can_perform? (params) - (params[:comments][:body].blank? || - !env_organization_ratings_config.are_moderated) - end - def permission :manage_memberships end diff --git a/plugins/organization_ratings/db/migrate/20151203121430_destroy_rejected_reports.rb b/plugins/organization_ratings/db/migrate/20151203121430_destroy_rejected_reports.rb new file mode 100644 index 0000000..7d08281 --- /dev/null +++ b/plugins/organization_ratings/db/migrate/20151203121430_destroy_rejected_reports.rb @@ -0,0 +1,14 @@ +class DestroyRejectedReports < ActiveRecord::Migration + def up + comments = [] + select_all("SELECT data FROM tasks WHERE type = 'CreateOrganizationRatingComment' AND status = 2").each do |task| + settings = YAML.load(task['data']) + comments << settings[:organization_rating_comment_id] + end + execute("DELETE FROM comments WHERE id IN (#{comments.join(',')})") + end + + def down + say "This migration can't be reverted" + end +end diff --git a/plugins/organization_ratings/lib/create_organization_rating_comment.rb b/plugins/organization_ratings/lib/create_organization_rating_comment.rb index 1ce9fb0..fe66ab3 100644 --- a/plugins/organization_ratings/lib/create_organization_rating_comment.rb +++ b/plugins/organization_ratings/lib/create_organization_rating_comment.rb @@ -9,28 +9,14 @@ class CreateOrganizationRatingComment < Task attr_accessible :organization_rating_id, :body, :requestor attr_accessible :reject_explanation, :target - before_save :update_comment_body - DATA_FIELDS = ['body'] DATA_FIELDS.each do |field| settings_items field.to_sym end - def update_comment_body - if self.organization_rating_comment_id.nil? - create_comment - else - comment = Comment.find_by_id(self.organization_rating_comment_id) - comment.body = get_comment_message - comment.save - end - end - - def create_comment + def perform if (self.body && !self.body.blank?) - comment_body = _("Comment waiting for approval") - comment = Comment.create!(:source => self.target, :body => comment_body, :author => self.requestor) - + comment = Comment.create!(:source => self.target, :body => self.body, :author => self.requestor) self.organization_rating_comment_id = comment.id link_comment_with_its_rating(comment) @@ -43,26 +29,16 @@ class CreateOrganizationRatingComment < Task rating.save end - def get_comment_message - if self.status == Status::CANCELLED - _("Comment rejected") - elsif self.status == Status::FINISHED - self.body - else - _("No comment") - end - end - def accept_details true end def title - _("New Comment") + _("New Report") end def information - message = _("%{requestor} wants to create a comment in this %{target_class}") % + message = _("%{requestor} wants to leave a report about this %{target_class}") % {:requestor_url => url_for(self.requestor.url), :requestor => self.requestor.name, :target_class => _(self.target.class.name)} {:message => message} @@ -87,45 +63,48 @@ class CreateOrganizationRatingComment < Task end def target_notification_description - _("%{requestor} wants to create a comment in this \"%{target}\"") % + _("%{requestor} wants to leave a report about this \"%{target}\"") % {:requestor => self.requestor.name, :target => _(self.target.class.name.downcase) } end def target_notification_message - _("User \"%{user}\" requested to create a comment in the %{target_class} + _("User \"%{user}\" just made a report at %{target_class} \"%{target_name}\". You have to approve or reject it through the \"Pending Validations\" section in your control panel.\n") % - { :user => self.requestor.name, :target_class => _(self.target.class.name.downcase), :target_name => self.target.name } + { :user => self.requestor.name, + :target_class => _(self.target.class.name.downcase), + :target_name => self.target.name } end def task_created_message - _("Your request for commenting at %{target} was + _("Your report at %{target_class} \"%{target}\" was just sent. The administrator will receive it and will approve or reject your request according to his methods and criteria. You will be notified as soon as environment administrator has a position about your request.") % - { :target => self.target.name } + { :target_class => _(self.target.class.name.downcase), :target => self.target.name } end def task_cancelled_message - _("Your request for commenting at %{target} was + _("Your report at %{target_class} \"%{target}\" was not approved by the administrator. The following explanation was given: \n\n%{explanation}") % - { :target => self.target.name, + { :target_class => _(self.target.class.name.downcase), + :target => self.target.name, :explanation => self.reject_explanation } end def task_finished_message - _('Your request for commenting at %{target} was approved. - You can access %{url} to see your comment.') % - { :target => self.target.name, :url => ratings_url } + _("Your report at %{target_class} \"%{target}\" was approved. + You can access %{url} to see your comment.") % + { :target_class => _(self.target.class.name.downcase), :target => self.target.name, :url => ratings_url } end private def ratings_url - url = url_for(self.target.public_profile_url) + "/plugin/organization_ratings/new_rating" + url_for(self.target.public_profile_url) + "/plugin/organization_ratings/new_rating" end end diff --git a/plugins/organization_ratings/lib/organization_rating.rb b/plugins/organization_ratings/lib/organization_rating.rb index 3bdeba1..feae5db 100644 --- a/plugins/organization_ratings/lib/organization_rating.rb +++ b/plugins/organization_ratings/lib/organization_rating.rb @@ -13,6 +13,18 @@ class OrganizationRating < ActiveRecord::Base validates :organization_id, :person_id, :presence => true + def display_moderation_message person + if person.present? + task_active? && (person.is_admin? || person == self.person || + self.organization.is_admin?(person)) + end + end + + def task_active? + tasks = CreateOrganizationRatingComment.where(:target_id => self.organization.id, + :status => Task::Status::ACTIVE) + tasks.detect {|t| t.organization_rating_id == self.id}.present? + end def self.average_rating organization_id average = OrganizationRating.where(organization_id: organization_id).average(:value) diff --git a/plugins/organization_ratings/lib/organization_ratings_plugin.rb b/plugins/organization_ratings/lib/organization_ratings_plugin.rb index 4420131..a6701bf 100644 --- a/plugins/organization_ratings/lib/organization_ratings_plugin.rb +++ b/plugins/organization_ratings/lib/organization_ratings_plugin.rb @@ -22,7 +22,11 @@ class OrganizationRatingsPlugin < Noosfero::Plugin nil end - def organization_ratings_plugin_extra_fields_show_data user_rating + def organization_ratings_plugin_task_extra_fields user_rating + nil + end + + def organization_ratings_plugin_container_extra_fields user_rating nil end diff --git a/plugins/organization_ratings/test/functional/organization_ratings_plugin_profile_controller_test.rb b/plugins/organization_ratings/test/functional/organization_ratings_plugin_profile_controller_test.rb index 17dfd9a..c7e4a14 100644 --- a/plugins/organization_ratings/test/functional/organization_ratings_plugin_profile_controller_test.rb +++ b/plugins/organization_ratings/test/functional/organization_ratings_plugin_profile_controller_test.rb @@ -17,6 +17,7 @@ class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCas @person = create_user('testuser').person @community = Community.create(:name => "TestCommunity") + @community.add_admin @person @enterprise = fast_create(Enterprise) @config = OrganizationRatingsConfig.instance login_as(@person.identifier) @@ -36,13 +37,13 @@ class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCas assert_redirected_to @community.url end - test "Create community_rating without comment body" do + test "create community_rating without comment body" do post :new_rating, profile: @community.identifier, :comments => {:body => ""}, :organization_rating_value => 2 assert_equal "#{@community.name} successfully rated!", session[:notice] end - test "Do not create community_rating without a rate value" do + test "do not create community_rating without a rate value" do post :new_rating, profile: @community.identifier, :comments => {:body => ""}, :organization_rating_value => nil assert_equal "Sorry, there were problems rating this profile.", session[:notice] @@ -76,13 +77,13 @@ class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCas block = StatisticsBlock.new enterprise = fast_create(Enterprise) post :new_rating, profile: enterprise.identifier, :comments => {:body => "body board"}, :organization_rating_value => 1 + CreateOrganizationRatingComment.last.finish enterprise.reload @environment.reload block.expects(:owner).at_least_once.returns(@environment) assert_equal 1, block.comments end - test "should count organization ratings on statistic block when block owner = Profile" do @config.cooldown = 0 @config.save @@ -91,13 +92,15 @@ class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCas post :new_rating, profile: @community.identifier, :comments => {:body => "body board"}, :organization_rating_value => 1 post :new_rating, profile: @community.identifier, :comments => {:body => "body surf"}, :organization_rating_value => 5 - + CreateOrganizationRatingComment.all.each do |s| + s.finish + end block.expects(:owner).at_least_once.returns(@community) @community.reload assert_equal 2, block.comments end - test "Display unavailable rating message for users that must wait the rating cooldown time" do + test "display unavailable rating message for users that must wait the rating cooldown time" do post :new_rating, profile: @community.identifier, :comments => {:body => ""}, :organization_rating_value => 3 assert_no_match(/The administrators set the minimum time of/, @response.body) valid_rating = OrganizationRating.last @@ -108,4 +111,81 @@ class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCas assert_equal valid_rating.id, new_rating.id end + + test "display moderation report message body to community admin" do + @member = create_user('member') + @community.add_member @member.person + login_as 'member' + @controller.stubs(:current_user).returns(@member) + + post :new_rating, profile: @community.identifier, :comments => {:body => "comment"}, :organization_rating_value => 3 + + login_as 'testuser' + @controller.stubs(:current_user).returns(@person.user) + get :new_rating, profile: @community.identifier + assert_tag :tag => 'p', :content => /Report waiting for approval/, :attributes => {:class =>/moderation-msg/} + assert_no_tag :tag => 'p', :attributes => {:class =>/comment-body/} + end + + test "display moderation report message to owner" do + @member = create_user('member') + @community.add_member @member.person + login_as 'member' + @controller.stubs(:current_user).returns(@member) + + post :new_rating, profile: @community.identifier, :comments => {:body => "comment"}, :organization_rating_value => 3 + get :new_rating, profile: @community.identifier + assert_tag :tag => 'p', :content => /Report waiting for approval/, :attributes => {:class =>/moderation-msg/} + assert_no_tag :tag => 'p', :attributes => {:class =>/comment-body/} + end + + test "display moderation report message comment to env admin" do + post :new_rating, profile: @community.identifier, :comments => {:body => "comment"}, :organization_rating_value => 3 + + @admin = create_admin_user(@environment) + login_as @admin + @controller.stubs(:current_user).returns(Profile[@admin].user) + + get :new_rating, profile: @community.identifier + assert_tag :tag => 'p', :content => /Report waiting for approval/, :attributes => {:class =>/moderation-msg/} + assert_no_tag :tag => 'p', :attributes => {:class =>/comment-body/} + end + + test "not display moderation report message to regular user" do + post :new_rating, profile: @community.identifier, :comments => {:body => "comment"}, :organization_rating_value => 3 + rating_task = CreateOrganizationRatingComment.last + rating_task.cancel + + @member = create_user('member') + @community.add_member @member.person + login_as 'member' + @controller.stubs(:current_user).returns(@member) + + get :new_rating, profile: @community.identifier + assert_no_tag :tag => 'p', :content => /Report waiting for approval/, :attributes => {:class =>/moderation-msg/} + assert_no_tag :tag => 'p', :attributes => {:class =>/comment-body/} + end + + test "not display rejected comment message to not logged user" do + post :new_rating, profile: @community.identifier, :comments => {:body => "comment"}, :organization_rating_value => 3 + rating_task = CreateOrganizationRatingComment.last + rating_task.cancel + + logout + @controller.stubs(:logged_in?).returns(false) + + get :new_rating, profile: @community.identifier + assert_no_tag :tag => 'p', :content => /Report waiting for approval/, :attributes => {:class =>/comment-rejected-msg/} + assert_no_tag :tag => 'p', :attributes => {:class =>/comment-body/} + end + + test "display report when Task accepted" do + post :new_rating, profile: @community.identifier, :comments => {:body => "comment accepted"}, :organization_rating_value => 3 + rating_task = CreateOrganizationRatingComment.last + rating_task.finish + + get :new_rating, profile: @community.identifier + assert_no_tag :tag => 'p', :content => /Report waiting for approva/, :attributes => {:class =>/comment-rejected-msg/} + assert_tag :tag => 'p', :content => /comment accepted/, :attributes => {:class =>/comment-body/} + end end diff --git a/plugins/organization_ratings/test/unit/create_organization_rating_comment_test.rb b/plugins/organization_ratings/test/unit/create_organization_rating_comment_test.rb new file mode 100644 index 0000000..c72d309 --- /dev/null +++ b/plugins/organization_ratings/test/unit/create_organization_rating_comment_test.rb @@ -0,0 +1,44 @@ +require 'test_helper' +class CreateOrganizationRatingCommentTest < ActiveSupport::TestCase + + def setup + @person = create_user('Mario').person + @person.email = "person@email.com" + @person.save + @community = fast_create(Community) + @adminuser = Person[create_admin_user(Environment.default)] + @rating = fast_create(OrganizationRating, {:value => 1, + :person_id => @person.id, + :organization_id => @community.id, + :created_at => DateTime.now, + :updated_at => DateTime.now, + }) + end + + test "create comment when finish TASK" do + create_organization_rating_comment = CreateOrganizationRatingComment.create!( + :requestor => @person, + :organization_rating_id => @rating.id, + :target => @community, + :body => "sample comment" + ) + assert_equal Task::Status::ACTIVE, create_organization_rating_comment.status + assert_difference 'Comment.count' do + create_organization_rating_comment.finish + end + end + + test "do not create comment when cancel TASK" do + create_organization_rating_comment = CreateOrganizationRatingComment.create!( + :requestor => @person, + :organization_rating_id => @rating.id, + :target => @community, + :body => "sample comment" + ) + assert_equal Task::Status::ACTIVE, create_organization_rating_comment.status + assert_no_difference 'Comment.count' do + create_organization_rating_comment.cancel + end + end + +end diff --git a/plugins/organization_ratings/test/unit/organization_rating_test.rb b/plugins/organization_ratings/test/unit/organization_rating_test.rb index 89f4fe8..b01cdab 100644 --- a/plugins/organization_ratings/test/unit/organization_rating_test.rb +++ b/plugins/organization_ratings/test/unit/organization_rating_test.rb @@ -1,6 +1,20 @@ -require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' - +require 'test_helper' class OrganizationRatingTest < ActiveSupport::TestCase + + def setup + @person = create_user('Mario').person + @person.email = "person@email.com" + @person.save + @community = fast_create(Community) + @adminuser = Person[create_admin_user(Environment.default)] + @rating = fast_create(OrganizationRating, {:value => 1, + :person_id => @person.id, + :organization_id => @community.id, + :created_at => DateTime.now, + :updated_at => DateTime.now, + }) + end + test "The value must be between 1 and 5" do organization_rating1 = OrganizationRating.new :value => -1 organization_rating2 = OrganizationRating.new :value => 6 @@ -21,57 +35,58 @@ class OrganizationRatingTest < ActiveSupport::TestCase assert_equal false, organization_rating2.errors[:value].include?("must be between 1 and 5") end - test "Create task for create a rating comment" do - person = create_user('molly').person - person.email = "person@email.com" - person.save! + test "false return when no active tasks for an Organization Rating" do + assert_not @rating.task_active? + end - community = fast_create(Community) - community.add_admin(person) + test "true return when an active task exists for an Organization Rating" do + CreateOrganizationRatingComment.create!( + :organization_rating_id => @rating.id, + :target => @community, + :requestor => @person) - organization_rating = OrganizationRating.create!( - :value => 3, - :person => person, - :organization => community - ) - - create_organization_rating_comment = CreateOrganizationRatingComment.create!( - :requestor => person, - :organization_rating_id => organization_rating.id, - :target => community - ) + assert_equal Task::Status::ACTIVE, CreateOrganizationRatingComment.last.status + assert @rating.task_active? + end - assert community.tasks.include?(create_organization_rating_comment) + test "return false when an cancelled task exists for an Organization Rating" do + CreateOrganizationRatingComment.create!( + :organization_rating_id => @rating.id, + :target => @community, + :requestor => @person) + CreateOrganizationRatingComment.last.cancel + assert_not @rating.task_active? end - test "Check comment message when Task status = ACTIVE" do - person = create_user('molly').person - person.email = "person@email.com" - person.save! + test "display report moderation message to community admin" do + moderator = create_user('moderator') + @community.add_admin(moderator.person) + @rating.stubs(:task_active?).returns(true) + assert @rating.display_moderation_message(@adminuser) + end - community = fast_create(Community) - community.add_admin(person) + test "display report moderation message to owner" do + @rating.stubs(:task_active?).returns(true) + assert @rating.display_moderation_message(@person) + end + test "do not display report moderation message to regular user" do + regular_person = fast_create(Person) + @rating.stubs(:task_active?).returns(true) + assert_not @rating.display_moderation_message(regular_person) + end - organization_rating = OrganizationRating.create!( - :value => 3, - :person => person, - :organization => community - ) + test "do not display report moderation message to not logged user" do + @rating.stubs(:task_active?).returns(true) + assert_not @rating.display_moderation_message(nil) + end - create_organization_rating_comment = CreateOrganizationRatingComment.create!( - :requestor => person, - :organization_rating_id => organization_rating.id, - :target => community, - :body => "sample comment" - ) - assert_equal 1, create_organization_rating_comment.status - message = "Comment waiting for approval" - comment = Comment.find_by_id(create_organization_rating_comment.organization_rating_comment_id) - assert_equal message, comment.body + test "do not display report moderation message no active task exists" do + @rating.stubs(:task_active?).returns(false) + assert_not @rating.display_moderation_message(@person) end - test "Check comment message when Task status = CANCELLED" do + test "Create task for create a rating comment" do person = create_user('molly').person person.email = "person@email.com" person.save! @@ -79,7 +94,6 @@ class OrganizationRatingTest < ActiveSupport::TestCase community = fast_create(Community) community.add_admin(person) - organization_rating = OrganizationRating.create!( :value => 3, :person => person, @@ -89,51 +103,12 @@ class OrganizationRatingTest < ActiveSupport::TestCase create_organization_rating_comment = CreateOrganizationRatingComment.create!( :requestor => person, :organization_rating_id => organization_rating.id, - :target => community, - :body => "sample comment" - ) - create_organization_rating_comment.cancel - assert_equal 2, create_organization_rating_comment.status - message = "Comment rejected" - comment = Comment.find_by_id(create_organization_rating_comment.organization_rating_comment_id) - assert_equal message, comment.body - end - - test "Check comment message when Task status = FINISHED" do - person = create_user('molly').person - person.email = "person@email.com" - person.save! - - community = fast_create(Community) - community.add_admin(person) - - comment = Comment.create!(source: community, - body: "regular comment", - author: person) - - organization_rating = OrganizationRating.create!( - :value => 3, - :person => person, - :organization => community, - :comment => comment + :target => community ) - create_organization_rating_comment = CreateOrganizationRatingComment.create!( - :body => comment.body, - :requestor => organization_rating.person, - :organization_rating_id => organization_rating.id, - :target => organization_rating.organization, - :body => "sample comment" - ) - - create_organization_rating_comment.finish - assert_equal 3, create_organization_rating_comment.status - message = "sample comment" - comment = Comment.find_by_id(create_organization_rating_comment.organization_rating_comment_id) - assert_equal message, comment.body + assert community.tasks.include?(create_organization_rating_comment) end - test "Should calculate community's rating average" do community = fast_create Community p1 = fast_create Person, :name=>"Person 1" diff --git a/plugins/organization_ratings/views/organization_ratings_plugin_profile/_new_rating_fields.html.erb b/plugins/organization_ratings/views/organization_ratings_plugin_profile/_new_rating_fields.html.erb index 0708dad..e379d05 100644 --- a/plugins/organization_ratings/views/organization_ratings_plugin_profile/_new_rating_fields.html.erb +++ b/plugins/organization_ratings/views/organization_ratings_plugin_profile/_new_rating_fields.html.erb @@ -19,13 +19,12 @@ <% if @rating_available %>
-
"rate" %>> +
<%= @plugins.dispatch(:organization_ratings_plugin_star_message).collect { |content| instance_exec(&content) }.join("") %>
- <% (1..5).each do |rate_number| %> <% if rate_number <= default_rating %>
@@ -43,8 +42,8 @@
<%= form_for :comments do |c| %>
- <%= c.label :body, _('Comment (Optional):'), :class => "formlabel" %> - <%= c.text_area :body %> + <%= c.label :body, _('Comment (Optional):'), :class => "formlabel" %> + <%= c.text_area :body %>
<%= @plugins.dispatch(:organization_ratings_plugin_comments_extra_fields).collect { |content| instance_exec(&content) }.join("") %> @@ -57,24 +56,22 @@ <% end %>
+
+ <% elsif env_organization_ratings_config.vote_once %> +
+ <%= _("Hi, %s! The administrators set that you can vote") % current_user.name %> + <%= _("only once") %> + <%= _("for this %s.") % profile.class.name.downcase %> + <%= render :partial => 'shared/rating_button', :locals => { :disabled => true } %> +
+ <% else %> +
+ <%= _("Hi, %s! The administrators set the minimum time of") % current_user.name %> + <%= _("%d hour(s)") % env_organization_ratings_config.cooldown %> + <%= _("between each evaluation.") %> - <% elsif env_organization_ratings_config.vote_once %> -
- <%= _("Hi, %s! The administrators set that you can vote") % current_user.name %> - <%= _("only once") %> - <%= _("for this %s.") % profile.class.name.downcase %> - <%= render :partial => 'shared/rating_button', :locals => { :disabled => true } %> -
- <% else %> -
- <%= _("Hi, %s! The administrators set the minimum time of") % current_user.name %> - <%= _("%d hour(s)") % env_organization_ratings_config.cooldown %> - <%= _("between each evaluation.") %> - - <%= render :partial => 'shared/rating_button', :locals => { :disabled => true } %> -
- <% end %> - + <%= render :partial => 'shared/rating_button', :locals => { :disabled => true } %> +
+ <% end %> -
diff --git a/plugins/organization_ratings/views/shared/_user_rating_container.html.erb b/plugins/organization_ratings/views/shared/_user_rating_container.html.erb index 0123818..4889579 100644 --- a/plugins/organization_ratings/views/shared/_user_rating_container.html.erb +++ b/plugins/organization_ratings/views/shared/_user_rating_container.html.erb @@ -25,9 +25,13 @@
- <%= user_rate.comment.nil? ? _("No comment") : user_rate.comment.body %> + <% if user_rate.display_moderation_message(user) %> +

<%= _("Report waiting for approval") %>

+ <% end %> + <% if user_rate.comment.present? %> +

<%= user_rate.comment.body %>

+ <% end %>
- - <%= @plugins.dispatch(:organization_ratings_plugin_extra_fields_show_data, user_rate).collect { |content| instance_exec(&content) }.join("") %> + <%= @plugins.dispatch(:organization_ratings_plugin_container_extra_fields, user_rate).collect { |content| instance_exec(&content) }.join("") %>
diff --git a/plugins/organization_ratings/views/tasks/_create_organization_rating_comment_accept_details.html.erb b/plugins/organization_ratings/views/tasks/_create_organization_rating_comment_accept_details.html.erb index 0632597..aa01c06 100644 --- a/plugins/organization_ratings/views/tasks/_create_organization_rating_comment_accept_details.html.erb +++ b/plugins/organization_ratings/views/tasks/_create_organization_rating_comment_accept_details.html.erb @@ -1,4 +1,19 @@
- <%= _("Comment:")%> - <%= "\"#{task.body}\""%> + <% rating = OrganizationRating.find(task.organization_rating_id) %> + <%= @plugins.dispatch(:organization_ratings_plugin_task_extra_fields, rating).collect{ |content| instance_exec(&content) }.join("") %> +
+ <%= _("Description:")%> +

<%= "\"#{task.body}\""%>

+
+ + <%= _("* The rating score is not moderated.")%> +
+ <% (1..5).each do |star_number| %> + <% if star_number <= rating.value %> +
+ <% else %> +
+ <% end %> + <% end %> +
diff --git a/public/stylesheets/tasks.scss b/public/stylesheets/tasks.scss index dd25798..81e1654 100644 --- a/public/stylesheets/tasks.scss +++ b/public/stylesheets/tasks.scss @@ -27,6 +27,7 @@ div.pending-tasks { } .task_box { + overflow: hidden; position: relative; border: 1px solid #888; -moz-border-radius: 10px; -- libgit2 0.21.2