Commit ff47927a7e1303aae2da1cacc72483b061d4654c
1 parent
adc4f4fd
Exists in
master
and in
29 other branches
Added comment_classification plugin
Status and Labels for comments http://noosfero.org/Development/CommentClassificationPlugin
Showing
35 changed files
with
674 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +README - Comment Classification Plugin | ||
2 | +====================================== | ||
3 | + | ||
4 | +This plugin creates the structure for classifying the comments. The | ||
5 | +initial idea of this plugin is to support the management of public | ||
6 | +consulting, but it can be used in different contexts. | ||
7 | +For now, two kind of classification will be available: | ||
8 | + | ||
9 | + * Label: when creating a comment, the user identify the kind of it by | ||
10 | +choosing the label of the comment. Example: "Suggestion", | ||
11 | +"Disagreement"... | ||
12 | + * Status: users with permission can include a Status for a comment. | ||
13 | +Example: "Merged", "Unmerged" |
plugins/comment_classification/controllers/admin/comment_classification_plugin_labels_controller.rb
0 → 100644
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +class CommentClassificationPluginLabelsController < AdminController | ||
2 | + append_view_path File.join(File.dirname(__FILE__) + '/../../views') | ||
3 | + | ||
4 | + def index | ||
5 | +# @labels = @environment.labels | ||
6 | + @labels = CommentClassificationPlugin::Label.all | ||
7 | + end | ||
8 | + | ||
9 | + def create | ||
10 | + @label = CommentClassificationPlugin::Label.new(params[:label]) | ||
11 | + @colors = CommentClassificationPlugin::Label::COLORS | ||
12 | + if request.post? | ||
13 | + begin | ||
14 | + @label.owner = environment | ||
15 | + @label.save! | ||
16 | + session[:notice] = _('Label created') | ||
17 | + redirect_to :action => 'index' | ||
18 | + rescue | ||
19 | + session[:notice] = _('Label could not be created') | ||
20 | + end | ||
21 | + end | ||
22 | + end | ||
23 | + | ||
24 | + def edit | ||
25 | +# @labels = @environment.labels.find(params[:id]) | ||
26 | + @label = CommentClassificationPlugin::Label.find(params[:id]) | ||
27 | + @colors = CommentClassificationPlugin::Label::COLORS | ||
28 | + if request.post? | ||
29 | + begin | ||
30 | + @label.update_attributes!(params[:label]) | ||
31 | + session[:notice] = _('Label updated') | ||
32 | + redirect_to :action => :index | ||
33 | + rescue | ||
34 | + session[:notice] = _('Failed to edit label') | ||
35 | + end | ||
36 | + end | ||
37 | + end | ||
38 | + | ||
39 | + def remove | ||
40 | +# @label = environment.labels.find(params[:label]) | ||
41 | + @label = CommentClassificationPlugin::Label.find(params[:id]) | ||
42 | + if request.post? | ||
43 | + begin | ||
44 | + @label.destroy | ||
45 | + session[:notice] = _('Label removed') | ||
46 | + rescue | ||
47 | + session[:notice] = _('Label could not be removed') | ||
48 | + end | ||
49 | + else | ||
50 | + session[:notice] = _('Label could not be removed') | ||
51 | + end | ||
52 | + redirect_to :action => 'index' | ||
53 | + end | ||
54 | + | ||
55 | +end |
plugins/comment_classification/controllers/admin/comment_classification_plugin_status_controller.rb
0 → 100644
@@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
1 | +class CommentClassificationPluginStatusController < AdminController | ||
2 | + append_view_path File.join(File.dirname(__FILE__) + '/../../views') | ||
3 | + | ||
4 | + def index | ||
5 | +# @labels = @environment.labels | ||
6 | + @status = CommentClassificationPlugin::Status.all | ||
7 | + end | ||
8 | + | ||
9 | + def create | ||
10 | + @status = CommentClassificationPlugin::Status.new(params[:status]) | ||
11 | + if request.post? | ||
12 | + begin | ||
13 | + @status.owner = environment | ||
14 | + @status.save! | ||
15 | + session[:notice] = _('Status created') | ||
16 | + redirect_to :action => 'index' | ||
17 | + rescue | ||
18 | + session[:notice] = _('Status could not be created') | ||
19 | + end | ||
20 | + end | ||
21 | + end | ||
22 | + | ||
23 | + def edit | ||
24 | +# @labels = @environment.labels.find(params[:id]) | ||
25 | + @status = CommentClassificationPlugin::Status.find(params[:id]) | ||
26 | + if request.post? | ||
27 | + begin | ||
28 | + @status.update_attributes!(params[:status]) | ||
29 | + session[:notice] = _('Status updated') | ||
30 | + redirect_to :action => :index | ||
31 | + rescue | ||
32 | + session[:notice] = _('Failed to edit status') | ||
33 | + end | ||
34 | + end | ||
35 | + end | ||
36 | + | ||
37 | + def remove | ||
38 | +# @label = environment.labels.find(params[:label]) | ||
39 | + @status = CommentClassificationPlugin::Status.find(params[:id]) | ||
40 | + if request.post? | ||
41 | + begin | ||
42 | + @status.destroy | ||
43 | + session[:notice] = _('Status removed') | ||
44 | + rescue | ||
45 | + session[:notice] = _('Status could not be removed') | ||
46 | + end | ||
47 | + else | ||
48 | + session[:notice] = _('Status could not be removed') | ||
49 | + end | ||
50 | + redirect_to :action => 'index' | ||
51 | + end | ||
52 | + | ||
53 | +end |
plugins/comment_classification/controllers/comment_classification_plugin_admin_controller.rb
0 → 100644
plugins/comment_classification/controllers/comment_classification_plugin_myprofile_controller.rb
0 → 100644
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +class CommentClassificationPluginMyprofileController < MyProfileController | ||
2 | + append_view_path File.join(File.dirname(__FILE__) + '/../views') | ||
3 | + | ||
4 | + before_filter :organizations_only | ||
5 | + protect 'moderate_comments', :profile | ||
6 | + | ||
7 | + def index | ||
8 | + @comments = Comment.all | ||
9 | + end | ||
10 | + | ||
11 | + def add_status | ||
12 | + @comment = Comment.find(params[:id]) | ||
13 | + @statuses = CommentClassificationPlugin::Status.enabled | ||
14 | + @status = CommentClassificationPlugin::CommentStatusUser.new(:profile => user, :comment => @comment) | ||
15 | + if request.post? && params[:status] | ||
16 | + @status.update_attributes(params[:status]) | ||
17 | + @status.save | ||
18 | + end | ||
19 | + end | ||
20 | + | ||
21 | + private | ||
22 | + | ||
23 | + def organizations_only | ||
24 | + render_not_found if !profile.organization? | ||
25 | + end | ||
26 | +end |
plugins/comment_classification/db/migrate/20130822043033_create_comments_labels.rb
0 → 100644
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +class CreateCommentsLabels < ActiveRecord::Migration | ||
2 | + def self.up | ||
3 | + create_table :comment_classification_plugin_labels do |t| | ||
4 | + t.string :name | ||
5 | + t.string :color | ||
6 | + t.boolean :enabled, :default => true | ||
7 | + t.references :owner, :polymorphic => true | ||
8 | + | ||
9 | + t.timestamps | ||
10 | + end | ||
11 | + end | ||
12 | + | ||
13 | + def self.down | ||
14 | + drop_table :comment_classification_plugin_labels | ||
15 | + end | ||
16 | +end |
plugins/comment_classification/db/migrate/20130822075623_create_comment_label_user.rb
0 → 100644
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +class CreateCommentLabelUser < ActiveRecord::Migration | ||
2 | + def self.up | ||
3 | + create_table :comment_classification_plugin_comment_label_user do |t| | ||
4 | + t.references :profile | ||
5 | + t.references :comment | ||
6 | + t.references :label | ||
7 | + | ||
8 | + t.timestamps | ||
9 | + end | ||
10 | + | ||
11 | + end | ||
12 | + | ||
13 | + def self.down | ||
14 | + drop_table :comment_classification_plugin_comment_label_user | ||
15 | + end | ||
16 | +end |
plugins/comment_classification/db/migrate/20130829130226_create_comment_status.rb
0 → 100644
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +class CreateCommentStatus < ActiveRecord::Migration | ||
2 | + def self.up | ||
3 | + create_table :comment_classification_plugin_statuses do |t| | ||
4 | + t.string :name | ||
5 | + t.boolean :enabled, :default => true | ||
6 | + t.boolean :enable_reason, :default => true | ||
7 | + t.references :owner, :polymorphic => true | ||
8 | + t.timestamps | ||
9 | + end | ||
10 | + | ||
11 | + end | ||
12 | + | ||
13 | + def self.down | ||
14 | + drop_table :comment_classification_plugin_statuses | ||
15 | + end | ||
16 | +end |
plugins/comment_classification/db/migrate/20130829144037_create_comment_status_user.rb
0 → 100644
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +class CreateCommentStatusUser < ActiveRecord::Migration | ||
2 | + def self.up | ||
3 | + create_table :comment_classification_plugin_comment_status_user do |t| | ||
4 | + t.references :profile | ||
5 | + t.references :comment | ||
6 | + t.references :status | ||
7 | + t.text :reason | ||
8 | + | ||
9 | + t.timestamps | ||
10 | + end | ||
11 | + end | ||
12 | + | ||
13 | + def self.down | ||
14 | + drop_table :comment_classification_plugin_comment_status_user | ||
15 | + end | ||
16 | +end |
@@ -0,0 +1,64 @@ | @@ -0,0 +1,64 @@ | ||
1 | +Feature: | ||
2 | + As a user | ||
3 | + I want to add label for comments | ||
4 | + | ||
5 | +Background: | ||
6 | + Given the following users | ||
7 | + | login | name | | ||
8 | + | joaosilva | Joao Silva | | ||
9 | + | mariasilva | Maria Silva | | ||
10 | + And the following communities | ||
11 | + | identifier | name | | ||
12 | + | sample-community | Sample Community | | ||
13 | + And the following articles | ||
14 | + | owner | name | body | | ||
15 | + | sample-community | Article to comment | First post | | ||
16 | + And CommentClassificationPlugin is enabled | ||
17 | + And "Maria Silva" is a member of "Sample Community" | ||
18 | + And "Joao Silva" is admin of "Sample Community" | ||
19 | + And I am logged in as "joaosilva" | ||
20 | + | ||
21 | + @selenium | ||
22 | + Scenario: dont display labels if admin did not configure status | ||
23 | + Given I am on article "Article to comment" | ||
24 | + And I follow "Post a comment" | ||
25 | + Then I should not see "Label" within "#page-comment-form" | ||
26 | + | ||
27 | + Scenario: admin configure labels | ||
28 | + Given I am logged in as "admin_user" | ||
29 | + And I am on the environment control panel | ||
30 | + And I follow "Plugins" | ||
31 | + And I follow "Configuration" | ||
32 | + And I follow "Manage Labels" | ||
33 | + Then I should see "no label registered yet" within "#comment-classification-labels" | ||
34 | + When I follow "Add a new label" | ||
35 | + And I fill in "Name" with "Question" | ||
36 | + And I check "Enable this label" | ||
37 | + And I press "Save" | ||
38 | + Then I should see "Question" within "#comment-classification-labels" | ||
39 | + | ||
40 | + @selenium | ||
41 | + Scenario: save label for comment | ||
42 | + Given the following labels | ||
43 | + | owner | name | enabled | | ||
44 | + | environment | Addition | true | | ||
45 | + And I go to article "Article to comment" | ||
46 | + And I follow "Post a comment" | ||
47 | + And I fill in "Enter your comment" with "Hey ho, let's go!" | ||
48 | + Then I select "Addition" from "comment_label_id" | ||
49 | + And I press "Post comment" | ||
50 | + Then I should see "Addition" within ".comment-details" | ||
51 | + | ||
52 | + @selenium | ||
53 | + Scenario: users without permission should not edit the labels | ||
54 | + Given the following labels | ||
55 | + | owner | name | enabled | | ||
56 | + | environment | Addition | true | | ||
57 | + And I go to article "Article to comment" | ||
58 | + And I follow "Post a comment" | ||
59 | + Then I should see "Label" within "#page-comment-form" | ||
60 | + And I should see "Addition" within "#comment_label_id" | ||
61 | + When I am not logged in | ||
62 | + And I am on article "Article to comment" | ||
63 | + And I follow "Post a comment" | ||
64 | + Then I should not see "Label" within "#page-comment-form" |
@@ -0,0 +1,67 @@ | @@ -0,0 +1,67 @@ | ||
1 | +Feature: | ||
2 | + As a user | ||
3 | + I want to add status for comments | ||
4 | + | ||
5 | +Background: | ||
6 | + Given the following users | ||
7 | + | login | name | | ||
8 | + | joaosilva | Joao Silva | | ||
9 | + | mariasilva | Maria Silva | | ||
10 | + And the following communities | ||
11 | + | identifier | name | | ||
12 | + | sample-community | Sample Community | | ||
13 | + And the following articles | ||
14 | + | owner | name | body | | ||
15 | + | sample-community | Article to comment | First post | | ||
16 | + And the following comments | ||
17 | + | article | author | body | | ||
18 | + | Article to comment | mariasilva | great post! | | ||
19 | + And CommentClassificationPlugin is enabled | ||
20 | + And "Maria Silva" is a member of "Sample Community" | ||
21 | + And "Joao Silva" is admin of "Sample Community" | ||
22 | + And I am logged in as "joaosilva" | ||
23 | + | ||
24 | + Scenario: dont display to add status if not an organization | ||
25 | + Given the following articles | ||
26 | + | owner | name | body | | ||
27 | + | joaosilva | Article on a person profile | First post | | ||
28 | + And the following comments | ||
29 | + | article | author | body | | ||
30 | + | Article on a person profile | mariasilva | great post! | | ||
31 | + Given I am on article "Article on a person profile" | ||
32 | + Then I should see "great post!" within ".comment-details" | ||
33 | + And I should not see "Status" within ".comment-details" | ||
34 | + | ||
35 | + Scenario: dont display to add status if admin did not configure status | ||
36 | + Given I am on article "Article to comment" | ||
37 | + Then I should see "great post!" within ".comment-details" | ||
38 | + And I should not see "Status" within ".comment-details" | ||
39 | + | ||
40 | + Scenario: admin configure status | ||
41 | + Given I am logged in as "admin_user" | ||
42 | + And I am on the environment control panel | ||
43 | + And I follow "Plugins" | ||
44 | + And I follow "Configuration" | ||
45 | + And I follow "Manage Status" | ||
46 | + Then I should see "no status registered yet" within "#comment-classification-status" | ||
47 | + When I follow "Add a new status" | ||
48 | + And I fill in "Name" with "Merged" | ||
49 | + And I check "Enable this status" | ||
50 | + And I press "Save" | ||
51 | + Then I should see "Merged" within "#comment-classification-status" | ||
52 | + | ||
53 | + Scenario: save status for comment | ||
54 | + Given the following status | ||
55 | + | owner | name | enabled | | ||
56 | + | environment | Merged | true | | ||
57 | + And I go to article "Article to comment" | ||
58 | + And I follow "Status" | ||
59 | + Then I select "Merged" from "status_status_id" | ||
60 | + And I press "Save" | ||
61 | + Then I should see "added the status Merged" within "#comment-classification-status-list" | ||
62 | + | ||
63 | + Scenario: dont display to add status if user not allowed | ||
64 | + Given I am logged in as "mariasilva" | ||
65 | + When I go to article "Article to comment" | ||
66 | + Then I should see "great post!" within ".comment-details" | ||
67 | + And I should not see "Status" within ".comment-details" |
plugins/comment_classification/features/step_definitions/plugin_steps.rb
0 → 100644
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +Given /^CommentClassificationPlugin is enabled$/ do | ||
2 | + Given %{I am logged in as admin} | ||
3 | + And %{I am on the environment control panel} | ||
4 | + And %{I follow "Plugins"} | ||
5 | + And %{I check "Comment Classification"} | ||
6 | + And %{I press "Save changes"} | ||
7 | + Environment.default.enabled_plugins.should include("CommentClassificationPlugin") | ||
8 | +end | ||
9 | + | ||
10 | +Given /^the following labels$/ do |table| | ||
11 | + table.hashes.map{|item| item.dup}.each do |item| | ||
12 | + owner_type = item.delete('owner') | ||
13 | + owner = owner_type == 'environment' ? Environment.default : Profile[owner_type] | ||
14 | + CommentClassificationPlugin::Label.create!(item) | ||
15 | + end | ||
16 | +end | ||
17 | + | ||
18 | +Given /^the following status$/ do |table| | ||
19 | + table.hashes.map{|item| item.dup}.each do |item| | ||
20 | + owner_type = item.delete('owner') | ||
21 | + owner = owner_type == 'environment' ? Environment.default : Profile[owner_type] | ||
22 | + CommentClassificationPlugin::Status.create!(item) | ||
23 | + end | ||
24 | +end |
plugins/comment_classification/lib/comment_classification_plugin.rb
0 → 100644
@@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
1 | +require 'ext/environment' | ||
2 | +require 'ext/comment' | ||
3 | + | ||
4 | +class CommentClassificationPlugin < Noosfero::Plugin | ||
5 | + | ||
6 | + def self.plugin_name | ||
7 | + "Comment Classification" | ||
8 | + end | ||
9 | + | ||
10 | + def self.plugin_description | ||
11 | + _("A plugin that allow classification of comments.") | ||
12 | + end | ||
13 | + | ||
14 | +#TODO Each organization can add its own status and labels | ||
15 | +# def control_panel_buttons | ||
16 | +# if context.profile.organization? | ||
17 | +# { :title => _('Manage comment classification'), :icon => 'comment_classification', :url => {:controller => 'comment_classification_plugin_myprofile'} } | ||
18 | +# end | ||
19 | +# end | ||
20 | + | ||
21 | + def comment_form_extra_contents(args) | ||
22 | + comment = args[:comment] | ||
23 | + lambda { | ||
24 | + render :file => 'comment/comments_labels_select.rhtml', :locals => {:comment => comment } | ||
25 | + } | ||
26 | + end | ||
27 | + | ||
28 | + def comment_extra_contents(args) | ||
29 | + comment = args[:comment] | ||
30 | + lambda { | ||
31 | + render :file => 'comment/comment_extra.rhtml', :locals => {:comment => comment} | ||
32 | + } | ||
33 | + end | ||
34 | + | ||
35 | + def process_extra_comment_params(args) | ||
36 | + comment = Comment.find args[0] | ||
37 | + label_id = args[1][:comment_label_id] | ||
38 | + if label_id.blank? | ||
39 | + if !CommentClassificationPlugin::CommentLabelUser.find_by_comment_id(comment.id).nil? | ||
40 | + CommentClassificationPlugin::CommentLabelUser.find_by_comment_id(comment.id).destroy | ||
41 | + end | ||
42 | + else | ||
43 | + label = CommentClassificationPlugin::Label.find label_id | ||
44 | + relation = CommentClassificationPlugin::CommentLabelUser.new(:profile => comment.author, :comment => comment, :label => label ) | ||
45 | + relation.save | ||
46 | + end | ||
47 | + end | ||
48 | + | ||
49 | + def js_files | ||
50 | + 'comment_classification.js' | ||
51 | + end | ||
52 | + | ||
53 | + def stylesheet? | ||
54 | + true | ||
55 | + end | ||
56 | + | ||
57 | +end |
plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb
0 → 100644
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +class CommentClassificationPlugin::CommentLabelUser < Noosfero::Plugin::ActiveRecord | ||
2 | + set_table_name :comment_classification_plugin_comment_label_user | ||
3 | + | ||
4 | + belongs_to :profile | ||
5 | + belongs_to :comment | ||
6 | + belongs_to :label, :class_name => 'CommentClassificationPlugin::Label' | ||
7 | + | ||
8 | + validates_presence_of :profile | ||
9 | + validates_presence_of :comment | ||
10 | + validates_presence_of :label | ||
11 | +end |
plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb
0 → 100644
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +class CommentClassificationPlugin::CommentStatusUser < Noosfero::Plugin::ActiveRecord | ||
2 | + set_table_name :comment_classification_plugin_comment_status_user | ||
3 | + | ||
4 | + belongs_to :profile | ||
5 | + belongs_to :comment | ||
6 | + belongs_to :status, :class_name => 'CommentClassificationPlugin::Status' | ||
7 | + | ||
8 | + validates_presence_of :profile | ||
9 | + validates_presence_of :comment | ||
10 | + validates_presence_of :status | ||
11 | +end |
plugins/comment_classification/lib/comment_classification_plugin/label.rb
0 → 100644
@@ -0,0 +1,10 @@ | @@ -0,0 +1,10 @@ | ||
1 | +class CommentClassificationPlugin::Label < Noosfero::Plugin::ActiveRecord | ||
2 | + | ||
3 | + belongs_to :owner, :polymorphic => true | ||
4 | + | ||
5 | + validates_presence_of :name | ||
6 | + | ||
7 | + named_scope :enabled, :conditions => { :enabled => true } | ||
8 | + | ||
9 | + COLORS = ['red', 'green', 'yellow', 'gray', 'blue'] | ||
10 | +end |
plugins/comment_classification/lib/comment_classification_plugin/status.rb
0 → 100644
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +require_dependency 'comment' | ||
2 | +require 'comment_classification_plugin.rb' | ||
3 | +require 'comment_classification_plugin/label.rb' | ||
4 | + | ||
5 | +class Comment | ||
6 | + | ||
7 | + has_one :comment_classification_plugin_comment_label_user, :class_name => 'CommentClassificationPlugin::CommentLabelUser' | ||
8 | + has_one :label, :through => :comment_classification_plugin_comment_label_user, :foreign_key => 'label_id' | ||
9 | + | ||
10 | + has_many :comment_classification_plugin_comment_status_users, :class_name => 'CommentClassificationPlugin::CommentStatusUser' | ||
11 | + has_many :statuses, :through => :comment_classification_plugin_comment_status_users, :foreign_key => 'status_id' | ||
12 | + | ||
13 | +end |
plugins/comment_classification/public/images/comment-classification.png
0 → 100644
4.15 KB
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +.controller-profile_editor .control-panel a.control-panel-comment_classification { | ||
2 | + background-image: url(images/comment-classification.png); | ||
3 | +} | ||
4 | + | ||
5 | +#content .comment-classification-options .label-name { | ||
6 | + font-style: italic; | ||
7 | +} | ||
8 | + | ||
9 | +#content .comment-classification-options a.button { | ||
10 | + background-color: transparent; | ||
11 | + border: none; | ||
12 | +} |
plugins/comment_classification/views/comment/comment_extra.rhtml
0 → 100644
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +<div class='comment-classification-options'> | ||
2 | + | ||
3 | + <% unless comment.label.nil? %> | ||
4 | + <p class='label-name' style='color:<%= comment.label.color %>'> | ||
5 | + <%= comment.label.name %> | ||
6 | + </p> | ||
7 | + <% end %> | ||
8 | + | ||
9 | + <% statuses = CommentClassificationPlugin::Status.enabled %> | ||
10 | + <% if profile.organization? && user && user.has_permission?(:moderate_comments, profile) && !statuses.empty? %> | ||
11 | + <div class='comment-classification-status'> | ||
12 | + <%= link_to(_('Status'), :profile => profile.identifier, :controller => :comment_classification_plugin_myprofile, :action => :add_status, :id => comment.id) | ||
13 | + %> | ||
14 | + </div> | ||
15 | + <% end %> | ||
16 | + | ||
17 | +</div> |
plugins/comment_classification/views/comment/comments_labels_select.rhtml
0 → 100644
@@ -0,0 +1,4 @@ | @@ -0,0 +1,4 @@ | ||
1 | +<% labels = CommentClassificationPlugin::Label.enabled %> | ||
2 | +<% if logged_in? && user.has_permission?(:moderate_comments, profile) && !labels.empty? %> | ||
3 | + <%= labelled_form_field(_('Label'), select_tag('comment_label_id', options_for_select( [[_('[Select ...]'), nil]] + labels.map{|l|[l.name,l.id]}, @comment.label.nil? ? '' : @comment.label.id))) %> | ||
4 | +<% end %> |
plugins/comment_classification/views/comment_classification_plugin_admin/index.rhtml
0 → 100644
@@ -0,0 +1,6 @@ | @@ -0,0 +1,6 @@ | ||
1 | +<h1><%= _('Comments classification options')%></h1> | ||
2 | + | ||
3 | +<ul> | ||
4 | + <li><%= link_to _('Manage Labels'), :controller => 'comment_classification_plugin_labels' %></li> | ||
5 | + <li><%= link_to _('Manage Status'), :controller => 'comment_classification_plugin_status' %></li> | ||
6 | +</ul> |
plugins/comment_classification/views/comment_classification_plugin_labels/_form.rhtml
0 → 100644
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +<%= error_messages_for :label %> | ||
2 | + | ||
3 | +<% form_for :label, @label do |f| %> | ||
4 | + <%= required_fields_message %> | ||
5 | + | ||
6 | + <%= required labelled_form_field(_('Name'), f.text_field(:name)) %> | ||
7 | + <%= labelled_form_field(_('Color'), f.select(:color, @colors.map{|s|[s.capitalize,s]})) %> | ||
8 | + <%= labelled_form_field(f.check_box(:enabled) + _('Enable this label?'),'') %> | ||
9 | + | ||
10 | + <% button_bar do %> | ||
11 | + <%= submit_button('save', _('Save'), :cancel => {:action => 'index'} ) %> | ||
12 | + <% end %> | ||
13 | +<% end %> |
plugins/comment_classification/views/comment_classification_plugin_labels/create.rhtml
0 → 100644
plugins/comment_classification/views/comment_classification_plugin_labels/edit.rhtml
0 → 100644
plugins/comment_classification/views/comment_classification_plugin_labels/index.rhtml
0 → 100644
@@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
1 | +<h1><%= _("Manage comments labels") %></h1> | ||
2 | + | ||
3 | +<div id='comment-classification-labels'> | ||
4 | + <% if @labels.empty? %> | ||
5 | + <%= _('(no label registered yet)') %> | ||
6 | + <% else %> | ||
7 | + <table> | ||
8 | + <tr> | ||
9 | + <th><%= _('Label') %></th> | ||
10 | + <th><%= _('Color') %></th> | ||
11 | + <th><%= _('Enabled') %></th> | ||
12 | + <th><%= _('Actions') %></th> | ||
13 | + </tr> | ||
14 | + <% @labels.each do |label| %> | ||
15 | + <tr> | ||
16 | + <td><%= label.name %></td> | ||
17 | + <td><%= label.color %></td> | ||
18 | + <td><%= label.enabled %></td> | ||
19 | + <td> | ||
20 | + <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => label} %> | ||
21 | + <%= button_without_text :delete, _('Remove'), {:action => 'destroy', :id => label}, :confirm => _('Are you sure you want to remove this label?') %> | ||
22 | + </td> | ||
23 | + </tr> | ||
24 | + <% end %> | ||
25 | + </table> | ||
26 | + <% end %> | ||
27 | + | ||
28 | + <% button_bar do %> | ||
29 | + <%= button(:add, _('Add a new label'), :action => 'create')%> | ||
30 | + <%= button :back, _('Back to admin panel'), :controller => 'admin_panel' %> | ||
31 | + <% end %> | ||
32 | +</div> |
plugins/comment_classification/views/comment_classification_plugin_myprofile/_status_form.html.erb
0 → 100644
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +<%= error_messages_for :status %> | ||
2 | + | ||
3 | +<% form_for :status, @status do |f| %> | ||
4 | + <%= required_fields_message %> | ||
5 | + | ||
6 | + <%= labelled_form_field(_('Status'), f.select(:status_id, @statuses.map{|s|[s.name,s.id]})) %> | ||
7 | + <%= labelled_form_field(_('Reason:'), f.text_area(:reason, :rows => 5)) %> | ||
8 | + | ||
9 | + <% button_bar do %> | ||
10 | + <%= submit_button('save', _('Save') ) %> | ||
11 | + <% end %> | ||
12 | +<% end %> |
plugins/comment_classification/views/comment_classification_plugin_myprofile/add_status.html.erb
0 → 100644
@@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
1 | +<h1><%= _('Status for comment') %></h1> | ||
2 | + | ||
3 | +<div id='comment-classification-status-list'> | ||
4 | + <% unless @comment.title.blank? %> | ||
5 | + <div class='comment-title'><%= _("Title: %s") % @comment.title %></div> | ||
6 | + <% end %> | ||
7 | + | ||
8 | + <b><%= _('Body:') %></b> | ||
9 | + <p><%= @comment.body %></p> | ||
10 | + | ||
11 | + <h2> <%= _("History") %> </h2> | ||
12 | + | ||
13 | + <ul> | ||
14 | + <% @comment.comment_classification_plugin_comment_status_users.each do |relation| %> | ||
15 | + <li> | ||
16 | + <%= _("<i>%{user}</i> added the status <i>%{status_name}</i> at <i>%{created_at}</i>.") % { :user => relation.profile.name, :status_name => relation.status.name, :created_at => time_ago_as_sentence(relation.created_at)} %> | ||
17 | + <% unless relation.reason.blank? %> | ||
18 | + <p><%= _("<i>Reason:</i> %s") % relation.reason %></p> | ||
19 | + <% end %> | ||
20 | + </li> | ||
21 | + <% end %> | ||
22 | + </ul> | ||
23 | + | ||
24 | + <h2> <%= _("Add a new status") %> </h2> | ||
25 | + | ||
26 | + <%= render :partial => 'status_form' %> | ||
27 | +</div> |
plugins/comment_classification/views/comment_classification_plugin_myprofile/index.html.erb
0 → 100644
plugins/comment_classification/views/comment_classification_plugin_status/_form.rhtml
0 → 100644
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +<%= error_messages_for :status %> | ||
2 | + | ||
3 | +<% form_for :status, @status do |f| %> | ||
4 | + <%= required_fields_message %> | ||
5 | + | ||
6 | + <%= required labelled_form_field(_('Name'), f.text_field(:name)) %> | ||
7 | + <%= labelled_form_field(f.check_box(:enabled) + _('Enable this status?'),'') %> | ||
8 | + <%#= labelled_form_field(f.check_box(:enable_reason) + _('This status allows reason?'),'') %> | ||
9 | + | ||
10 | + <% button_bar do %> | ||
11 | + <%= submit_button('save', _('Save'), :cancel => {:action => 'index'} ) %> | ||
12 | + <% end %> | ||
13 | +<% end %> |
plugins/comment_classification/views/comment_classification_plugin_status/create.rhtml
0 → 100644
plugins/comment_classification/views/comment_classification_plugin_status/edit.rhtml
0 → 100644
plugins/comment_classification/views/comment_classification_plugin_status/index.rhtml
0 → 100644
@@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
1 | +<h1> <%= _("Manage comments status") %></h1> | ||
2 | + | ||
3 | +<div id='comment-classification-status'> | ||
4 | + <% if @status.empty? %> | ||
5 | + <%= _('(no status registered yet)') %> | ||
6 | + <% else %> | ||
7 | + <table> | ||
8 | + <tr> | ||
9 | + <th><%= _('Status') %></th> | ||
10 | + <th><%= _('Enabled') %></th> | ||
11 | + <th><%= _('Reason enabled?') %></th> | ||
12 | + <th><%= _('Actions') %></th> | ||
13 | + </tr> | ||
14 | + <% @status.each do |st| %> | ||
15 | + <tr> | ||
16 | + <td><%= st.name %></td> | ||
17 | + <td><%= st.enabled %></td> | ||
18 | + <td><%= st.enable_reason %></td> | ||
19 | + <td> | ||
20 | + <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => st} %> | ||
21 | + <%= button_without_text :delete, _('Remove'), {:action => 'destroy', :id => st}, :confirm => _('Are you sure you want to remove this status?') %> | ||
22 | + </td> | ||
23 | + </tr> | ||
24 | + <% end %> | ||
25 | + </table> | ||
26 | + <% end %> | ||
27 | + | ||
28 | + <% button_bar do %> | ||
29 | + <%= button(:add, _('Add a new status'), :action => 'create')%> | ||
30 | + <%= button :back, _('Back to admin panel'), :controller => 'admin_panel' %> | ||
31 | + <% end %> | ||
32 | +</div> |