diff --git a/plugins/comment_classification/features/step_definitions/plugin_steps.rb b/plugins/comment_classification/features/step_definitions/plugin_steps.rb index 6392885..93eb522 100644 --- a/plugins/comment_classification/features/step_definitions/plugin_steps.rb +++ b/plugins/comment_classification/features/step_definitions/plugin_steps.rb @@ -1,9 +1,9 @@ Given /^CommentClassificationPlugin is enabled$/ do - Given %{I am logged in as admin} - And %{I am on the environment control panel} - And %{I follow "Plugins"} - And %{I check "Comment Classification"} - And %{I press "Save changes"} + step %{I am logged in as admin} + step %{I am on the environment control panel} + step %{I follow "Plugins"} + step %{I check "Comment Classification"} + step %{I press "Save changes"} Environment.default.enabled_plugins.should include("CommentClassificationPlugin") end diff --git a/plugins/comment_classification/lib/comment_classification_plugin.rb b/plugins/comment_classification/lib/comment_classification_plugin.rb index 7546f3d..69c35eb 100644 --- a/plugins/comment_classification/lib/comment_classification_plugin.rb +++ b/plugins/comment_classification/lib/comment_classification_plugin.rb @@ -20,15 +20,15 @@ class CommentClassificationPlugin < Noosfero::Plugin def comment_form_extra_contents(args) comment = args[:comment] - lambda { - render :file => 'comment/comments_labels_select.rhtml', :locals => {:comment => comment } + proc { + render :file => 'comment/comments_labels_select', :locals => {:comment => comment } } end def comment_extra_contents(args) comment = args[:comment] - lambda { - render :file => 'comment/comment_extra.rhtml', :locals => {:comment => comment} + proc { + render :file => 'comment/comment_extra', :locals => {:comment => comment} } end @@ -46,10 +46,6 @@ class CommentClassificationPlugin < Noosfero::Plugin end end - def js_files - 'comment_classification.js' - end - def stylesheet? true end diff --git a/plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb b/plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb index c25f1ba..6a2ce1a 100644 --- a/plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb +++ b/plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb @@ -1,10 +1,12 @@ -class CommentClassificationPlugin::CommentLabelUser < Noosfero::Plugin::ActiveRecord +class CommentClassificationPlugin::CommentLabelUser < ActiveRecord::Base set_table_name :comment_classification_plugin_comment_label_user belongs_to :profile belongs_to :comment belongs_to :label, :class_name => 'CommentClassificationPlugin::Label' + attr_accessible :profile, :comment, :label + validates_presence_of :profile validates_presence_of :comment validates_presence_of :label diff --git a/plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb b/plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb index af2b9f1..9ca449a 100644 --- a/plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb +++ b/plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb @@ -1,10 +1,12 @@ -class CommentClassificationPlugin::CommentStatusUser < Noosfero::Plugin::ActiveRecord +class CommentClassificationPlugin::CommentStatusUser < ActiveRecord::Base set_table_name :comment_classification_plugin_comment_status_user belongs_to :profile belongs_to :comment belongs_to :status, :class_name => 'CommentClassificationPlugin::Status' + attr_accessible :name, :enabled, :profile, :comment, :status_id, :reason + validates_presence_of :profile validates_presence_of :comment validates_presence_of :status diff --git a/plugins/comment_classification/lib/comment_classification_plugin/label.rb b/plugins/comment_classification/lib/comment_classification_plugin/label.rb index 27f7d32..36b9897 100644 --- a/plugins/comment_classification/lib/comment_classification_plugin/label.rb +++ b/plugins/comment_classification/lib/comment_classification_plugin/label.rb @@ -4,7 +4,9 @@ class CommentClassificationPlugin::Label < Noosfero::Plugin::ActiveRecord validates_presence_of :name - named_scope :enabled, :conditions => { :enabled => true } + scope :enabled, :conditions => { :enabled => true } + + attr_accessible :name, :enabled, :color COLORS = ['red', 'green', 'yellow', 'gray', 'blue'] end diff --git a/plugins/comment_classification/lib/comment_classification_plugin/status.rb b/plugins/comment_classification/lib/comment_classification_plugin/status.rb index f244152..e7769f9 100644 --- a/plugins/comment_classification/lib/comment_classification_plugin/status.rb +++ b/plugins/comment_classification/lib/comment_classification_plugin/status.rb @@ -2,7 +2,9 @@ class CommentClassificationPlugin::Status < Noosfero::Plugin::ActiveRecord belongs_to :owner, :polymorphic => true + attr_accessible :name, :enabled + validates_presence_of :name - named_scope :enabled, :conditions => { :enabled => true } + scope :enabled, :conditions => { :enabled => true } end diff --git a/plugins/comment_classification/views/comment/comment_extra.html.erb b/plugins/comment_classification/views/comment/comment_extra.html.erb new file mode 100644 index 0000000..7b8dee9 --- /dev/null +++ b/plugins/comment_classification/views/comment/comment_extra.html.erb @@ -0,0 +1,17 @@ +
+ + <% unless comment.label.nil? %> +

+ <%= comment.label.name %> +

+ <% end %> + + <% statuses = CommentClassificationPlugin::Status.enabled %> + <% if profile.organization? && user && user.has_permission?(:moderate_comments, profile) && !statuses.empty? %> +
+ <%= link_to(_('Status'), :profile => profile.identifier, :controller => :comment_classification_plugin_myprofile, :action => :add_status, :id => comment.id) + %> +
+ <% end %> + +
diff --git a/plugins/comment_classification/views/comment/comment_extra.rhtml b/plugins/comment_classification/views/comment/comment_extra.rhtml deleted file mode 100644 index 7b8dee9..0000000 --- a/plugins/comment_classification/views/comment/comment_extra.rhtml +++ /dev/null @@ -1,17 +0,0 @@ -
- - <% unless comment.label.nil? %> -

- <%= comment.label.name %> -

- <% end %> - - <% statuses = CommentClassificationPlugin::Status.enabled %> - <% if profile.organization? && user && user.has_permission?(:moderate_comments, profile) && !statuses.empty? %> -
- <%= link_to(_('Status'), :profile => profile.identifier, :controller => :comment_classification_plugin_myprofile, :action => :add_status, :id => comment.id) - %> -
- <% end %> - -
diff --git a/plugins/comment_classification/views/comment/comments_labels_select.html.erb b/plugins/comment_classification/views/comment/comments_labels_select.html.erb new file mode 100644 index 0000000..cf85aa7 --- /dev/null +++ b/plugins/comment_classification/views/comment/comments_labels_select.html.erb @@ -0,0 +1,4 @@ +<% labels = CommentClassificationPlugin::Label.enabled %> +<% if logged_in? && user.has_permission?(:moderate_comments, profile) && !labels.empty? %> + <%= 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))) %> +<% end %> diff --git a/plugins/comment_classification/views/comment/comments_labels_select.rhtml b/plugins/comment_classification/views/comment/comments_labels_select.rhtml deleted file mode 100644 index cf85aa7..0000000 --- a/plugins/comment_classification/views/comment/comments_labels_select.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -<% labels = CommentClassificationPlugin::Label.enabled %> -<% if logged_in? && user.has_permission?(:moderate_comments, profile) && !labels.empty? %> - <%= 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))) %> -<% end %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_admin/index.html.erb b/plugins/comment_classification/views/comment_classification_plugin_admin/index.html.erb new file mode 100644 index 0000000..516e3b1 --- /dev/null +++ b/plugins/comment_classification/views/comment_classification_plugin_admin/index.html.erb @@ -0,0 +1,6 @@ +

