diff --git a/plugins/environment_notification/controllers/environment_notification_plugin_myprofile_controller.rb b/plugins/environment_notification/controllers/environment_notification_plugin_myprofile_controller.rb
index 0e03072..7c1df2c 100644
--- a/plugins/environment_notification/controllers/environment_notification_plugin_myprofile_controller.rb
+++ b/plugins/environment_notification/controllers/environment_notification_plugin_myprofile_controller.rb
@@ -1,4 +1,4 @@
-class EnvironmentNotificationPluginMyProfileController < MyProfileController
+class EnvironmentNotificationPluginMyprofileController < MyProfileController
helper EnvironmentNotificationHelper
include EnvironmentNotificationHelper
@@ -98,7 +98,7 @@ class EnvironmentNotificationPluginMyProfileController < MyProfileController
protected
def admin_required
- redirect_to :root unless profile.is_admin?(current_user.person)
+ redirect_to :root unless (current_person.is_admin? || profile.is_admin?(current_person))
end
end
diff --git a/plugins/environment_notification/lib/environment_notification_plugin.rb b/plugins/environment_notification/lib/environment_notification_plugin.rb
index 8331e40..c663e17 100644
--- a/plugins/environment_notification/lib/environment_notification_plugin.rb
+++ b/plugins/environment_notification/lib/environment_notification_plugin.rb
@@ -21,7 +21,7 @@ class EnvironmentNotificationPlugin < Noosfero::Plugin
def body_beginning
lambda do
extend EnvironmentNotificationHelper
- render template: 'environment_notification_plugin_admin/show_notification'
+ render template: 'shared/show_notification'
end
end
diff --git a/plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb b/plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb
deleted file mode 100644
index f441219..0000000
--- a/plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
- <% abstract_options = {:value => @notification.message, :style => 'width: 100%; height: 200px;', :class => 'mceEditor'} %>
-
- <%= button :back, _('Back'), :controller => 'environment_notification_plugin_admin' %>
-
- <%= form_for :notifications do |f| %>
-
- <%= render :file => 'shared/tiny_mce', :locals => {:mode => 'restricted'} %>
-
- <%= labelled_form_field(_("Optional Title:"), f.text_field(:title, value: @notification.title)) %>
-
- <%= labelled_form_field(_("Enter your message here:"), f.text_area(:message, abstract_options)) %>
-
- <%= _("Obs: You can use %{name} and %{email} variables to put the user's name and email in the message.") %>
-
-
- <%= labelled_form_field(_('Notifications Status'), select(:notifications, :active, options_for_select_with_title({"Active" => true, "Inactive" => false}, @notification.active))) %>
-
- <%= labelled_form_field(_('Notifications Color/Type'), select(:notifications, :type, options_for_select_with_title({_("Blue - Information") => "EnvironmentNotificationPlugin::InformationNotification", _("Yellow - Warning") => "EnvironmentNotificationPlugin::WarningNotification", _("Green - Success") => "EnvironmentNotificationPlugin::SuccessNotification", _("Red - Danger") => "EnvironmentNotificationPlugin::DangerNotification"}, @notification.type))) %>
-
-
- <%= labelled_check_box(_("Display only in the homepage"), 'notifications[display_only_in_homepage]', '1', @notification.display_only_in_homepage?) %>
-
-
-
- <%= labelled_check_box(_("Display to not logged users too"), 'notifications[display_to_all_users]', '1', @notification.display_to_all_users?) %>
-
-
-
- <%= labelled_check_box(_("Display popup until user close the notification"), 'notifications[display_popup]', '1', @notification.display_popup?) %>
-
-
- <% button_bar do %>
- <%= submit_button 'save', _('Save'), :cancel => { :action => 'index' } %>
- <% end %>
-
- <% end %>
-
diff --git a/plugins/environment_notification/views/environment_notification_plugin_admin/edit.html.erb b/plugins/environment_notification/views/environment_notification_plugin_admin/edit.html.erb
index 2872e82..85dd733 100644
--- a/plugins/environment_notification/views/environment_notification_plugin_admin/edit.html.erb
+++ b/plugins/environment_notification/views/environment_notification_plugin_admin/edit.html.erb
@@ -1 +1 @@
-<%= render :partial => "form" %>
+<%= render :partial => "shared/form" %>
diff --git a/plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb b/plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb
index f91fc60..21e19c4 100644
--- a/plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb
+++ b/plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb
@@ -1,40 +1 @@
-
-
-
<%= _("Environment Notifications") %>
-
-
-
-
-
- <%= _('Notifications') %>
-
-
- <%= _('Actions') %>
-
-
-
- <% @notifications.each do |notification| %>
-
-
- <%= truncate(notification.message, length: 50) %>
-
-
- <% if notification.active? %>
- <%= button_without_text :deactivate, _('Deactivate'), {:action => :change_status, :id => notification}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %>
- <% else %>
- <%= button_without_text :activate, _('Activate'), {:action => :change_status, :id => notification}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %>
- <% end %>
- <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => notification.id} if !remove_content_button(:edit, notification) %>
- <%= button_without_text :delete, _('Delete'), {:action => :destroy, :id => notification}, :method => :delete, :confirm => _("Do you want to delete this notification?") %>
-
-
- <% end %>
-
-
+<%= render :partial => "shared/notifications_list" %>
diff --git a/plugins/environment_notification/views/environment_notification_plugin_admin/new.html.erb b/plugins/environment_notification/views/environment_notification_plugin_admin/new.html.erb
index 2872e82..85dd733 100644
--- a/plugins/environment_notification/views/environment_notification_plugin_admin/new.html.erb
+++ b/plugins/environment_notification/views/environment_notification_plugin_admin/new.html.erb
@@ -1 +1 @@
-<%= render :partial => "form" %>
+<%= render :partial => "shared/form" %>
diff --git a/plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb b/plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb
deleted file mode 100644
index 514cf2c..0000000
--- a/plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb
+++ /dev/null
@@ -1,31 +0,0 @@
-<% if current_user && current_user.person.is_admin? %>
- <% active_notifications = EnvironmentNotificationPlugin::EnvironmentNotification.active(environment) %>
- <% unless active_notifications.blank? %>
-
-
-
-
- <%= _("There are active notifications in this environment!") %>
- <%= link_to _("Manage all notifications here."), EnvironmentNotificationPlugin.admin_url %>
-
-
-
-
- <% end %>
-<% end %>
-
-<% @notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(environment, current_user, controller_path).where("id NOT IN (?)", hide_notifications) %>
-
-
- <% @notifications.each do |notification| %>
-
notification" data-notification="<%=notification.id%>" notification-display-popup="<%=notification.display_popup?%>">
-
- <%= EnvironmentNotificationHelper.substitute_variables(notification.message, current_user) %>
-
- <% if logged_in? %>
-
-
- <% end %>
-
- <% end %>
-
diff --git a/plugins/environment_notification/views/environment_notification_plugin_myprofile/edit.html.erb b/plugins/environment_notification/views/environment_notification_plugin_myprofile/edit.html.erb
new file mode 100644
index 0000000..85dd733
--- /dev/null
+++ b/plugins/environment_notification/views/environment_notification_plugin_myprofile/edit.html.erb
@@ -0,0 +1 @@
+<%= render :partial => "shared/form" %>
diff --git a/plugins/environment_notification/views/environment_notification_plugin_myprofile/index.html.erb b/plugins/environment_notification/views/environment_notification_plugin_myprofile/index.html.erb
new file mode 100644
index 0000000..21e19c4
--- /dev/null
+++ b/plugins/environment_notification/views/environment_notification_plugin_myprofile/index.html.erb
@@ -0,0 +1 @@
+<%= render :partial => "shared/notifications_list" %>
diff --git a/plugins/environment_notification/views/environment_notification_plugin_myprofile/new.html.erb b/plugins/environment_notification/views/environment_notification_plugin_myprofile/new.html.erb
new file mode 100644
index 0000000..85dd733
--- /dev/null
+++ b/plugins/environment_notification/views/environment_notification_plugin_myprofile/new.html.erb
@@ -0,0 +1 @@
+<%= render :partial => "shared/form" %>
diff --git a/plugins/environment_notification/views/shared/_form.html.erb b/plugins/environment_notification/views/shared/_form.html.erb
new file mode 100644
index 0000000..f441219
--- /dev/null
+++ b/plugins/environment_notification/views/shared/_form.html.erb
@@ -0,0 +1,39 @@
+
+
+ <% abstract_options = {:value => @notification.message, :style => 'width: 100%; height: 200px;', :class => 'mceEditor'} %>
+
+ <%= button :back, _('Back'), :controller => 'environment_notification_plugin_admin' %>
+
+ <%= form_for :notifications do |f| %>
+
+ <%= render :file => 'shared/tiny_mce', :locals => {:mode => 'restricted'} %>
+
+ <%= labelled_form_field(_("Optional Title:"), f.text_field(:title, value: @notification.title)) %>
+
+ <%= labelled_form_field(_("Enter your message here:"), f.text_area(:message, abstract_options)) %>
+
+ <%= _("Obs: You can use %{name} and %{email} variables to put the user's name and email in the message.") %>
+
+
+ <%= labelled_form_field(_('Notifications Status'), select(:notifications, :active, options_for_select_with_title({"Active" => true, "Inactive" => false}, @notification.active))) %>
+
+ <%= labelled_form_field(_('Notifications Color/Type'), select(:notifications, :type, options_for_select_with_title({_("Blue - Information") => "EnvironmentNotificationPlugin::InformationNotification", _("Yellow - Warning") => "EnvironmentNotificationPlugin::WarningNotification", _("Green - Success") => "EnvironmentNotificationPlugin::SuccessNotification", _("Red - Danger") => "EnvironmentNotificationPlugin::DangerNotification"}, @notification.type))) %>
+
+
+ <%= labelled_check_box(_("Display only in the homepage"), 'notifications[display_only_in_homepage]', '1', @notification.display_only_in_homepage?) %>
+
+
+
+ <%= labelled_check_box(_("Display to not logged users too"), 'notifications[display_to_all_users]', '1', @notification.display_to_all_users?) %>
+
+
+
+ <%= labelled_check_box(_("Display popup until user close the notification"), 'notifications[display_popup]', '1', @notification.display_popup?) %>
+
+
+ <% button_bar do %>
+ <%= submit_button 'save', _('Save'), :cancel => { :action => 'index' } %>
+ <% end %>
+
+ <% end %>
+
diff --git a/plugins/environment_notification/views/shared/_notifications_list.html.erb b/plugins/environment_notification/views/shared/_notifications_list.html.erb
new file mode 100644
index 0000000..e695874
--- /dev/null
+++ b/plugins/environment_notification/views/shared/_notifications_list.html.erb
@@ -0,0 +1,39 @@
+
+
+
<%= _("Environment Notifications") %>
+
+
+
+
+
+ <%= _('Notifications') %>
+
+
+ <%= _('Actions') %>
+
+
+
+ <% @notifications.each do |notification| %>
+
+
+ <%= truncate(notification.message, length: 50) %>
+
+
+ <% if notification.active? %>
+ <%= button_without_text :deactivate, _('Deactivate'), {:action => :change_status, :id => notification}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %>
+ <% else %>
+ <%= button_without_text :activate, _('Activate'), {:action => :change_status, :id => notification}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %>
+ <% end %>
+ <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => notification.id} if !remove_content_button(:edit, notification) %>
+ <%= button_without_text :delete, _('Delete'), {:action => :destroy, :id => notification}, :method => :delete, :confirm => _("Do you want to delete this notification?") %>
+
+
+ <% end %>
+
diff --git a/plugins/environment_notification/views/shared/show_notification.html.erb b/plugins/environment_notification/views/shared/show_notification.html.erb
new file mode 100644
index 0000000..514cf2c
--- /dev/null
+++ b/plugins/environment_notification/views/shared/show_notification.html.erb
@@ -0,0 +1,31 @@
+<% if current_user && current_user.person.is_admin? %>
+ <% active_notifications = EnvironmentNotificationPlugin::EnvironmentNotification.active(environment) %>
+ <% unless active_notifications.blank? %>
+
+
+
+
+ <%= _("There are active notifications in this environment!") %>
+ <%= link_to _("Manage all notifications here."), EnvironmentNotificationPlugin.admin_url %>
+
+
+
+
+ <% end %>
+<% end %>
+
+<% @notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(environment, current_user, controller_path).where("id NOT IN (?)", hide_notifications) %>
+
+
+ <% @notifications.each do |notification| %>
+
notification" data-notification="<%=notification.id%>" notification-display-popup="<%=notification.display_popup?%>">
+
+ <%= EnvironmentNotificationHelper.substitute_variables(notification.message, current_user) %>
+
+ <% if logged_in? %>
+
+
+ <% end %>
+
+ <% end %>
+
--
libgit2 0.21.2