Commit b33ee2224ebeec225e4ff8fbdec3190aee2fdead

Authored by Simiao Carvalho
Committed by Fabio Teixeira
1 parent ec1525ac

Moderation is a option in administration

plugins/communities_ratings/controllers/communities_ratings_plugin_profile_controller.rb
... ... @@ -47,15 +47,23 @@ class CommunitiesRatingsPluginProfileController < ProfileController
47 47 community_rating.value = params[:community_rating_value] if params[:community_rating_value]
48 48  
49 49 if params[:comments] and (not params[:comments][:body].empty?)
50   -
51   - create_comment = CreateCommunityRatingComment.create!(
52   - params[:comments].merge(
53   - :requestor => community_rating.person,
54   - :source => community_rating.community,
55   - :community_rating => community_rating,
56   - :environment => environment
  50 + if !environment.communities_ratings_are_moderated
  51 + comment = Comment.new(params[:comments])
  52 + comment.author = community_rating.person
  53 + comment.community = community_rating.community
  54 + comment.save
  55 +
  56 + community_rating.comment = comment
  57 + else
  58 + create_comment = CreateCommunityRatingComment.create!(
  59 + params[:comments].merge(
  60 + :requestor => community_rating.person,
  61 + :source => community_rating.community,
  62 + :community_rating => community_rating,
  63 + :environment => environment
  64 + )
57 65 )
58   - )
  66 + end
59 67 end
60 68  
61 69 if community_rating.save
... ...
plugins/communities_ratings/db/migrate/20151010171028_add_communities_rating_config_to_environment.rb 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +class AddCommunitiesRatingConfigToEnvironment < ActiveRecord::Migration
  2 +
  3 + def change
  4 + add_column :environments, :communities_ratings_cooldown, :integer, :default => 24
  5 + add_column :environments, :communities_ratings_default_rating, :integer, :default => 1
  6 + add_column :environments, :communities_ratings_order, :string, :default => "most recent"
  7 + add_column :environments, :communities_ratings_per_page, :integer, :default => 10
  8 + add_column :environments, :communities_ratings_vote_once, :boolean, :default => false
  9 + add_column :environments, :communities_ratings_are_moderated, :boolean, :default => true
  10 + end
  11 +end
... ...
plugins/communities_ratings/lib/create_community_rating_comment.rb
... ... @@ -28,7 +28,7 @@ class CreateCommunityRatingComment &lt; Task
28 28 end
29 29  
30 30 def information
31   - message = _("%{requestor} wants to create a comment in the \"%{source}\" community. \n\n\n Comment: \n\n \"%{body}\"") %
  31 + message = _("%{requestor} wants to create a comment in the \"%{source}\" community. <div class=\"comment\"> Comment: <br> \"%{body}\"</div>") %
32 32 {:requestor => self.requestor.name, :source => self.source.name, :body => self.body }
33 33  
34 34 {:message => message}
... ...
plugins/communities_ratings/lib/ext/environment.rb
1 1 require_dependency 'environment'
2 2  
3 3 Environment.class_eval do
4   - attr_accessible :communities_ratings_cooldown, :communities_ratings_default_rating, :communities_ratings_order, :communities_ratings_per_page, :communities_ratings_vote_once
  4 + attr_accessible :communities_ratings_cooldown, :communities_ratings_default_rating, :communities_ratings_order, :communities_ratings_per_page, :communities_ratings_vote_once, :communities_ratings_are_moderated
5 5  
6 6 COMMUNITIES_RATINGS_ORDER_OPTIONS = ["Most Recent", "Best Ratings"]
7 7 COMMUNITIES_RATINGS_MINIMUM_RATING = 1
... ...
plugins/communities_ratings/style.css
... ... @@ -189,4 +189,8 @@
189 189 float: right;
190 190 margin-top: 20px;
191 191 padding-right: 15px;
  192 +}
  193 +
  194 +.task_information .comment {
  195 + padding-left: 60px;
192 196 }
193 197 \ No newline at end of file
... ...
plugins/communities_ratings/views/communities_ratings_plugin_admin/index.html.erb
... ... @@ -17,6 +17,10 @@
17 17 <td><%= check_box :environment, :communities_ratings_vote_once %></td>
18 18 </tr>
19 19 <tr>
  20 + <td><%= _('The comments are moderated') %></td>
  21 + <td><%= check_box :environment, :communities_ratings_are_moderated %></td>
  22 + </tr>
  23 + <tr>
20 24 <td><%= _('Time cooldown between evaluations from the same user') %></td>
21 25  
22 26 <% hours_options = {size: 1} %>
... ...