Commit e6fcb8a81787a2de5b57f08c63a03d055ed42cf8
1 parent
e4fe2983
Exists in
communities_ratings_moderation
Moderation is a option in administration
Showing
6 changed files
with
37 additions
and
10 deletions
Show diff stats
plugins/communities_ratings/controllers/communities_ratings_plugin_profile_controller.rb
| @@ -47,15 +47,23 @@ class CommunitiesRatingsPluginProfileController < ProfileController | @@ -47,15 +47,23 @@ class CommunitiesRatingsPluginProfileController < ProfileController | ||
| 47 | community_rating.value = params[:community_rating_value] if params[:community_rating_value] | 47 | community_rating.value = params[:community_rating_value] if params[:community_rating_value] |
| 48 | 48 | ||
| 49 | if params[:comments] and (not params[:comments][:body].empty?) | 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 | end | 67 | end |
| 60 | 68 | ||
| 61 | if community_rating.save | 69 | if community_rating.save |
plugins/communities_ratings/db/migrate/20151010171028_add_communities_rating_config_to_environment.rb
0 → 100644
| @@ -0,0 +1,11 @@ | @@ -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 < Task | @@ -28,7 +28,7 @@ class CreateCommunityRatingComment < Task | ||
| 28 | end | 28 | end |
| 29 | 29 | ||
| 30 | def information | 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 | {:requestor => self.requestor.name, :source => self.source.name, :body => self.body } | 32 | {:requestor => self.requestor.name, :source => self.source.name, :body => self.body } |
| 33 | 33 | ||
| 34 | {:message => message} | 34 | {:message => message} |
plugins/communities_ratings/lib/ext/environment.rb
| 1 | require_dependency 'environment' | 1 | require_dependency 'environment' |
| 2 | 2 | ||
| 3 | Environment.class_eval do | 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 | COMMUNITIES_RATINGS_ORDER_OPTIONS = ["Most Recent", "Best Ratings"] | 6 | COMMUNITIES_RATINGS_ORDER_OPTIONS = ["Most Recent", "Best Ratings"] |
| 7 | COMMUNITIES_RATINGS_MINIMUM_RATING = 1 | 7 | COMMUNITIES_RATINGS_MINIMUM_RATING = 1 |
plugins/communities_ratings/style.css
| @@ -142,4 +142,8 @@ | @@ -142,4 +142,8 @@ | ||
| 142 | float: right; | 142 | float: right; |
| 143 | margin-top: 20px; | 143 | margin-top: 20px; |
| 144 | padding-right: 15px; | 144 | padding-right: 15px; |
| 145 | +} | ||
| 146 | + | ||
| 147 | +.task_information .comment { | ||
| 148 | + padding-left: 60px; | ||
| 145 | } | 149 | } |
| 146 | \ No newline at end of file | 150 | \ No newline at end of file |
plugins/communities_ratings/views/communities_ratings_plugin_admin/index.html.erb
| @@ -17,6 +17,10 @@ | @@ -17,6 +17,10 @@ | ||
| 17 | <td><%= check_box :environment, :communities_ratings_vote_once %></td> | 17 | <td><%= check_box :environment, :communities_ratings_vote_once %></td> |
| 18 | </tr> | 18 | </tr> |
| 19 | <tr> | 19 | <tr> |
| 20 | + <td><%= _('The comments are moderated') %></td> | ||
| 21 | + <td><%= check_box :environment, :communities_ratings_are_moderated %></td> | ||
| 22 | + </tr> | ||
| 23 | + <tr> | ||
| 20 | <td><%= _('Time cooldown between evaluations from the same user') %></td> | 24 | <td><%= _('Time cooldown between evaluations from the same user') %></td> |
| 21 | 25 | ||
| 22 | <% hours_options = {size: 1} %> | 26 | <% hours_options = {size: 1} %> |