Commit 413e4545d352849ee572cb6505324cdad85d6e6a
1 parent
20be7887
Exists in
community_notifications
fixes list of notifications
Showing
3 changed files
with
8 additions
and
2 deletions
Show diff stats
plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb
... | ... | @@ -14,7 +14,7 @@ class EnvironmentNotificationPluginAdminController < AdminController |
14 | 14 | if request.post? |
15 | 15 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.new(params[:notifications]) |
16 | 16 | @notification.message = @notification.message.html_safe |
17 | - @notification.environment_id = environment.id | |
17 | + @notification.target = environment | |
18 | 18 | if @notification.save |
19 | 19 | session[:notice] = _("Notification successfully created") |
20 | 20 | redirect_to :action => :index | ... | ... |
plugins/environment_notification/models/environment_notification_plugin/environment_notification.rb
... | ... | @@ -32,6 +32,10 @@ class EnvironmentNotificationPlugin::EnvironmentNotification < ActiveRecord::Bas |
32 | 32 | def self.visibles(target, user, controller_path) |
33 | 33 | notifications = EnvironmentNotificationPlugin::EnvironmentNotification.active(target).order('updated_at DESC') |
34 | 34 | |
35 | + if target.kind_of?(Organization) && target.environment.present? | |
36 | + env_notifications = EnvironmentNotificationPlugin::EnvironmentNotification.active(target.environment).order('updated_at DESC') | |
37 | + end | |
38 | + | |
35 | 39 | if user |
36 | 40 | active_notifications_ids = notifications.pluck(:id) - user.environment_notifications.pluck(:id) |
37 | 41 | ... | ... |
plugins/environment_notification/views/shared/show_notification.html.erb
... | ... | @@ -14,7 +14,9 @@ |
14 | 14 | <% end %> |
15 | 15 | <% end %> |
16 | 16 | |
17 | -<% @notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(environment, current_user, controller_path).where("id NOT IN (?)", hide_notifications) %> | |
17 | +<% target = profile.present? ? profile : environment %> | |
18 | + | |
19 | +<% @notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(target, current_user, controller_path).where("id NOT IN (?)", hide_notifications) %> | |
18 | 20 | |
19 | 21 | <div class="environment-notification-plugin-notification-bar"> |
20 | 22 | <% @notifications.each do |notification| %> | ... | ... |