<%= _('Comments classification options')%>

+ + diff --git a/plugins/comment_classification/views/comment_classification_plugin_admin/index.rhtml b/plugins/comment_classification/views/comment_classification_plugin_admin/index.rhtml deleted file mode 100644 index 516e3b1..0000000 --- a/plugins/comment_classification/views/comment_classification_plugin_admin/index.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -

<%= _('Comments classification options')%>

- - diff --git a/plugins/comment_classification/views/comment_classification_plugin_labels/_form.html.erb b/plugins/comment_classification/views/comment_classification_plugin_labels/_form.html.erb new file mode 100644 index 0000000..35f377e --- /dev/null +++ b/plugins/comment_classification/views/comment_classification_plugin_labels/_form.html.erb @@ -0,0 +1,13 @@ +<%= error_messages_for :label %> + +<%= form_for :label do |f| %> + <%= required_fields_message %> + + <%= required labelled_form_field(_('Name'), f.text_field(:name)) %> + <%= labelled_form_field(_('Color'), f.select(:color, @colors.map{|s|[s.capitalize,s]})) %> + <%= labelled_form_field(f.check_box(:enabled) + _('Enable this label?'),'') %> + + <% button_bar do %> + <%= submit_button('save', _('Save'), :cancel => {:action => 'index'} ) %> + <% end %> +<% end %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_labels/_form.rhtml b/plugins/comment_classification/views/comment_classification_plugin_labels/_form.rhtml deleted file mode 100644 index 37ef5d8..0000000 --- a/plugins/comment_classification/views/comment_classification_plugin_labels/_form.rhtml +++ /dev/null @@ -1,13 +0,0 @@ -<%= error_messages_for :label %> - -<% form_for :label, @label do |f| %> - <%= required_fields_message %> - - <%= required labelled_form_field(_('Name'), f.text_field(:name)) %> - <%= labelled_form_field(_('Color'), f.select(:color, @colors.map{|s|[s.capitalize,s]})) %> - <%= labelled_form_field(f.check_box(:enabled) + _('Enable this label?'),'') %> - - <% button_bar do %> - <%= submit_button('save', _('Save'), :cancel => {:action => 'index'} ) %> - <% end %> -<% end %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_labels/create.html.erb b/plugins/comment_classification/views/comment_classification_plugin_labels/create.html.erb new file mode 100644 index 0000000..087850b --- /dev/null +++ b/plugins/comment_classification/views/comment_classification_plugin_labels/create.html.erb @@ -0,0 +1,3 @@ +

