Commit ffbedc40666537b3d223945fd984fb1186560181
Committed by
Tallys Martins
1 parent
180ad529
Exists in
notification_plugin_rebase
Create environment notification plugin
Signed-off-by: Eduardo Vital <vitaldu@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Jéssica Cristina <jessica.cris1127@gmail.com> Signed-off-by: Simião Carvalho <simiaosimis@gmail.com> Signed-off-by: Victor Navarro <victor.matias.navarro@gmail.com> Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com> Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br>
Showing
24 changed files
with
679 additions
and
0 deletions
Show diff stats
plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb
0 → 100644
... | ... | @@ -0,0 +1,81 @@ |
1 | +class EnvironmentNotificationPluginAdminController < AdminController | |
2 | + before_filter :admin_required, :except => [:hide_notification] | |
3 | + def index | |
4 | + @notifications = environment.notifications.order('updated_at DESC') | |
5 | + end | |
6 | + | |
7 | + def new | |
8 | + @notification = Notification.new | |
9 | + if request.post? | |
10 | + @notification = Notification.new(params[:notifications]) | |
11 | + @notification.message = @notification.message.html_safe | |
12 | + @notification.environment_id = environment.id | |
13 | + if @notification.save | |
14 | + session[:notice] = _("Notification successfully created") | |
15 | + redirect_to :action => :index | |
16 | + else | |
17 | + session[:notice] = _("Notification couldn't be created") | |
18 | + end | |
19 | + end | |
20 | + end | |
21 | + | |
22 | + def destroy | |
23 | + if request.delete? | |
24 | + notification = environment.notifications.find_by_id(params[:id]) | |
25 | + if notification && notification.destroy | |
26 | + session[:notice] = _('The notification was deleted.') | |
27 | + else | |
28 | + session[:notice] = _('Could not remove the notification') | |
29 | + end | |
30 | + end | |
31 | + redirect_to :action => :index | |
32 | + end | |
33 | + | |
34 | + def edit | |
35 | + @notification = environment.notifications.find_by_id(params[:id]) | |
36 | + if request.post? | |
37 | + if @notification.update_attributes(params[:notifications]) | |
38 | + session[:notice] = _('The notification was edited.') | |
39 | + else | |
40 | + session[:notice] = _('Could not edit the notification.') | |
41 | + end | |
42 | + redirect_to :action => :index | |
43 | + end | |
44 | + end | |
45 | + | |
46 | + def change_status | |
47 | + @notification = environment.notifications.find_by_id(params[:id]) | |
48 | + | |
49 | + @notification.active = !@notification.active | |
50 | + | |
51 | + if @notification.save! | |
52 | + session[:notice] = _('The status of the notification was changed.') | |
53 | + else | |
54 | + session[:notice] = _('Could not change the status of the notification.') | |
55 | + end | |
56 | + | |
57 | + redirect_to :action => :index | |
58 | + end | |
59 | + | |
60 | + def hide_notification | |
61 | + result = false | |
62 | + | |
63 | + if logged_in? | |
64 | + @notification = environment.notifications.find_by_id(params[:notification_id]) | |
65 | + | |
66 | + if @notification | |
67 | + # Fix-me. I need validation on sucess and fail | |
68 | + @notification.users << current_user | |
69 | + result = @notification.users.include?(current_user) | |
70 | + end | |
71 | + end | |
72 | + | |
73 | + render json: result | |
74 | + end | |
75 | + | |
76 | + protected | |
77 | + def admin_required | |
78 | + redirect_to :root unless current_user.person.is_admin? | |
79 | + end | |
80 | + | |
81 | +end | ... | ... |
plugins/environment_notification/db/migrate/20150721132025_create_notification_table.rb
0 → 100644
... | ... | @@ -0,0 +1,22 @@ |
1 | +class CreateNotificationTable < ActiveRecord::Migration | |
2 | + def up | |
3 | + create_table :notifications do |t| | |
4 | + t.text :message | |
5 | + t.integer :environment_id | |
6 | + t.string :type | |
7 | + t.boolean :active | |
8 | + t.column :created_at, :datetime | |
9 | + t.column :updated_at, :datetime | |
10 | + end | |
11 | + | |
12 | + create_table :notifications_users, id: false do |t| | |
13 | + t.belongs_to :notification, index: true | |
14 | + t.belongs_to :user, index: true | |
15 | + end | |
16 | + end | |
17 | + | |
18 | + def down | |
19 | + drop_table :notifications | |
20 | + drop_table :notifications_users | |
21 | + end | |
22 | +end | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +require environment_notification_plugin.rb | ... | ... |
plugins/environment_notification/lib/danger_notification.rb
0 → 100644
plugins/environment_notification/lib/environment_notification_plugin.rb
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +class EnvironmentNotificationPlugin < Noosfero::Plugin | |
2 | + | |
3 | + def self.plugin_name | |
4 | + "Environment Notifications Plugin" | |
5 | + end | |
6 | + | |
7 | + def self.plugin_description | |
8 | + _("A plugin for environment notifications.") | |
9 | + end | |
10 | + | |
11 | + def stylesheet? | |
12 | + true | |
13 | + end | |
14 | + | |
15 | + def js_files | |
16 | + %w( | |
17 | + public/app.js | |
18 | + ) | |
19 | + end | |
20 | + | |
21 | + def body_beginning | |
22 | + expanded_template('environment_notification_plugin_admin/show_notification.html.erb') | |
23 | + end | |
24 | + | |
25 | + def admin_panel_links | |
26 | + {:title => _('Notification Manager'), :url => {:controller => 'environment_notification_plugin_admin', :action => 'index'}} | |
27 | + end | |
28 | + | |
29 | +end | ... | ... |
plugins/environment_notification/lib/information_notification.rb
0 → 100644
... | ... | @@ -0,0 +1,21 @@ |
1 | +class Notification < ActiveRecord::Base | |
2 | + | |
3 | + TYPE_LIST = ["WarningNotification", "SuccessNotification", "InformationNotification", | |
4 | + "DangerNotification"] | |
5 | + | |
6 | + attr_accessible :message, :environment_id, :active, :type | |
7 | + | |
8 | + has_many :notifications_users | |
9 | + has_many :users, :through => :notifications_users | |
10 | + | |
11 | + validates_presence_of :message | |
12 | + validates_presence_of :environment_id | |
13 | + validate :notification_type_must_be_in_type_list | |
14 | + | |
15 | + def notification_type_must_be_in_type_list | |
16 | + unless TYPE_LIST.include?(type) | |
17 | + errors.add(:type, "invalid notification type") | |
18 | + end | |
19 | + end | |
20 | + | |
21 | +end | ... | ... |
plugins/environment_notification/lib/notifications_user.rb
0 → 100644
plugins/environment_notification/lib/success_notification.rb
0 → 100644
plugins/environment_notification/lib/warning_notification.rb
0 → 100644
... | ... | @@ -0,0 +1,40 @@ |
1 | +(function($) { | |
2 | + "use strict"; | |
3 | + function repositioning_notification_bar() { | |
4 | + var complete_message = $(".notification-bar").remove(); | |
5 | + | |
6 | + $("#content-inner").before(complete_message); | |
7 | + } | |
8 | + | |
9 | + jQuery(document).ready(function(){ | |
10 | + repositioning_notification_bar(); | |
11 | + $(".notification-close").on("click", hideNotification) | |
12 | + mceRestrict(); | |
13 | + }); | |
14 | + | |
15 | + function hideNotification(){ | |
16 | + var notification = $(this).parent(); | |
17 | + var id = notification.attr("data-notification"); | |
18 | + | |
19 | + $.ajax({ | |
20 | + url: noosfero_root()+"/admin/plugin/environment_notification/hide_notification", | |
21 | + type: "POST", | |
22 | + data: {notification_id: id}, | |
23 | + success: function(response) { | |
24 | + notification.fadeOut(); | |
25 | + } | |
26 | + }); | |
27 | + } | |
28 | + | |
29 | + function mceRestrict() { | |
30 | + tinyMCE.init({ | |
31 | + menubar : false, | |
32 | + selector: "textarea", | |
33 | + plugins: [ | |
34 | + "autolink link" | |
35 | + ], | |
36 | + toolbar: "bold italic underline | link" | |
37 | + }); | |
38 | + } | |
39 | + | |
40 | +})(jQuery); | ... | ... |
240 Bytes
389 Bytes
364 Bytes
... | ... | @@ -0,0 +1,141 @@ |
1 | +.notification-bar { | |
2 | + display: block; | |
3 | +} | |
4 | + | |
5 | +.notification:hover { | |
6 | + opacity: 0.8; | |
7 | +} | |
8 | + | |
9 | +#notification-manager { | |
10 | + overflow: auto; | |
11 | +} | |
12 | + | |
13 | +.notification .notification-close { | |
14 | + background: url(public/images/close.png) no-repeat; | |
15 | + background-position: center; | |
16 | + width: 20px; | |
17 | + height: 20px; | |
18 | +} | |
19 | + | |
20 | +.warningnotification, | |
21 | +.informationnotification, | |
22 | +.successnotification, | |
23 | +.dangernotification { | |
24 | + margin-bottom: 10px; | |
25 | + padding: 7px 10px; | |
26 | + border-radius: 5px; | |
27 | + border: 1px solid blue; | |
28 | + font-size: 16px; | |
29 | + color: white; | |
30 | + overflow: auto; | |
31 | +} | |
32 | + | |
33 | +.warningnotification p, | |
34 | +.informationnotification p, | |
35 | +.successnotification p, | |
36 | +.dangernotification p { | |
37 | + margin: 0px; | |
38 | +} | |
39 | + | |
40 | +.warningnotification { | |
41 | + background: #EEA236; | |
42 | + border: 1px solid #EEA236; | |
43 | +} | |
44 | + | |
45 | +.informationnotification { | |
46 | + background: #5BC0DE; | |
47 | + border: 1px solid #46B8DA; | |
48 | +} | |
49 | + | |
50 | +.successnotification { | |
51 | + background: #5CB85C; | |
52 | + border: 1px solid #4CAE4C; | |
53 | +} | |
54 | + | |
55 | +.dangernotification { | |
56 | + background: #C9302C; | |
57 | + border: 1px solid #AC2925; | |
58 | +} | |
59 | + | |
60 | +a.button.icon-deactivate { | |
61 | + background: url(public/images/hide.png) no-repeat; | |
62 | + background-position: center; | |
63 | +} | |
64 | + | |
65 | +a.button.icon-activate { | |
66 | + background: url(public/images/show.png) no-repeat; | |
67 | + background-position: center; | |
68 | +} | |
69 | + | |
70 | +.notification-line { | |
71 | + display: inline; | |
72 | + padding-top: 10px; | |
73 | + vertical-align: middle; | |
74 | + border-bottom: 1px solid #ccc; | |
75 | +} | |
76 | + | |
77 | +.notification-title-bar { | |
78 | + float: left; | |
79 | + width: 100%; | |
80 | + font-style: 14px; | |
81 | + font-weight: 700; | |
82 | + border-bottom: 2px solid black; | |
83 | + padding: 9px 0; | |
84 | +} | |
85 | + | |
86 | +.notification-title { | |
87 | + width: 80%; | |
88 | + float: left; | |
89 | + text-align: center; | |
90 | +} | |
91 | + | |
92 | +.action-title { | |
93 | + width: 20%; | |
94 | + float: left; | |
95 | + text-align: center; | |
96 | +} | |
97 | + | |
98 | +.notification-action { | |
99 | + width: 18%; | |
100 | + float: left; | |
101 | + height: 30px; | |
102 | + padding-top: 9px; | |
103 | +} | |
104 | + | |
105 | +.main-bar .button, | |
106 | +.notification-action .button { | |
107 | + border-radius: 3px; | |
108 | +} | |
109 | + | |
110 | +.notification-message { | |
111 | + width: 82%; | |
112 | + float: left; | |
113 | +} | |
114 | + | |
115 | +.new-notification { | |
116 | + float: right; | |
117 | + width: auto; | |
118 | +} | |
119 | + | |
120 | +.back-button { | |
121 | + float: left; | |
122 | +} | |
123 | + | |
124 | +.main-bar { | |
125 | + display: inline; | |
126 | + width: 100%; | |
127 | +} | |
128 | + | |
129 | +.notification-bar .notification .notification-message { | |
130 | + width: 90%; | |
131 | + float: left; | |
132 | +} | |
133 | + | |
134 | +.notification-bar .notification .notification-close { | |
135 | + background: url(public/images/close.png) no-repeat; | |
136 | + background-position: center; | |
137 | + width: 20px; | |
138 | + height: 20px; | |
139 | + float: right; | |
140 | + cursor: pointer; | |
141 | +} | ... | ... |
plugins/environment_notification/test/functional/environment_notification_plugin_admin_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,144 @@ |
1 | +require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' | |
2 | +require( | |
3 | + File.expand_path(File.dirname(__FILE__)) + | |
4 | + '/../../controllers/environment_notification_plugin_admin_controller' | |
5 | +) | |
6 | + | |
7 | +class EnvironmentNotificationPluginAdminController; def rescue_action(e) raise e end; | |
8 | +end | |
9 | + | |
10 | +class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestCase | |
11 | + def setup | |
12 | + @controller = EnvironmentNotificationPluginAdminController.new | |
13 | + @request = ActionController::TestRequest.new | |
14 | + @response = ActionController::TestResponse.new | |
15 | + @person = create_user('person').person | |
16 | + | |
17 | + @environment = Environment.default | |
18 | + @environment.enable_plugin('EnvironmentNotificationPlugin') | |
19 | + @environment.save! | |
20 | + | |
21 | + login_as(@person.user.login) | |
22 | + end | |
23 | + | |
24 | + attr_accessor :person | |
25 | + | |
26 | + should 'an admin be able to create a notification' do | |
27 | + @environment.add_admin(@person) | |
28 | + post :new, :notifications => { :message => "Message", | |
29 | + :active => true, | |
30 | + :type => "DangerNotification" | |
31 | + } | |
32 | + assert_redirected_to :action => 'index' | |
33 | + notification = Notification.last | |
34 | + assert_equal "Message", notification.message | |
35 | + assert notification.active | |
36 | + assert_equal "DangerNotification", notification.type | |
37 | + end | |
38 | + | |
39 | + should 'an user not to be able to create a notification' do | |
40 | + post :new, :notifications => { :message => "Message", | |
41 | + :active => true, | |
42 | + :type => "DangerNotification" | |
43 | + } | |
44 | + assert_redirected_to :root | |
45 | + assert_nil Notification.last | |
46 | + end | |
47 | + | |
48 | + should 'an admin be able to edit a notification' do | |
49 | + @environment.add_admin(@person) | |
50 | + @notification = Notification.create( :environment_id => @environment.id, | |
51 | + :message => "Message", | |
52 | + :active => true, | |
53 | + :type => "DangerNotification" | |
54 | + ) | |
55 | + post :edit, :id => @notification.id, | |
56 | + :notifications => { | |
57 | + :message => "Edited Message", | |
58 | + :active => false, | |
59 | + :type => "WarningNotification" | |
60 | + } | |
61 | + @notification = Notification.last | |
62 | + assert_redirected_to :action => 'index' | |
63 | + assert_equal "Edited Message", @notification.message | |
64 | + assert !@notification.active | |
65 | + assert_equal "WarningNotification", @notification.type | |
66 | + end | |
67 | + | |
68 | + should 'an user not to be able to edit a notification' do | |
69 | + @notification = Notification.create( :environment_id => @environment.id, | |
70 | + :message => "Message", | |
71 | + :active => true, | |
72 | + :type => "DangerNotification" | |
73 | + ) | |
74 | + post :edit, :notifications => { :message => "Edited Message", | |
75 | + :active => false, | |
76 | + :type => "DangerNotification" | |
77 | + } | |
78 | + @notification.reload | |
79 | + assert_redirected_to :root | |
80 | + assert_equal "Message", @notification.message | |
81 | + assert @notification.active | |
82 | + end | |
83 | + | |
84 | + should 'an admin be able to destroy a notification' do | |
85 | + @environment.add_admin(@person) | |
86 | + @notification = Notification.create( :environment_id => @environment.id, | |
87 | + :message => "Message", | |
88 | + :active => true, | |
89 | + :type => "DangerNotification" | |
90 | + ) | |
91 | + delete :destroy, :id => @notification.id | |
92 | + assert_nil Notification.find_by_id(@notification.id) | |
93 | + end | |
94 | + | |
95 | + should 'an user not to be able to destroy a notification' do | |
96 | + @notification = Notification.create( :environment_id => @environment.id, | |
97 | + :message => "Message", | |
98 | + :active => true, | |
99 | + :type => "DangerNotification" | |
100 | + ) | |
101 | + delete :destroy, :id => @notification.id | |
102 | + | |
103 | + assert_redirected_to :root | |
104 | + assert_not_nil Notification.find_by_id(@notification.id) | |
105 | + end | |
106 | + | |
107 | + should 'an admin be able to change Notification status' do | |
108 | + @environment.add_admin(@person) | |
109 | + @notification = Notification.create( :environment_id => @environment.id, | |
110 | + :message => "Message", | |
111 | + :active => true, | |
112 | + :type => "DangerNotification" | |
113 | + ) | |
114 | + post :change_status, :id => @notification.id | |
115 | + assert_redirected_to :action => 'index' | |
116 | + | |
117 | + @notification.reload | |
118 | + assert !@notification.active | |
119 | + end | |
120 | + | |
121 | + should 'an user not be able to change Notification status' do | |
122 | + @notification = Notification.create( :environment_id => @environment.id, | |
123 | + :message => "Message", | |
124 | + :active => true, | |
125 | + :type => "DangerNotification" | |
126 | + ) | |
127 | + post :change_status, :id => @notification.id | |
128 | + assert_redirected_to :root | |
129 | + | |
130 | + @notification.reload | |
131 | + assert @notification.active | |
132 | + end | |
133 | + | |
134 | + should 'a logged in user be able to permanently hide notifications' do | |
135 | + @notification = Notification.create( :environment_id => @environment.id, | |
136 | + :message => "Message", | |
137 | + :active => true, | |
138 | + :type => "DangerNotification" | |
139 | + ) | |
140 | + post :hide_notification, :notification_id => @notification.id | |
141 | + assert_equal "true", @response.body | |
142 | + assert_equal true, @notification.users.include?(@person.user) | |
143 | + end | |
144 | +end | ... | ... |
plugins/environment_notification/test/functional/home_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,88 @@ |
1 | +require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' | |
2 | +require 'home_controller' | |
3 | + | |
4 | +class HomeController; def rescue_action(e) raise e end; | |
5 | +end | |
6 | + | |
7 | +class HomeControllerTest < ActionController::TestCase | |
8 | + def setup | |
9 | + @controller = HomeController.new | |
10 | + @request = ActionController::TestRequest.new | |
11 | + @response = ActionController::TestResponse.new | |
12 | + @person = create_user('person').person | |
13 | + | |
14 | + @environment = Environment.default | |
15 | + @environment.enable_plugin('EnvironmentNotificationPlugin') | |
16 | + @environment.save! | |
17 | + end | |
18 | + | |
19 | + attr_accessor :person | |
20 | + | |
21 | + should 'an active notification be displayed on home page for a logged in user' do | |
22 | + login_as(@person.user.login) | |
23 | + @notification = Notification.create( :environment_id => @environment.id, | |
24 | + :message => "Hello, this is a Notification Message", | |
25 | + :active => true, | |
26 | + :type => "DangerNotification" | |
27 | + ) | |
28 | + get :index | |
29 | + assert_match /Hello, this is a Notification Message/, @response.body | |
30 | + end | |
31 | + | |
32 | + | |
33 | + should 'an active notification be displayed on home page for unlogged user' do | |
34 | + @notification = Notification.create( :environment_id => @environment.id, | |
35 | + :message => "Hello, this is a Notification Message", | |
36 | + :active => true, | |
37 | + :type => "DangerNotification" | |
38 | + ) | |
39 | + get :index | |
40 | + assert_match /Hello, this is a Notification Message/, @response.body | |
41 | + end | |
42 | + | |
43 | + | |
44 | + should 'only the last notification be displayed on home page for unlogged user' do | |
45 | + @notification1 = Notification.create( :environment_id => @environment.id, | |
46 | + :message => "Hello, this is an old Notification Message", | |
47 | + :active => true, | |
48 | + :type => "DangerNotification" | |
49 | + ) | |
50 | + | |
51 | + @notification2 = Notification.create( :environment_id => @environment.id, | |
52 | + :message => "Hello, this is a new Notification Message", | |
53 | + :active => true, | |
54 | + :type => "DangerNotification" | |
55 | + ) | |
56 | + | |
57 | + | |
58 | + get :index | |
59 | + assert_no_match /Hello, this is a Notification Message/, @response.body | |
60 | + assert_match /Hello, this is a new Notification Message/, @response.body | |
61 | + end | |
62 | + | |
63 | + should 'an inactive notification not be displayed on home page' do | |
64 | + @notification = Notification.create( :environment_id => @environment.id, | |
65 | + :message => "Hello, this is a Notification Message", | |
66 | + :active => false, | |
67 | + :type => "DangerNotification" | |
68 | + ) | |
69 | + get :index | |
70 | + assert_no_match /Hello, this is a Notification Message/, @response.body | |
71 | + end | |
72 | + | |
73 | + | |
74 | + should 'an active notification not be displayed to a logged in user after been closed by him' do | |
75 | + login_as(@person.user.login) | |
76 | + @notification = Notification.create( :environment_id => @environment.id, | |
77 | + :message => "Hello, this is a Notification Message", | |
78 | + :active => true, | |
79 | + :type => "DangerNotification" | |
80 | + ) | |
81 | + @notification.users << @person.user | |
82 | + @notification.save! | |
83 | + assert_equal true, @notification.users.include?(@person.user) | |
84 | + get :index | |
85 | + assert_no_match /Hello, this is a Notification Message/, @response.body | |
86 | + end | |
87 | + | |
88 | +end | ... | ... |
plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb
0 → 100644
... | ... | @@ -0,0 +1,19 @@ |
1 | +<% abstract_options = {:value => @notification.message, :style => 'width: 100%; height: 200px;'} %> | |
2 | + | |
3 | +<%= button :back, _('Back'), :controller => 'environment_notification_plugin_admin' %> | |
4 | + | |
5 | +<%= form_for :notifications do |f| %> | |
6 | + | |
7 | + <%= render :file => 'shared/tiny_mce' %> | |
8 | + | |
9 | + <%= labelled_form_field(_("Enter your message here:"), f.text_area(:message, abstract_options)) %> | |
10 | + | |
11 | + <%= labelled_form_field(_('Notifications Status'), select(:notifications, :active, options_for_select_with_title({"Active" => true, "Inactive" => false}, @notification.active))) %> | |
12 | + | |
13 | + <%= labelled_form_field(_('Notifications Type'), select(:notifications, :type, options_for_select_with_title({"Information" => "InformationNotification", "Warning" => "WarningNotification", "Success" => "SuccessNotification", "Danger" => "DangerNotification"}, @notification.type))) %> | |
14 | + | |
15 | + <% button_bar do %> | |
16 | + <%= submit_button 'save', _('Save'), :cancel => { :action => 'index' } %> | |
17 | + <% end %> | |
18 | + | |
19 | +<% end %> | ... | ... |
plugins/environment_notification/views/environment_notification_plugin_admin/edit.html.erb
0 → 100644
... | ... | @@ -0,0 +1 @@ |
1 | +<%= render :partial => "form" %> | ... | ... |
plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb
0 → 100644
... | ... | @@ -0,0 +1,40 @@ |
1 | + <div id="notification-manager"> | |
2 | + <div class="notification-manager-title"> | |
3 | + <h1>Notifications</h1> | |
4 | + </div> | |
5 | + <div class="buttons-bar"> | |
6 | + <div class="new-notification"> | |
7 | + <%= button :new, _('New Notification'), {:action => :new}, :method => :get %> | |
8 | + </div> | |
9 | + <div class="back-button"> | |
10 | + <%= button :back, _('Back to control panel'), {:controller => 'admin_panel', :action => :index}, :method => :get %> | |
11 | + </div> | |
12 | + </div> | |
13 | + | |
14 | + <div class="notification-title-bar"> | |
15 | + <div class="notification-title"> | |
16 | + <%= _('Notifications') %> | |
17 | + </div> | |
18 | + <div class="action-title"> | |
19 | + <%= _('Actions') %> | |
20 | + </div> | |
21 | + </div> | |
22 | + <% @notifications.each do |n| %> | |
23 | + <div class="notification-line"> | |
24 | + <div class="notification-message"> | |
25 | + <%= truncate(n.message, length: 50) %> | |
26 | + | |
27 | + </div> | |
28 | + <div class="notification-action"> | |
29 | + <% if n.active? %> | |
30 | + <%= button_without_text :deactivate, _('Deactivate'), {:action => :change_status, :id => n}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %> | |
31 | + <% else %> | |
32 | + <%= button_without_text :activate, _('Activate'), {:action => :change_status, :id => n}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %> | |
33 | + <% end %> | |
34 | + <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => n.id} if !remove_content_button(:edit, n) %> | |
35 | + <%= button_without_text :delete, _('Delete'), {:action => :destroy, :id => n}, :method => :delete, :confirm => _("Do you want to delete this notification?") %> | |
36 | + </div> | |
37 | + </div> | |
38 | + <% end %> | |
39 | + </div> | |
40 | + | ... | ... |
plugins/environment_notification/views/environment_notification_plugin_admin/new.html.erb
0 → 100644
... | ... | @@ -0,0 +1 @@ |
1 | +<%= render :partial => "form" %> | ... | ... |
plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb
0 → 100644
... | ... | @@ -0,0 +1,24 @@ |
1 | +<% if controller_path == "home" %> | |
2 | + <div class="notification-bar"> | |
3 | + | |
4 | + <% if logged_in? %> | |
5 | + <% @notifications = environment.notifications.order('updated_at DESC').where(active: true) %> | |
6 | + <% @deactivated = current_user.notifications %> | |
7 | + <% @notifications = @notifications - @deactivated %> | |
8 | + <% else %> | |
9 | + <% @notifications = environment.notifications.order('updated_at DESC').where(active: true).limit(1) %> | |
10 | + <% end %> | |
11 | + <% @notifications.each do |n| %> | |
12 | + <div class="<%= n.type.downcase %> notification" data-notification="<%=n.id%>"> | |
13 | + <div class="notification-message"> | |
14 | + <%= n.message %> | |
15 | + </div> | |
16 | + <% if logged_in? %> | |
17 | + <div class="notification-close"> | |
18 | + </div> | |
19 | + <% end %> | |
20 | + </div> | |
21 | + <% end %> | |
22 | + | |
23 | + </div> | |
24 | +<% end %> | ... | ... |