<%= _("Add a new label") %>

+ +<%= render :partial => 'form' %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_labels/create.rhtml b/plugins/comment_classification/views/comment_classification_plugin_labels/create.rhtml deleted file mode 100644 index 087850b..0000000 --- a/plugins/comment_classification/views/comment_classification_plugin_labels/create.rhtml +++ /dev/null @@ -1,3 +0,0 @@ -

<%= _("Add a new label") %>

- -<%= render :partial => 'form' %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_labels/edit.html.erb b/plugins/comment_classification/views/comment_classification_plugin_labels/edit.html.erb new file mode 100644 index 0000000..bbce3d8 --- /dev/null +++ b/plugins/comment_classification/views/comment_classification_plugin_labels/edit.html.erb @@ -0,0 +1,3 @@ +

<%= _("Editing label %s") % @label.name %>

+ +<%= render :partial => 'form' %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_labels/edit.rhtml b/plugins/comment_classification/views/comment_classification_plugin_labels/edit.rhtml deleted file mode 100644 index bbce3d8..0000000 --- a/plugins/comment_classification/views/comment_classification_plugin_labels/edit.rhtml +++ /dev/null @@ -1,3 +0,0 @@ -

<%= _("Editing label %s") % @label.name %>

- -<%= render :partial => 'form' %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_labels/index.html.erb b/plugins/comment_classification/views/comment_classification_plugin_labels/index.html.erb new file mode 100644 index 0000000..62a1fa6 --- /dev/null +++ b/plugins/comment_classification/views/comment_classification_plugin_labels/index.html.erb @@ -0,0 +1,32 @@ +

<%= _("Manage comments labels") %>

+ +
+ <% if @labels.empty? %> + <%= _('(no label registered yet)') %> + <% else %> + + + + + + + + <% @labels.each do |label| %> + + + + + + + <% end %> +
<%= _('Label') %><%= _('Color') %><%= _('Enabled') %><%= _('Actions') %>
<%= label.name %><%= label.color %><%= label.enabled %> + <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => label} %> + <%= button_without_text :delete, _('Remove'), {:action => 'destroy', :id => label}, :confirm => _('Are you sure you want to remove this label?') %> +
+ <% end %> + + <% button_bar do %> + <%= button(:add, _('Add a new label'), :action => 'create')%> + <%= button :back, _('Back to admin panel'), :controller => 'admin_panel' %> + <% end %> +
diff --git a/plugins/comment_classification/views/comment_classification_plugin_labels/index.rhtml b/plugins/comment_classification/views/comment_classification_plugin_labels/index.rhtml deleted file mode 100644 index 62a1fa6..0000000 --- a/plugins/comment_classification/views/comment_classification_plugin_labels/index.rhtml +++ /dev/null @@ -1,32 +0,0 @@ -

<%= _("Manage comments labels") %>

- -
- <% if @labels.empty? %> - <%= _('(no label registered yet)') %> - <% else %> - - - - - - - - <% @labels.each do |label| %> - - - - - - - <% end %> -
<%= _('Label') %><%= _('Color') %><%= _('Enabled') %><%= _('Actions') %>
<%= label.name %><%= label.color %><%= label.enabled %> - <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => label} %> - <%= button_without_text :delete, _('Remove'), {:action => 'destroy', :id => label}, :confirm => _('Are you sure you want to remove this label?') %> -
- <% end %> - - <% button_bar do %> - <%= button(:add, _('Add a new label'), :action => 'create')%> - <%= button :back, _('Back to admin panel'), :controller => 'admin_panel' %> - <% end %> -
diff --git a/plugins/comment_classification/views/comment_classification_plugin_myprofile/_status_form.html.erb b/plugins/comment_classification/views/comment_classification_plugin_myprofile/_status_form.html.erb index c60c1af..7a7fb41 100644 --- a/plugins/comment_classification/views/comment_classification_plugin_myprofile/_status_form.html.erb +++ b/plugins/comment_classification/views/comment_classification_plugin_myprofile/_status_form.html.erb @@ -1,6 +1,6 @@ <%= error_messages_for :status %> -<% form_for :status, @status do |f| %> +<%= form_for :status do |f| %> <%= required_fields_message %> <%= labelled_form_field(_('Status'), f.select(:status_id, @statuses.map{|s|[s.name,s.id]})) %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_status/_form.html.erb b/plugins/comment_classification/views/comment_classification_plugin_status/_form.html.erb new file mode 100644 index 0000000..2814519 --- /dev/null +++ b/plugins/comment_classification/views/comment_classification_plugin_status/_form.html.erb @@ -0,0 +1,13 @@ +<%= error_messages_for :status %> + +<%= form_for :status do |f| %> + <%= required_fields_message %> + + <%= required labelled_form_field(_('Name'), f.text_field(:name)) %> + <%= labelled_form_field(f.check_box(:enabled) + _('Enable this status?'),'') %> + <%#= labelled_form_field(f.check_box(:enable_reason) + _('This status allows reason?'),'') %> + + <% button_bar do %> + <%= submit_button('save', _('Save'), :cancel => {:action => 'index'} ) %> + <% end %> +<% end %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_status/_form.rhtml b/plugins/comment_classification/views/comment_classification_plugin_status/_form.rhtml deleted file mode 100644 index 02b557c..0000000 --- a/plugins/comment_classification/views/comment_classification_plugin_status/_form.rhtml +++ /dev/null @@ -1,13 +0,0 @@ -<%= error_messages_for :status %> - -<% form_for :status, @status do |f| %> - <%= required_fields_message %> - - <%= required labelled_form_field(_('Name'), f.text_field(:name)) %> - <%= labelled_form_field(f.check_box(:enabled) + _('Enable this status?'),'') %> - <%#= labelled_form_field(f.check_box(:enable_reason) + _('This status allows reason?'),'') %> - - <% button_bar do %> - <%= submit_button('save', _('Save'), :cancel => {:action => 'index'} ) %> - <% end %> -<% end %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_status/create.html.erb b/plugins/comment_classification/views/comment_classification_plugin_status/create.html.erb new file mode 100644 index 0000000..c834998 --- /dev/null +++ b/plugins/comment_classification/views/comment_classification_plugin_status/create.html.erb @@ -0,0 +1,3 @@ +

<%= _("Add a new status") %>

+ +<%= render :partial => 'form' %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_status/create.rhtml b/plugins/comment_classification/views/comment_classification_plugin_status/create.rhtml deleted file mode 100644 index c834998..0000000 --- a/plugins/comment_classification/views/comment_classification_plugin_status/create.rhtml +++ /dev/null @@ -1,3 +0,0 @@ -

<%= _("Add a new status") %>

- -<%= render :partial => 'form' %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_status/edit.html.erb b/plugins/comment_classification/views/comment_classification_plugin_status/edit.html.erb new file mode 100644 index 0000000..f564c5e --- /dev/null +++ b/plugins/comment_classification/views/comment_classification_plugin_status/edit.html.erb @@ -0,0 +1,3 @@ +

<%= _("Editing status %s") % @status.name %>

+ +<%= render :partial => 'form' %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_status/edit.rhtml b/plugins/comment_classification/views/comment_classification_plugin_status/edit.rhtml deleted file mode 100644 index f564c5e..0000000 --- a/plugins/comment_classification/views/comment_classification_plugin_status/edit.rhtml +++ /dev/null @@ -1,3 +0,0 @@ -

<%= _("Editing status %s") % @status.name %>

- -<%= render :partial => 'form' %> diff --git a/plugins/comment_classification/views/comment_classification_plugin_status/index.html.erb b/plugins/comment_classification/views/comment_classification_plugin_status/index.html.erb new file mode 100644 index 0000000..d793baa --- /dev/null +++ b/plugins/comment_classification/views/comment_classification_plugin_status/index.html.erb @@ -0,0 +1,32 @@ +

<%= _("Manage comments status") %>

+ +
+ <% if @status.empty? %> + <%= _('(no status registered yet)') %> + <% else %> + + + + + + + + <% @status.each do |st| %> + + + + + + + <% end %> +
<%= _('Status') %><%= _('Enabled') %><%= _('Reason enabled?') %><%= _('Actions') %>
<%= st.name %><%= st.enabled %><%= st.enable_reason %> + <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => st} %> + <%= button_without_text :delete, _('Remove'), {:action => 'destroy', :id => st}, :confirm => _('Are you sure you want to remove this status?') %> +
+ <% end %> + + <% button_bar do %> + <%= button(:add, _('Add a new status'), :action => 'create')%> + <%= button :back, _('Back to admin panel'), :controller => 'admin_panel' %> + <% end %> +
diff --git a/plugins/comment_classification/views/comment_classification_plugin_status/index.rhtml b/plugins/comment_classification/views/comment_classification_plugin_status/index.rhtml deleted file mode 100644 index d793baa..0000000 --- a/plugins/comment_classification/views/comment_classification_plugin_status/index.rhtml +++ /dev/null @@ -1,32 +0,0 @@ -

<%= _("Manage comments status") %>

- -
- <% if @status.empty? %> - <%= _('(no status registered yet)') %> - <% else %> - - - - - - - - <% @status.each do |st| %> - - - - - - - <% end %> -
<%= _('Status') %><%= _('Enabled') %><%= _('Reason enabled?') %><%= _('Actions') %>
<%= st.name %><%= st.enabled %><%= st.enable_reason %> - <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => st} %> - <%= button_without_text :delete, _('Remove'), {:action => 'destroy', :id => st}, :confirm => _('Are you sure you want to remove this status?') %> -
- <% end %> - - <% button_bar do %> - <%= button(:add, _('Add a new status'), :action => 'create')%> - <%= button :back, _('Back to admin panel'), :controller => 'admin_panel' %> - <% end %> -
-- libgit2 0.21.2