Commit c09dd81fff3815f7f6056470cb83d33492fc95b5
Exists in
staging
and in
1 other branch
Merge branch 'master' into staging
Showing
101 changed files
with
2046 additions
and
1695 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 101 files displayed.
app/controllers/public/profile_controller.rb
| ... | ... | @@ -86,8 +86,16 @@ class ProfileController < PublicController |
| 86 | 86 | @articles = profile.top_level_articles.includes([:profile, :parent]) |
| 87 | 87 | end |
| 88 | 88 | |
| 89 | + def join_modal | |
| 90 | + profile.add_member(user) | |
| 91 | + session[:notice] = _('%s administrator still needs to accept you as member.') % profile.name | |
| 92 | + redirect_to :action => :index | |
| 93 | + end | |
| 94 | + | |
| 89 | 95 | def join |
| 90 | 96 | if !user.memberships.include?(profile) |
| 97 | + return if profile.community? && show_confirmation_modal?(profile) | |
| 98 | + | |
| 91 | 99 | profile.add_member(user) |
| 92 | 100 | if !profile.members.include?(user) |
| 93 | 101 | render :text => {:message => _('%s administrator still needs to accept you as member.') % profile.name}.to_json | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -56,6 +56,8 @@ module ApplicationHelper |
| 56 | 56 | |
| 57 | 57 | include TaskHelper |
| 58 | 58 | |
| 59 | + include MembershipsHelper | |
| 60 | + | |
| 59 | 61 | def locale |
| 60 | 62 | (@page && !@page.language.blank?) ? @page.language : FastGettext.locale |
| 61 | 63 | end |
| ... | ... | @@ -986,11 +988,11 @@ module ApplicationHelper |
| 986 | 988 | |
| 987 | 989 | def task_information(task) |
| 988 | 990 | values = {} |
| 991 | + values.merge!(task.information[:variables]) if task.information[:variables] | |
| 989 | 992 | values.merge!({:requestor => link_to(task.requestor.name, task.requestor.url)}) if task.requestor |
| 990 | 993 | values.merge!({:subject => content_tag('span', task.subject, :class=>'task_target')}) if task.subject |
| 991 | 994 | values.merge!({:linked_subject => link_to(content_tag('span', task.linked_subject[:text], :class => 'task_target'), task.linked_subject[:url])}) if task.linked_subject |
| 992 | - values.merge!(task.information[:variables]) if task.information[:variables] | |
| 993 | - task.information[:message] % values | |
| 995 | + (task.information[:message] % values).html_safe | |
| 994 | 996 | end |
| 995 | 997 | |
| 996 | 998 | def add_zoom_to_article_images | ... | ... |
app/helpers/memberships_helper.rb
| 1 | 1 | module MembershipsHelper |
| 2 | + | |
| 3 | + def join_community_button options={:logged => false} | |
| 4 | + url = options[:logged] ? profile.join_url : profile.join_not_logged_url | |
| 5 | + | |
| 6 | + if show_confirmation_modal? profile | |
| 7 | + modal_button :add, _('Join this community'), url, class: 'join-community' | |
| 8 | + else | |
| 9 | + button :add, _('Join this community'), url, class: 'join-community' | |
| 10 | + end | |
| 11 | + end | |
| 12 | + | |
| 13 | + def show_confirmation_modal? profile | |
| 14 | + profile.requires_email? && current_person && !current_person.public_fields.include?("email") | |
| 15 | + end | |
| 16 | + | |
| 2 | 17 | end | ... | ... |
app/helpers/profile_image_helper.rb
| ... | ... | @@ -61,6 +61,8 @@ module ProfileImageHelper |
| 61 | 61 | image_tag(profile_icon(profile, size), opt ) |
| 62 | 62 | end |
| 63 | 63 | |
| 64 | + include MembershipsHelper | |
| 65 | + | |
| 64 | 66 | def links_for_balloon(profile) |
| 65 | 67 | if environment.enabled?(:show_balloon_with_profile_links_when_clicked) |
| 66 | 68 | if profile.kind_of?(Person) |
| ... | ... | @@ -76,7 +78,7 @@ module ProfileImageHelper |
| 76 | 78 | {_('Wall') => {:href => url_for(profile.public_profile_url)}}, |
| 77 | 79 | {_('Members') => {:href => url_for(:controller => :profile, :action => :members, :profile => profile.identifier)}}, |
| 78 | 80 | {_('Agenda') => {:href => url_for(:controller => :profile, :action => :events, :profile => profile.identifier)}}, |
| 79 | - {_('Join') => {:href => url_for(profile.join_url), :class => 'join-community', :style => 'display: none'}}, | |
| 81 | + {_('Join') => {:href => url_for(profile.join_url), :class => 'join-community'+ (show_confirmation_modal?(profile) ? ' modal-toggle' : '') , :style => 'display: none'}}, | |
| 80 | 82 | {_('Leave community') => {:href => url_for(profile.leave_url), :class => 'leave-community', :style => 'display: none'}}, |
| 81 | 83 | {_('Send an e-mail') => {:href => url_for(:profile => profile.identifier, :controller => 'contact', :action => 'new'), :class => 'send-an-email', :style => 'display: none'}} |
| 82 | 84 | ] | ... | ... |
app/models/add_member.rb
| ... | ... | @@ -29,16 +29,18 @@ class AddMember < Task |
| 29 | 29 | end |
| 30 | 30 | |
| 31 | 31 | def information |
| 32 | - requestor_email = " (#{requestor.email})" if requestor.may_display_field_to?("email") | |
| 33 | - | |
| 34 | - {:message => _("%{requestor}%{requestor_email} wants to be a member of '%{organization}'."), | |
| 35 | - variables: {requestor: requestor.name, requestor_email: requestor_email, organization: organization.name}} | |
| 32 | + {:message => _("%{requestor} wants to be a member of '%{target}'."), | |
| 33 | + variables: {requestor: requestor.name, target: target.name}} | |
| 36 | 34 | end |
| 37 | 35 | |
| 38 | 36 | def accept_details |
| 39 | 37 | true |
| 40 | 38 | end |
| 41 | 39 | |
| 40 | + def footer | |
| 41 | + true | |
| 42 | + end | |
| 43 | + | |
| 42 | 44 | def icon |
| 43 | 45 | {:type => :profile_image, :profile => requestor, :url => requestor.url} |
| 44 | 46 | end |
| ... | ... | @@ -63,4 +65,15 @@ class AddMember < Task |
| 63 | 65 | suggestion.disable if suggestion |
| 64 | 66 | end |
| 65 | 67 | |
| 68 | + def task_finished_message | |
| 69 | + _("You have been accepted at \"%{target}\" with the profile \"%{requestor}\"") % | |
| 70 | + {:target => self.target.name, | |
| 71 | + :requestor => self.requestor.name} | |
| 72 | + end | |
| 73 | + | |
| 74 | + def task_cancelled_message | |
| 75 | + _("Your request to enter community \"%{target} with the profile \"%{requestor}\" was not accepted. Please contact any profile admin from %{url} for more information.") % | |
| 76 | + {:target => self.target.name, :url => self.target.url, | |
| 77 | + :requestor => self.requestor.name} | |
| 78 | + end | |
| 66 | 79 | end | ... | ... |
app/models/community.rb
| ... | ... | @@ -2,6 +2,7 @@ class Community < Organization |
| 2 | 2 | |
| 3 | 3 | attr_accessible :accessor_id, :accessor_type, :role_id, :resource_id, :resource_type |
| 4 | 4 | attr_accessible :address_reference, :district, :tag_list, :language, :description |
| 5 | + attr_accessible :requires_email | |
| 5 | 6 | after_destroy :check_invite_member_for_destroy |
| 6 | 7 | |
| 7 | 8 | def self.type_name |
| ... | ... | @@ -12,6 +13,9 @@ class Community < Organization |
| 12 | 13 | N_('Language') |
| 13 | 14 | |
| 14 | 15 | settings_items :language |
| 16 | + settings_items :requires_email, :type => :boolean | |
| 17 | + | |
| 18 | + alias_method :requires_email?, :requires_email | |
| 15 | 19 | |
| 16 | 20 | extend SetProfileRegionFromCityState::ClassMethods |
| 17 | 21 | set_profile_region_from_city_state | ... | ... |
app/models/task.rb
| ... | ... | @@ -213,6 +213,10 @@ class Task < ApplicationRecord |
| 213 | 213 | false |
| 214 | 214 | end |
| 215 | 215 | |
| 216 | + def footer | |
| 217 | + false | |
| 218 | + end | |
| 219 | + | |
| 216 | 220 | def icon |
| 217 | 221 | {:type => :defined_image, :src => "/images/icons-app/user-minor.png", :name => requestor.name, :url => requestor.url} |
| 218 | 222 | end | ... | ... |
app/views/blocks/profile_info_actions/_join_leave_community.html.erb
| ... | ... | @@ -7,15 +7,12 @@ |
| 7 | 7 | <%= button :delete, content_tag('span', _('Leave community')), profile.leave_url, |
| 8 | 8 | class: 'leave-community', |
| 9 | 9 | style: 'position: relative;' %> |
| 10 | - <%= button :add, content_tag('span', _('Join this community')), profile.join_url, | |
| 11 | - class: 'join-community', | |
| 12 | - style: 'position: relative; display: none;' %> | |
| 13 | 10 | <% else %> |
| 14 | - <%= button :add, _('Join this community'), profile.join_url, class: 'join-community' %> | |
| 11 | + <%= join_community_button({:logged => true}) %> | |
| 15 | 12 | <% end %> |
| 16 | 13 | <% end %> |
| 17 | 14 | <% else %> |
| 18 | - <%= button :add, _('Join this community'), profile.join_not_logged_url %> | |
| 15 | + <%= join_community_button %> | |
| 19 | 16 | <% end %> |
| 20 | 17 | </div> |
| 21 | 18 | ... | ... |
app/views/profile/_private_profile.html.erb
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | |
| 8 | 8 | <% button_bar do %> |
| 9 | 9 | <% if @action == :join && logged_in? %> |
| 10 | - <%= button(:add, content_tag('span', _('Join')), profile.join_url, :class => 'join-community', :title => _("Join community"), :style => 'position: relative;') %> | |
| 10 | + <%= join_community_button({:logged => true}) %> | |
| 11 | 11 | <% end %> |
| 12 | 12 | <% if @action == :add_friend && logged_in? && !user.already_request_friendship?(profile) %> |
| 13 | 13 | <%= button(:add, content_tag('span', _('Add friend')), profile.add_url, :class => 'add-friend', :title => _("Add friend"), :style => 'position: relative;') %> | ... | ... |
app/views/profile/join.html.erb
| 1 | -<h1><%= _('Joining %s') % profile.name %></h1> | |
| 1 | +<div class="join-community-confirmation"> | |
| 2 | 2 | |
| 3 | -<p> | |
| 4 | -<%= _('Are you sure you want to join %s?') % profile.name %> | |
| 5 | -</p> | |
| 3 | + <h1><%= _('To join %s, you must:') % profile.name %></h1> | |
| 6 | 4 | |
| 7 | -<%= form_tag do %> | |
| 8 | - <%= hidden_field_tag('back_to', @back_to) %> | |
| 9 | - <%= hidden_field_tag(:confirmation, 1) %> | |
| 10 | - <%= submit_button(:ok, _("Yes, I want to join.") % profile.name) %> | |
| 11 | - <% if logged_in? && request.xhr? %> | |
| 12 | - <%= modal_close_button _("No, I don't want") %> | |
| 13 | - <% else %> | |
| 14 | - <%= button(:cancel, _("No, I don't want."), profile.url) %> | |
| 5 | + <p> | |
| 6 | + <%= _("Authorize the visibility of your email address to the community administrator.") %> | |
| 7 | + </p> | |
| 8 | + | |
| 9 | + <%= form_tag url_for({:action => :join_modal, :controller => :profile}) do %> | |
| 10 | + <%= hidden_field_tag('back_to', @back_to) %> | |
| 11 | + <%= submit_button(:ok, _("Authorize")) %> | |
| 12 | + <%= modal_close_button _("Cancel") %> | |
| 15 | 13 | <% end %> |
| 16 | -<% end %> | |
| 14 | + | |
| 15 | +</div> | |
| 16 | + | ... | ... |
app/views/profile_editor/_moderation.html.erb
| ... | ... | @@ -9,7 +9,6 @@ |
| 9 | 9 | <%= _('Send administrator Email for every task') %> |
| 10 | 10 | </div> |
| 11 | 11 | </div> |
| 12 | - | |
| 13 | 12 | <div style='margin-bottom: 1em'> |
| 14 | 13 | <h4><%= _('Invitation moderation:')%></h4> |
| 15 | 14 | </div> |
| ... | ... | @@ -36,6 +35,12 @@ |
| 36 | 35 | <div style='margin-left: 30px'> |
| 37 | 36 | <%= _('<strong>Before</strong> joining this group (a moderator has to accept the member in pending request before member can access the intranet and/or the website).').html_safe %> |
| 38 | 37 | </div> |
| 38 | + <div id = "requires_email_option" style="margin-left: 30px; margin-top: 10px; margin-bottom: 15px;<%=" display: none;" unless profile.closed? %>"> | |
| 39 | + <%= check_box(:profile_data, :requires_email, :style => 'float: left') %> | |
| 40 | + <div style='margin-left: 30px'> | |
| 41 | + <%= _('New members must allow email visibility to the profile admin') %> | |
| 42 | + </div> | |
| 43 | + </div> | |
| 39 | 44 | </div> |
| 40 | 45 | <div> |
| 41 | 46 | <%= radio_button 'profile_data', 'closed', 'false', :style => 'float: left' %> | ... | ... |
app/views/tasks/_task.html.erb
| ... | ... | @@ -77,4 +77,10 @@ |
| 77 | 77 | |
| 78 | 78 | <% end %> |
| 79 | 79 | |
| 80 | + <% if task.footer %> | |
| 81 | + <div id="task-footer-<%=task.id%>"> | |
| 82 | + <%= render :partial => partial_for_class(task.class, nil, :footer), :locals => {:task => task} %> | |
| 83 | + </div> | |
| 84 | + <% end %> | |
| 85 | + | |
| 80 | 86 | </div><!-- class="task_box" --> | ... | ... |
| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | +This plugin is the new version of "environment_notification" plugin. | |
| 2 | + | |
| 3 | +New features added: | |
| 4 | + - Create a notification for an organization; | |
| 5 | + - Only profile admin can create notifications; | |
| 6 | + - Organization notifications can be seen by members from any of the organization pages; | |
| 7 | + - home_page option set the notification to be seen only at organization homepage; | ... | ... |
plugins/admin_notifications/controllers/admin_notifications_plugin_admin_controller.rb
0 → 100644
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +class AdminNotificationsPluginAdminController < AdminController | |
| 2 | + | |
| 3 | + include AdminNotificationsPlugin::NotificationManager | |
| 4 | + | |
| 5 | + before_filter :admin_required | |
| 6 | + | |
| 7 | + protected | |
| 8 | + def target | |
| 9 | + environment | |
| 10 | + end | |
| 11 | + | |
| 12 | + def admin_required | |
| 13 | + redirect_to :root unless current_person.is_admin? | |
| 14 | + end | |
| 15 | + | |
| 16 | +end | ... | ... |
plugins/admin_notifications/controllers/admin_notifications_plugin_myprofile_controller.rb
0 → 100644
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +class AdminNotificationsPluginMyprofileController < MyProfileController | |
| 2 | + | |
| 3 | + include AdminNotificationsPlugin::NotificationManager | |
| 4 | + | |
| 5 | + before_filter :admin_required | |
| 6 | + | |
| 7 | + protected | |
| 8 | + def target | |
| 9 | + profile | |
| 10 | + end | |
| 11 | + | |
| 12 | + def admin_required | |
| 13 | + redirect_to :root unless target.is_admin?(current_person) | |
| 14 | + end | |
| 15 | + | |
| 16 | +end | ... | ... |
plugins/admin_notifications/controllers/public/admin_notifications_plugin_public_controller.rb
0 → 100644
| ... | ... | @@ -0,0 +1,48 @@ |
| 1 | +class AdminNotificationsPluginPublicController < PublicController | |
| 2 | + | |
| 3 | + helper AdminNotificationsPlugin::NotificationHelper | |
| 4 | + include AdminNotificationsPlugin::NotificationHelper | |
| 5 | + | |
| 6 | + def notifications_with_popup | |
| 7 | + @hide_notifications = hide_notifications | |
| 8 | + if params[:previous_path] | |
| 9 | + @previous_path = params[:previous_path] | |
| 10 | + else | |
| 11 | + @previous_path = nil | |
| 12 | + end | |
| 13 | + end | |
| 14 | + | |
| 15 | + def close_notification | |
| 16 | + result = false | |
| 17 | + | |
| 18 | + if logged_in? | |
| 19 | + @notification = AdminNotificationsPlugin::Notification.find_by_id(params[:notification_id]) | |
| 20 | + | |
| 21 | + if @notification | |
| 22 | + @notification.users << current_user | |
| 23 | + result = @notification.users.include?(current_user) | |
| 24 | + end | |
| 25 | + end | |
| 26 | + | |
| 27 | + render json: result | |
| 28 | + end | |
| 29 | + | |
| 30 | + def hide_notification | |
| 31 | + result = false | |
| 32 | + | |
| 33 | + if logged_in? | |
| 34 | + @notification = AdminNotificationsPlugin::Notification.find_by_id(params[:notification_id]) | |
| 35 | + | |
| 36 | + if @notification | |
| 37 | + current_notificaions = [] | |
| 38 | + current_notificaions = JSON.parse(cookies[:hide_notifications]) unless cookies[:hide_notifications].blank? | |
| 39 | + current_notificaions << @notification.id unless current_notificaions.include? @notification.id | |
| 40 | + cookies[:hide_notifications] = JSON.generate(current_notificaions) | |
| 41 | + result = current_notificaions.include? @notification.id | |
| 42 | + end | |
| 43 | + end | |
| 44 | + | |
| 45 | + render json: result | |
| 46 | + end | |
| 47 | + | |
| 48 | +end | ... | ... |
plugins/admin_notifications/db/migrate/20150721132025_create_notification_table.rb
0 → 100644
| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | +class CreateNotificationTable < ActiveRecord::Migration | |
| 2 | + def up | |
| 3 | + create_table :environment_notifications do |t| | |
| 4 | + t.text :message | |
| 5 | + t.integer :environment_id | |
| 6 | + t.string :type | |
| 7 | + t.string :title | |
| 8 | + t.boolean :active | |
| 9 | + t.boolean :display_only_in_homepage, :default => false | |
| 10 | + t.boolean :display_to_all_users, :default => false | |
| 11 | + t.boolean :display_popup, :default => false | |
| 12 | + t.column :created_at, :datetime | |
| 13 | + t.column :updated_at, :datetime | |
| 14 | + end | |
| 15 | + | |
| 16 | + create_table :environment_notifications_users, id: false do |t| | |
| 17 | + t.belongs_to :environment_notification | |
| 18 | + t.belongs_to :user | |
| 19 | + end | |
| 20 | + add_index :environment_notifications_users, [:environment_notification_id], name: :index_Zaem6uuw | |
| 21 | + add_index :environment_notifications_users, [:user_id], name: :index_ap3nohR9 | |
| 22 | + end | |
| 23 | + | |
| 24 | + def down | |
| 25 | + drop_table :environment_notifications | |
| 26 | + drop_table :environment_notifications_users | |
| 27 | + end | |
| 28 | +end | ... | ... |
plugins/admin_notifications/db/migrate/20160321190726_change_notification_relation_to_polymorphic.rb
0 → 100644
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +class ChangeNotificationRelationToPolymorphic < ActiveRecord::Migration | |
| 2 | + def up | |
| 3 | + rename_column(:environment_notifications, :environment_id, :target_id) | |
| 4 | + add_column(:environment_notifications, :target_type, :string) | |
| 5 | + | |
| 6 | + execute("UPDATE environment_notifications SET target_type = 'Environment'") | |
| 7 | + end | |
| 8 | + | |
| 9 | + def down | |
| 10 | + rename_column(:environment_notifications, :target_id, :environment_id) | |
| 11 | + remove_column(:environment_notifications, :target_type) | |
| 12 | + end | |
| 13 | +end | ... | ... |
plugins/admin_notifications/db/migrate/20160330171610_rename_plugin_tables.rb
0 → 100644
| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | +class RenamePluginTables < ActiveRecord::Migration | |
| 2 | + def up | |
| 3 | + remove_index :environment_notifications_users, name: :index_Zaem6uuw | |
| 4 | + remove_index :environment_notifications_users, name: :index_ap3nohR9 | |
| 5 | + | |
| 6 | + rename_column :environment_notifications_users, :environment_notification_id, :notification_id | |
| 7 | + | |
| 8 | + rename_table :environment_notifications, :admin_notifications_plugin_notifications | |
| 9 | + rename_table :environment_notifications_users, :admin_notifications_plugin_notifications_users | |
| 10 | + | |
| 11 | + add_index :admin_notifications_plugin_notifications_users, [:notification_id], :name => :index_notifications_users_notification_id | |
| 12 | + add_index :admin_notifications_plugin_notifications_users, [:user_id], :name => :index_notifications_users_user_id | |
| 13 | + | |
| 14 | + Environment.all.each do |e| | |
| 15 | + if e.enabled_plugins.include?('EnvironmentNotificationPlugin') | |
| 16 | + e.enabled_plugins -= ['EnvironmentNotificationPlugin'] | |
| 17 | + e.enabled_plugins += ['AdminNotificationsPlugin'] | |
| 18 | + e.save! | |
| 19 | + end | |
| 20 | + end | |
| 21 | + end | |
| 22 | + | |
| 23 | + def down | |
| 24 | + remove_index :admin_notifications_plugin_notifications_users, :name => :index_notifications_users_notification_id | |
| 25 | + remove_index :admin_notifications_plugin_notifications_users, :name => :index_notifications_users_user_id | |
| 26 | + | |
| 27 | + rename_table :admin_notifications_plugin_notifications, :environment_notifications | |
| 28 | + rename_table :admin_notifications_plugin_notifications_users, :environment_notifications_users | |
| 29 | + | |
| 30 | + rename_column :environment_notifications_users, :notification_id, :environment_notification_id | |
| 31 | + | |
| 32 | + add_index :environment_notifications_users, [:environment_notification_id], name: :index_Zaem6uuw | |
| 33 | + add_index :environment_notifications_users, [:user_id], name: :index_ap3nohR9 | |
| 34 | + end | |
| 35 | + | |
| 36 | + Environment.all.each do |e| | |
| 37 | + if e.enabled_plugins.include?('AdminNotificationsPlugin') | |
| 38 | + e.enabled_plugins -= ['AdminNotificationsPlugin'] | |
| 39 | + e.enabled_plugins += ['EnvironmentNotificationPlugin'] | |
| 40 | + e.save! | |
| 41 | + end | |
| 42 | + end | |
| 43 | +end | ... | ... |
plugins/admin_notifications/db/migrate/20160505142214_change_type_to_new_namespace.rb
0 → 100644
| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | +class ChangeTypeToNewNamespace < ActiveRecord::Migration | |
| 2 | + def up | |
| 3 | + notification_types = %w(InformationNotification DangerNotification SuccessNotification WarningNotification) | |
| 4 | + notification_types.each do |notification_type| | |
| 5 | + execute("update admin_notifications_plugin_notifications set type = 'AdminNotificationsPlugin::#{notification_type}' where type = 'EnvironmentNotificationPlugin::#{notification_type}'") | |
| 6 | + end | |
| 7 | + end | |
| 8 | +end | ... | ... |
plugins/admin_notifications/features/message_edition.feature
0 → 100644
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +Feature: Create envronment notification message | |
| 2 | + As an admin user | |
| 3 | + I want to create a notification | |
| 4 | + In order to notificate users | |
| 5 | + | |
| 6 | + @selenium | |
| 7 | + Scenario: mce restricted mode should show on message creation | |
| 8 | + Given I am logged in as admin | |
| 9 | + And I follow "Administration" | |
| 10 | + And I follow "Plugins" | |
| 11 | + And I follow "Configuration" | |
| 12 | + And I follow "New Notification" | |
| 13 | + Then The tinymce "toolbar1" should be "bold italic underline | link" | |
| 14 | + Then The tinymce "menubar" should be "false" | ... | ... |
plugins/admin_notifications/lib/admin_notifications_plugin.rb
0 → 100644
| ... | ... | @@ -0,0 +1,59 @@ |
| 1 | +class AdminNotificationsPlugin < Noosfero::Plugin | |
| 2 | + | |
| 3 | + def self.plugin_name | |
| 4 | + "Notifications Plugin" | |
| 5 | + end | |
| 6 | + | |
| 7 | + def self.plugin_description | |
| 8 | + _("A plugin for notifications.") | |
| 9 | + end | |
| 10 | + | |
| 11 | + def stylesheet? | |
| 12 | + true | |
| 13 | + end | |
| 14 | + | |
| 15 | + def js_files | |
| 16 | + %w( | |
| 17 | + admin_notifications_plugin.js | |
| 18 | + ) | |
| 19 | + end | |
| 20 | + | |
| 21 | + def body_beginning | |
| 22 | + lambda do | |
| 23 | + extend AdminNotificationsPlugin::NotificationHelper | |
| 24 | + render template: 'shared/show_notification' | |
| 25 | + end | |
| 26 | + end | |
| 27 | + | |
| 28 | + def admin_panel_links | |
| 29 | + {:title => _('Notification Manager'), :url => {:controller => 'admin_notifications_plugin_admin', :action => 'index'}} | |
| 30 | + end | |
| 31 | + | |
| 32 | + def control_panel_buttons | |
| 33 | + if context.profile.organization? | |
| 34 | + { | |
| 35 | + :title => _('Manage Notifications'), | |
| 36 | + :icon => 'important', | |
| 37 | + :url => { | |
| 38 | + :controller => 'admin_notifications_plugin_myprofile', | |
| 39 | + :action => 'index' | |
| 40 | + } | |
| 41 | + } | |
| 42 | + end | |
| 43 | + end | |
| 44 | + | |
| 45 | + def account_controller_filters | |
| 46 | + block = proc do | |
| 47 | + if !logged_in? | |
| 48 | + cookies[:hide_notifications] = nil | |
| 49 | + end | |
| 50 | + end | |
| 51 | + | |
| 52 | + [{ | |
| 53 | + :type => "after_filter", | |
| 54 | + :method_name => "clean_hide_notifications_cookie", | |
| 55 | + :options => { }, | |
| 56 | + :block => block | |
| 57 | + }] | |
| 58 | + end | |
| 59 | +end | ... | ... |
plugins/admin_notifications/lib/admin_notifications_plugin/notification_helper.rb
0 → 100644
| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | +module AdminNotificationsPlugin::NotificationHelper | |
| 2 | + | |
| 3 | + def hide_notifications | |
| 4 | + invalid_id = -1 | |
| 5 | + hide_notifications_ids = [invalid_id] | |
| 6 | + hide_notifications_ids = JSON.parse(cookies[:hide_notifications]) unless cookies[:hide_notifications].blank? | |
| 7 | + hide_notifications_ids | |
| 8 | + end | |
| 9 | + | |
| 10 | + def self.substitute_variables(message, user) | |
| 11 | + if user | |
| 12 | + message = message.gsub("%{email}", user.person.email).gsub("%{name}", user.person.name) | |
| 13 | + end | |
| 14 | + | |
| 15 | + message | |
| 16 | + end | |
| 17 | + | |
| 18 | +end | ... | ... |
plugins/admin_notifications/lib/admin_notifications_plugin/notification_manager.rb
0 → 100644
| ... | ... | @@ -0,0 +1,60 @@ |
| 1 | +module AdminNotificationsPlugin::NotificationManager | |
| 2 | + | |
| 3 | + def index | |
| 4 | + @notifications = target.notifications.order('updated_at DESC') | |
| 5 | + end | |
| 6 | + | |
| 7 | + def new | |
| 8 | + @notification = AdminNotificationsPlugin::Notification.new | |
| 9 | + if request.post? | |
| 10 | + @notification = AdminNotificationsPlugin::Notification.new(params[:notifications]) | |
| 11 | + @notification.message = @notification.message.html_safe | |
| 12 | + @notification.target = target | |
| 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 = target.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 = target.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 = target.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 | +end | ... | ... |
plugins/admin_notifications/lib/admin_notifications_plugin/notifications_user.rb
0 → 100644
| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | +class AdminNotificationsPlugin::NotificationsUser < ActiveRecord::Base | |
| 2 | + self.table_name = "admin_notifications_plugin_notifications_users" | |
| 3 | + | |
| 4 | + belongs_to :user | |
| 5 | + belongs_to :notification, class_name: 'AdminNotificationsPlugin::Notification' | |
| 6 | + | |
| 7 | + attr_accessible :user_id, :notification_id | |
| 8 | + | |
| 9 | + validates_uniqueness_of :user_id, :scope => :notification_id | |
| 10 | +end | ... | ... |
plugins/admin_notifications/models/admin_notifications_plugin/danger_notification.rb
0 → 100644
plugins/admin_notifications/models/admin_notifications_plugin/information_notification.rb
0 → 100644
plugins/admin_notifications/models/admin_notifications_plugin/notification.rb
0 → 100644
| ... | ... | @@ -0,0 +1,56 @@ |
| 1 | +class AdminNotificationsPlugin::Notification < ActiveRecord::Base | |
| 2 | + | |
| 3 | + self.table_name = "admin_notifications_plugin_notifications" | |
| 4 | + | |
| 5 | + TYPE_LIST = [ | |
| 6 | + "AdminNotificationsPlugin::WarningNotification", | |
| 7 | + "AdminNotificationsPlugin::SuccessNotification", | |
| 8 | + "AdminNotificationsPlugin::InformationNotification", | |
| 9 | + "AdminNotificationsPlugin::DangerNotification" | |
| 10 | + ] | |
| 11 | + | |
| 12 | + attr_accessible :message, :target_id, :active, :type, :display_only_in_homepage, :display_to_all_users, :display_popup, :title, :target | |
| 13 | + | |
| 14 | + has_many :notifications_users, :class_name => "AdminNotificationsPlugin::NotificationsUser" | |
| 15 | + has_many :users, :through => :notifications_users | |
| 16 | + | |
| 17 | + belongs_to :target, :polymorphic => true | |
| 18 | + | |
| 19 | + validates_presence_of :message | |
| 20 | + validates_presence_of :target_id | |
| 21 | + validate :notification_type_must_be_in_type_list | |
| 22 | + | |
| 23 | + def notification_type_must_be_in_type_list | |
| 24 | + unless TYPE_LIST.include?(type) | |
| 25 | + errors.add(:type, "invalid notification type") | |
| 26 | + end | |
| 27 | + end | |
| 28 | + | |
| 29 | + scope :active, lambda{|target| where(:target_id => (target.kind_of?(Organization) ? [target.id, target.environment.id] : target.id), :active => true)} | |
| 30 | + | |
| 31 | + def self.visibles(target, user, controller_path) | |
| 32 | + notifications = AdminNotificationsPlugin::Notification.active(target).order('updated_at DESC') | |
| 33 | + | |
| 34 | + if user | |
| 35 | + active_notifications_ids = notifications.pluck(:id) - user.notifications.pluck(:id) | |
| 36 | + | |
| 37 | + notifications = notifications.where(id: active_notifications_ids) | |
| 38 | + else | |
| 39 | + notifications = notifications.where(display_to_all_users: true) | |
| 40 | + end | |
| 41 | + | |
| 42 | + if controller_path != "home" | |
| 43 | + notifications = notifications.where.not("display_only_in_homepage = ? AND target_type = ?",true,"Environment") | |
| 44 | + if controller_path != "profile" | |
| 45 | + notifications = notifications.where.not("display_only_in_homepage = ? AND target_type = ?",true,"Profile") | |
| 46 | + end | |
| 47 | + end | |
| 48 | + | |
| 49 | + notifications | |
| 50 | + end | |
| 51 | + | |
| 52 | + def self.with_popup(target, user, previous_path) | |
| 53 | + AdminNotificationsPlugin::Notification.visibles(target, user, previous_path).where(display_popup: true) | |
| 54 | + end | |
| 55 | + | |
| 56 | +end | ... | ... |
plugins/admin_notifications/models/admin_notifications_plugin/success_notification.rb
0 → 100644
plugins/admin_notifications/models/admin_notifications_plugin/warning_notification.rb
0 → 100644
| ... | ... | @@ -0,0 +1,187 @@ |
| 1 | +# SOME DESCRIPTIVE TITLE. | |
| 2 | +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | |
| 3 | +# This file is distributed under the same license as the PACKAGE package. | |
| 4 | +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | |
| 5 | +# | |
| 6 | +#, fuzzy | |
| 7 | +msgid "" | |
| 8 | +msgstr "" | |
| 9 | +"Project-Id-Version: PACKAGE VERSION\n" | |
| 10 | +"Report-Msgid-Bugs-To: \n" | |
| 11 | +"POT-Creation-Date: 2016-03-31 15:02-0300\n" | |
| 12 | +"PO-Revision-Date: 2016-03-31 15:02-0300\n" | |
| 13 | +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
| 14 | +"Language-Team: LANGUAGE <LL@li.org>\n" | |
| 15 | +"Language: \n" | |
| 16 | +"MIME-Version: 1.0\n" | |
| 17 | +"Content-Type: text/plain; charset=UTF-8\n" | |
| 18 | +"Content-Transfer-Encoding: 8bit\n" | |
| 19 | +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" | |
| 20 | + | |
| 21 | +#: ../lib/notification_plugin.rb:8 | |
| 22 | +msgid "A plugin for notifications." | |
| 23 | +msgstr "" | |
| 24 | + | |
| 25 | +#: ../lib/notification_plugin.rb:29 | |
| 26 | +msgid "Notification Manager" | |
| 27 | +msgstr "" | |
| 28 | + | |
| 29 | +#: ../lib/notification_plugin.rb:35 | |
| 30 | +msgid "Manage Notifications" | |
| 31 | +msgstr "" | |
| 32 | + | |
| 33 | +#: ../lib/notification_plugin/notification_manager.rb:14 | |
| 34 | +msgid "Notification successfully created" | |
| 35 | +msgstr "" | |
| 36 | + | |
| 37 | +#: ../lib/notification_plugin/notification_manager.rb:17 | |
| 38 | +msgid "Notification couldn't be created" | |
| 39 | +msgstr "" | |
| 40 | + | |
| 41 | +#: ../lib/notification_plugin/notification_manager.rb:26 | |
| 42 | +msgid "The notification was deleted." | |
| 43 | +msgstr "" | |
| 44 | + | |
| 45 | +#: ../lib/notification_plugin/notification_manager.rb:28 | |
| 46 | +msgid "Could not remove the notification" | |
| 47 | +msgstr "" | |
| 48 | + | |
| 49 | +#: ../lib/notification_plugin/notification_manager.rb:38 | |
| 50 | +msgid "The notification was edited." | |
| 51 | +msgstr "" | |
| 52 | + | |
| 53 | +#: ../lib/notification_plugin/notification_manager.rb:40 | |
| 54 | +msgid "Could not edit the notification." | |
| 55 | +msgstr "" | |
| 56 | + | |
| 57 | +#: ../lib/notification_plugin/notification_manager.rb:52 | |
| 58 | +msgid "The status of the notification was changed." | |
| 59 | +msgstr "" | |
| 60 | + | |
| 61 | +#: ../lib/notification_plugin/notification_manager.rb:54 | |
| 62 | +msgid "Could not change the status of the notification." | |
| 63 | +msgstr "" | |
| 64 | + | |
| 65 | +#: ../views/shared/_form.html.erb:5 | |
| 66 | +msgid "Back" | |
| 67 | +msgstr "" | |
| 68 | + | |
| 69 | +#: ../views/shared/_form.html.erb:11 | |
| 70 | +msgid "Optional Title:" | |
| 71 | +msgstr "" | |
| 72 | + | |
| 73 | +#: ../views/shared/_form.html.erb:13 | |
| 74 | +msgid "Enter your message here:" | |
| 75 | +msgstr "" | |
| 76 | + | |
| 77 | +#: ../views/shared/_form.html.erb:15 | |
| 78 | +msgid "" | |
| 79 | +"Obs: You can use %{name} and %{email} variables to put the user's name and ema" | |
| 80 | +"il in the message." | |
| 81 | +msgstr "" | |
| 82 | + | |
| 83 | +#: ../views/shared/_form.html.erb:18 | |
| 84 | +msgid "Notifications Status" | |
| 85 | +msgstr "" | |
| 86 | + | |
| 87 | +#: ../views/shared/_form.html.erb:18 | |
| 88 | +msgid "Active" | |
| 89 | +msgstr "" | |
| 90 | + | |
| 91 | +#: ../views/shared/_form.html.erb:18 | |
| 92 | +msgid "Inactive" | |
| 93 | +msgstr "" | |
| 94 | + | |
| 95 | +#: ../views/shared/_form.html.erb:20 | |
| 96 | +msgid "Notifications Color/Type" | |
| 97 | +msgstr "" | |
| 98 | + | |
| 99 | +#: ../views/shared/_form.html.erb:20 | |
| 100 | +msgid "Blue - Information" | |
| 101 | +msgstr "" | |
| 102 | + | |
| 103 | +#: ../views/shared/_form.html.erb:20 | |
| 104 | +msgid "Yellow - Warning" | |
| 105 | +msgstr "" | |
| 106 | + | |
| 107 | +#: ../views/shared/_form.html.erb:20 | |
| 108 | +msgid "Green - Success" | |
| 109 | +msgstr "" | |
| 110 | + | |
| 111 | +#: ../views/shared/_form.html.erb:20 | |
| 112 | +msgid "Red - Danger" | |
| 113 | +msgstr "" | |
| 114 | + | |
| 115 | +#: ../views/shared/_form.html.erb:23 | |
| 116 | +msgid "Display only in the homepage" | |
| 117 | +msgstr "" | |
| 118 | + | |
| 119 | +#: ../views/shared/_form.html.erb:27 | |
| 120 | +msgid "Display to not logged users too" | |
| 121 | +msgstr "" | |
| 122 | + | |
| 123 | +#: ../views/shared/_form.html.erb:31 | |
| 124 | +msgid "Display popup until user close the notification" | |
| 125 | +msgstr "" | |
| 126 | + | |
| 127 | +#: ../views/shared/_form.html.erb:35 | |
| 128 | +msgid "Save" | |
| 129 | +msgstr "" | |
| 130 | + | |
| 131 | +#: ../views/shared/_notifications_list.html.erb:3 | |
| 132 | +#: ../views/shared/_notifications_list.html.erb:16 | |
| 133 | +msgid "Notifications" | |
| 134 | +msgstr "" | |
| 135 | + | |
| 136 | +#: ../views/shared/_notifications_list.html.erb:7 | |
| 137 | +msgid "New Notification" | |
| 138 | +msgstr "" | |
| 139 | + | |
| 140 | +#: ../views/shared/_notifications_list.html.erb:10 | |
| 141 | +msgid "Back to control panel" | |
| 142 | +msgstr "" | |
| 143 | + | |
| 144 | +#: ../views/shared/_notifications_list.html.erb:19 | |
| 145 | +msgid "Actions" | |
| 146 | +msgstr "" | |
| 147 | + | |
| 148 | +#: ../views/shared/_notifications_list.html.erb:30 | |
| 149 | +msgid "Deactivate" | |
| 150 | +msgstr "" | |
| 151 | + | |
| 152 | +#: ../views/shared/_notifications_list.html.erb:30 | |
| 153 | +#: ../views/shared/_notifications_list.html.erb:32 | |
| 154 | +msgid "Do you want to change the status of this notification?" | |
| 155 | +msgstr "" | |
| 156 | + | |
| 157 | +#: ../views/shared/_notifications_list.html.erb:32 | |
| 158 | +msgid "Activate" | |
| 159 | +msgstr "" | |
| 160 | + | |
| 161 | +#: ../views/shared/_notifications_list.html.erb:34 | |
| 162 | +msgid "Edit" | |
| 163 | +msgstr "" | |
| 164 | + | |
| 165 | +#: ../views/shared/_notifications_list.html.erb:35 | |
| 166 | +msgid "Delete" | |
| 167 | +msgstr "" | |
| 168 | + | |
| 169 | +#: ../views/shared/_notifications_list.html.erb:35 | |
| 170 | +msgid "Do you want to delete this notification?" | |
| 171 | +msgstr "" | |
| 172 | + | |
| 173 | +#: ../views/shared/show_notification.html.erb:8 | |
| 174 | +msgid "There are active notifications in this environment!" | |
| 175 | +msgstr "" | |
| 176 | + | |
| 177 | +#: ../views/shared/show_notification.html.erb:9 | |
| 178 | +msgid "Manage all notifications here." | |
| 179 | +msgstr "" | |
| 180 | + | |
| 181 | +#: ../views/shared/show_notification.html.erb:28 | |
| 182 | +msgid "Do not show anymore" | |
| 183 | +msgstr "" | |
| 184 | + | |
| 185 | +#: ../views/shared/show_notification.html.erb:29 | |
| 186 | +msgid "Hide for now" | |
| 187 | +msgstr "" | ... | ... |
plugins/admin_notifications/public/admin_notifications_plugin.js
0 → 100644
| ... | ... | @@ -0,0 +1,84 @@ |
| 1 | +(function($) { | |
| 2 | + "use strict"; | |
| 3 | + | |
| 4 | + var admin_notifications_plugin = { | |
| 5 | + | |
| 6 | + | |
| 7 | + notificationBar: function() { | |
| 8 | + var completeMessage = $(".notification-plugin-notification-bar").remove(); | |
| 9 | + $("#content-inner").before(completeMessage); | |
| 10 | + }, | |
| 11 | + | |
| 12 | + closeNotification: function(){ | |
| 13 | + var notification = $(this).parent(); | |
| 14 | + var id = notification.attr("data-notification"); | |
| 15 | + | |
| 16 | + $.ajax({ | |
| 17 | + url: noosfero_root()+'/plugin/admin_notifications/public/close_notification', | |
| 18 | + type: "POST", | |
| 19 | + data: {notification_id: id}, | |
| 20 | + success: function(response) { | |
| 21 | + notification.fadeOut(); | |
| 22 | + } | |
| 23 | + }); | |
| 24 | + }, | |
| 25 | + | |
| 26 | + hideNotification: function(){ | |
| 27 | + var notification = $(this).parent(); | |
| 28 | + var id = notification.attr("data-notification"); | |
| 29 | + | |
| 30 | + $.ajax({ | |
| 31 | + url: noosfero_root()+'/plugin/admin_notifications/public/hide_notification', | |
| 32 | + type: "POST", | |
| 33 | + data: {notification_id: id}, | |
| 34 | + success: function(response) { | |
| 35 | + notification.fadeOut(); | |
| 36 | + } | |
| 37 | + }); | |
| 38 | + }, | |
| 39 | + | |
| 40 | + hideUserNotification: function(){ | |
| 41 | + var ids = $.cookie('hide_notifications'); | |
| 42 | + if(ids === null) { | |
| 43 | + return null; | |
| 44 | + } | |
| 45 | + | |
| 46 | + if(ids.startsWith('[') && ids.endsWith(']')){ | |
| 47 | + ids = ids.substring(1, ids.length - 1); | |
| 48 | + ids = ids.split(","); | |
| 49 | + | |
| 50 | + for(var i = 0; i < ids.length; i++) { | |
| 51 | + $('[data-notification="' + ids[i] + '"]').fadeOut(); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + }, | |
| 55 | + | |
| 56 | + showPopup: function() { | |
| 57 | + if($('.action-home-index').length > 0) { | |
| 58 | + jQuery(function($){ | |
| 59 | + $.colorbox({href: noosfero_root()+'/plugin/admin_notifications/public/notifications_with_popup?previous_path=home'}); | |
| 60 | + }); | |
| 61 | + } | |
| 62 | + else { | |
| 63 | + jQuery(function($){ | |
| 64 | + $.colorbox({href: noosfero_root()+'/plugin/admin_notifications/public/notifications_with_popup'}); | |
| 65 | + }); | |
| 66 | + } | |
| 67 | + }, | |
| 68 | + }; | |
| 69 | + | |
| 70 | + $(document).ready(function(){ | |
| 71 | + admin_notifications_plugin.notificationBar(); | |
| 72 | + $(".notification-plugin-notification-bar .notification-close").on("click", admin_notifications_plugin.closeNotification); | |
| 73 | + $(".notification-plugin-notification-bar .notification-hide").on("click", admin_notifications_plugin.hideNotification); | |
| 74 | + | |
| 75 | + if($('.notification-plugin-notification-bar').length > 0){ | |
| 76 | + admin_notifications_plugin.hideUserNotification(); | |
| 77 | + } | |
| 78 | + | |
| 79 | + if($('.notification-plugin-notification-bar [notification-display-popup="true"]').length > 0){ | |
| 80 | + admin_notifications_plugin.showPopup(); | |
| 81 | + } | |
| 82 | + }); | |
| 83 | + | |
| 84 | +})($); | ... | ... |
240 Bytes
794 Bytes
389 Bytes
552 Bytes
364 Bytes
| ... | ... | @@ -0,0 +1,250 @@ |
| 1 | +.notification-plugin-notification-bar{ | |
| 2 | + display: block; | |
| 3 | +} | |
| 4 | + | |
| 5 | +.notification-plugin-notification-bar .notification:hover, | |
| 6 | +.notification-plugin-notification-modal .notification:hover{ | |
| 7 | + opacity: 0.8; | |
| 8 | +} | |
| 9 | + | |
| 10 | +#notification-plugin-notification-manager{ | |
| 11 | + overflow: auto; | |
| 12 | +} | |
| 13 | + | |
| 14 | +.notification-plugin-notification-bar .notification .notification-close, | |
| 15 | +.notification-plugin-notification-modal .notification .notification-close{ | |
| 16 | + background: url(images/close.png) no-repeat; | |
| 17 | + background-position: center; | |
| 18 | + width: 20px; | |
| 19 | + height: 20px; | |
| 20 | +} | |
| 21 | + | |
| 22 | +.notification-plugin-notification-bar .warningnotification, | |
| 23 | +.notification-plugin-notification-bar .informationnotification, | |
| 24 | +.notification-plugin-notification-bar .successnotification, | |
| 25 | +.notification-plugin-notification-bar .dangernotification, | |
| 26 | +.notification-plugin-notification-bar .adminnotification, | |
| 27 | +.notification-plugin-notification-modal .warningnotification, | |
| 28 | +.notification-plugin-notification-modal .informationnotification, | |
| 29 | +.notification-plugin-notification-modal .successnotification, | |
| 30 | +.notification-plugin-notification-modal .dangernotification{ | |
| 31 | + margin-bottom: 10px; | |
| 32 | + padding: 7px 10px; | |
| 33 | + border-radius: 5px; | |
| 34 | + border: 1px solid blue; | |
| 35 | + font-size: 16px; | |
| 36 | + color: white; | |
| 37 | + overflow: auto; | |
| 38 | +} | |
| 39 | + | |
| 40 | +.notification-plugin-notification-bar .warningnotification p, | |
| 41 | +.notification-plugin-notification-bar .informationnotification p, | |
| 42 | +.notification-plugin-notification-bar .successnotification p, | |
| 43 | +.notification-plugin-notification-bar .dangernotification p, | |
| 44 | +.notification-plugin-notification-bar .adminnotification p, | |
| 45 | +.notification-plugin-notification-modal .warningnotification p, | |
| 46 | +.notification-plugin-notification-modal .informationnotification p, | |
| 47 | +.notification-plugin-notification-modal .successnotification p, | |
| 48 | +.notification-plugin-notification-modal .dangernotification p{ | |
| 49 | + margin: 0px; | |
| 50 | +} | |
| 51 | + | |
| 52 | +.notification-plugin-notification-bar .warningnotification, | |
| 53 | +.notification-plugin-notification-modal .warningnotification{ | |
| 54 | + background: #fcf8e3; | |
| 55 | + border: 1px solid #faebcc; | |
| 56 | + color: #8a6d3b; | |
| 57 | +} | |
| 58 | + | |
| 59 | +.notification-plugin-notification-bar .warningnotification p a, | |
| 60 | +.notification-plugin-notification-modal .warningnotification p a{ | |
| 61 | + font-weight: bold; | |
| 62 | + color: #8a6d3b; | |
| 63 | +} | |
| 64 | + | |
| 65 | + | |
| 66 | +.notification-plugin-notification-bar .informationnotification, | |
| 67 | +.notification-plugin-notification-modal .informationnotification{ | |
| 68 | + background: #d9edf7; | |
| 69 | + border: 1px solid #bce8f1; | |
| 70 | + color: #31708f; | |
| 71 | +} | |
| 72 | + | |
| 73 | +.notification-plugin-notification-bar .informationnotification p a, | |
| 74 | +.notification-plugin-notification-modal .informationnotification p a{ | |
| 75 | + font-weight: bold; | |
| 76 | + color: #31708f; | |
| 77 | +} | |
| 78 | + | |
| 79 | +.notification-plugin-notification-bar .successnotification, | |
| 80 | +.notification-plugin-notification-modal .successnotification{ | |
| 81 | + background: #dff0d8; | |
| 82 | + border: 1px solid #d6e9c6; | |
| 83 | + color: #3c763d; | |
| 84 | +} | |
| 85 | + | |
| 86 | +.notification-plugin-notification-bar .successnotification p a | |
| 87 | +.notification-plugin-notification-modal .successnotification p a{ | |
| 88 | + font-weight: bold; | |
| 89 | + color: #3c763d; | |
| 90 | +} | |
| 91 | + | |
| 92 | +.notification-plugin-notification-bar .dangernotification, | |
| 93 | +.notification-plugin-notification-modal .dangernotification{ | |
| 94 | + background: #f2dede; | |
| 95 | + border: 1px solid #ebccd1; | |
| 96 | + color: #a94442; | |
| 97 | +} | |
| 98 | + | |
| 99 | +.notification-plugin-notification-bar .dangernotification p a, | |
| 100 | +.notification-plugin-notification-modal .dangernotification p a{ | |
| 101 | + font-weight: bold; | |
| 102 | + color: #a94442; | |
| 103 | +} | |
| 104 | + | |
| 105 | +.notification-plugin-notification-bar .adminnotification, | |
| 106 | +.notification-plugin-notification-modal .adminnotification{ | |
| 107 | + background: #9a959a; | |
| 108 | + border: 1px solid #9a959a; | |
| 109 | +} | |
| 110 | + | |
| 111 | +.notification-plugin-notification-bar .adminnotification p a, | |
| 112 | +.notification-plugin-notification-modal .adminnotification p a{ | |
| 113 | + font-weight: bold; | |
| 114 | + color: white; | |
| 115 | +} | |
| 116 | + | |
| 117 | +#notification-plugin-notification-manager a.button.icon-deactivate{ | |
| 118 | + background: url(images/hide.png) no-repeat; | |
| 119 | + background-position: center; | |
| 120 | +} | |
| 121 | + | |
| 122 | +#notification-plugin-notification-manager a.button.icon-activate{ | |
| 123 | + background: url(images/show.png) no-repeat; | |
| 124 | + background-position: center; | |
| 125 | +} | |
| 126 | + | |
| 127 | +#notification-plugin-notification-manager .notification-line{ | |
| 128 | + display: inline; | |
| 129 | + padding-top: 10px; | |
| 130 | + vertical-align: middle; | |
| 131 | + border-bottom: 1px solid #ccc; | |
| 132 | +} | |
| 133 | + | |
| 134 | +#notification-plugin-notification-manager .notification-title-bar{ | |
| 135 | + float: left; | |
| 136 | + width: 100%; | |
| 137 | + font-style: 14px; | |
| 138 | + font-weight: 700; | |
| 139 | + border-bottom: 2px solid black; | |
| 140 | + padding: 9px 0; | |
| 141 | +} | |
| 142 | + | |
| 143 | +#notification-plugin-notification-manager .notification-title{ | |
| 144 | + width: 80%; | |
| 145 | + float: left; | |
| 146 | + text-align: center; | |
| 147 | +} | |
| 148 | + | |
| 149 | +.notification-plugin-notification-modal .notification-with-title{ | |
| 150 | + margin-bottom: 0px; | |
| 151 | +} | |
| 152 | + | |
| 153 | +.notification-plugin-notification-modal .notification .notification-title{ | |
| 154 | + width: 100%; | |
| 155 | + float: left; | |
| 156 | + font-weight: bold; | |
| 157 | + text-align: left; | |
| 158 | +} | |
| 159 | + | |
| 160 | +.notification-plugin-notification-modal .notification-with-title-message{ | |
| 161 | + width: 100%; | |
| 162 | + float: left; | |
| 163 | + border-radius: 3px; | |
| 164 | + margin-bottom: 10px; | |
| 165 | + background-color: #f5f5f5; | |
| 166 | + font-size: 14px; | |
| 167 | + overflow: auto; | |
| 168 | +} | |
| 169 | + | |
| 170 | +.notification-plugin-notification-modal .notification-with-title-message p{ | |
| 171 | + padding: 0px 7px; | |
| 172 | +} | |
| 173 | + | |
| 174 | +.notification-plugin-notification-modal .notification-with-title-message p a{ | |
| 175 | + color: black; | |
| 176 | + font-weight: bold; | |
| 177 | +} | |
| 178 | + | |
| 179 | + | |
| 180 | +#notification-plugin-notification-manager .action-title{ | |
| 181 | + width: 20%; | |
| 182 | + float: left; | |
| 183 | + text-align: center; | |
| 184 | +} | |
| 185 | + | |
| 186 | +#notification-plugin-notification-manager .notification-action{ | |
| 187 | + width: 18%; | |
| 188 | + float: left; | |
| 189 | + height: 30px; | |
| 190 | + padding-top: 9px; | |
| 191 | +} | |
| 192 | + | |
| 193 | +#notification-plugin-notification-manager .main-bar .button, | |
| 194 | +#notification-plugin-notification-manager .notification-action .button{ | |
| 195 | + border-radius: 3px; | |
| 196 | +} | |
| 197 | + | |
| 198 | +#notification-plugin-notification-manager .notification-message{ | |
| 199 | + width: 82%; | |
| 200 | + float: left; | |
| 201 | +} | |
| 202 | + | |
| 203 | +#notification-plugin-notification-manager .new-notification{ | |
| 204 | + float: right; | |
| 205 | + width: auto; | |
| 206 | +} | |
| 207 | + | |
| 208 | +#notification-plugin-notification-manager .back-button{ | |
| 209 | + float: left; | |
| 210 | +} | |
| 211 | + | |
| 212 | +#notification-plugin-notification-manager .main-bar{ | |
| 213 | + display: inline; | |
| 214 | + width: 100%; | |
| 215 | +} | |
| 216 | + | |
| 217 | +.notification-plugin-notification-bar .notification .notification-message, | |
| 218 | +.notification-plugin-notification-modal .notification .notification-message{ | |
| 219 | + width: 90%; | |
| 220 | + float: left; | |
| 221 | +} | |
| 222 | + | |
| 223 | +.notification-plugin-notification-bar .notification .notification-close{ | |
| 224 | + background: url(images/redclose.png) no-repeat; | |
| 225 | + background-position: center; | |
| 226 | + width: 20px; | |
| 227 | + height: 20px; | |
| 228 | + float: right; | |
| 229 | + cursor: pointer; | |
| 230 | +} | |
| 231 | + | |
| 232 | +.notification-plugin-notification-bar .notification .notification-hide{ | |
| 233 | + background: url(images/greenhide.png) no-repeat; | |
| 234 | + background-position: center; | |
| 235 | + width: 20px; | |
| 236 | + height: 20px; | |
| 237 | + float: right; | |
| 238 | + cursor: pointer; | |
| 239 | +} | |
| 240 | + | |
| 241 | +.notification-plugin-notification-modal{ | |
| 242 | + display: block; | |
| 243 | + min-width: 400px; | |
| 244 | + max-width: 700px; | |
| 245 | +} | |
| 246 | + | |
| 247 | +.notification-plugin-form .notification-variables-options{ | |
| 248 | + font-style: italic; | |
| 249 | + color: red; | |
| 250 | +} | ... | ... |
plugins/admin_notifications/test/functional/account_controller_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | +require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' | |
| 2 | +require 'account_controller' | |
| 3 | + | |
| 4 | +class AccountController | |
| 5 | + include AdminNotificationsPlugin::NotificationHelper | |
| 6 | +end | |
| 7 | + | |
| 8 | +class AccountControllerTest < ActionController::TestCase | |
| 9 | + def setup | |
| 10 | + @controller = AccountController.new | |
| 11 | + @request = ActionController::TestRequest.new | |
| 12 | + @response = ActionController::TestResponse.new | |
| 13 | + @person = create_user('person').person | |
| 14 | + | |
| 15 | + @environment = Environment.default | |
| 16 | + @environment.enable_plugin('AdminNotificationsPlugin') | |
| 17 | + @environment.save! | |
| 18 | + | |
| 19 | + login_as(@person.user.login) | |
| 20 | + end | |
| 21 | + | |
| 22 | + attr_accessor :person | |
| 23 | + | |
| 24 | + should 'clean hide_notifications cookie after logout' do | |
| 25 | + @request.cookies[:hide_notifications] = JSON.generate([1,2]) | |
| 26 | + get :index | |
| 27 | + assert !@request.cookies[:hide_notifications].blank? | |
| 28 | + | |
| 29 | + @request.cookies[:hide_notifications] = nil | |
| 30 | + get :logout | |
| 31 | + assert_nil session[:user] | |
| 32 | + assert_response :redirect | |
| 33 | + assert_equal 1, @controller.hide_notifications.count | |
| 34 | + assert @controller.hide_notifications.include?(-1) | |
| 35 | + end | |
| 36 | +end | ... | ... |
plugins/admin_notifications/test/functional/admin_notifications_plugin_admin_controller_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,136 @@ |
| 1 | +require 'test_helper' | |
| 2 | +require_relative '../../controllers/admin_notifications_plugin_admin_controller' | |
| 3 | + | |
| 4 | +class AdminNotificationsPluginAdminControllerTest < ActionController::TestCase | |
| 5 | + def setup | |
| 6 | + @controller = AdminNotificationsPluginAdminController.new | |
| 7 | + @request = ActionController::TestRequest.new | |
| 8 | + @response = ActionController::TestResponse.new | |
| 9 | + @person = create_user('person').person | |
| 10 | + | |
| 11 | + @environment = Environment.default | |
| 12 | + @environment.enable_plugin('AdminNotificationsPlugin') | |
| 13 | + @environment.save! | |
| 14 | + | |
| 15 | + login_as(@person.user.login) | |
| 16 | + end | |
| 17 | + | |
| 18 | + attr_accessor :person | |
| 19 | + | |
| 20 | + should 'an admin be able to create a notification' do | |
| 21 | + @environment.add_admin(@person) | |
| 22 | + post :new, :notifications => { | |
| 23 | + :message => "Message", | |
| 24 | + :active => true, | |
| 25 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 26 | + } | |
| 27 | + assert_redirected_to :action => 'index' | |
| 28 | + notification = AdminNotificationsPlugin::Notification.last | |
| 29 | + assert_equal "Message", notification.message | |
| 30 | + assert notification.active | |
| 31 | + assert_equal "AdminNotificationsPlugin::DangerNotification", notification.type | |
| 32 | + end | |
| 33 | + | |
| 34 | + should 'an user not to be able to create a notification' do | |
| 35 | + post :new, :notifications => { | |
| 36 | + :message => "Message", | |
| 37 | + :active => true, | |
| 38 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 39 | + } | |
| 40 | + assert_redirected_to :root | |
| 41 | + assert_nil AdminNotificationsPlugin::Notification.last | |
| 42 | + end | |
| 43 | + | |
| 44 | + should 'an admin be able to edit a notification' do | |
| 45 | + @environment.add_admin(@person) | |
| 46 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 47 | + :target => @environment, | |
| 48 | + :message => "Message", | |
| 49 | + :active => true, | |
| 50 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 51 | + ) | |
| 52 | + post :edit, :id => @notification.id, :notifications => { | |
| 53 | + :message => "Edited Message", | |
| 54 | + :active => false, | |
| 55 | + :type => "AdminNotificationsPlugin::WarningNotification" | |
| 56 | + } | |
| 57 | + @notification = AdminNotificationsPlugin::Notification.last | |
| 58 | + assert_redirected_to :action => 'index' | |
| 59 | + assert_equal "Edited Message", @notification.message | |
| 60 | + assert !@notification.active | |
| 61 | + assert_equal "AdminNotificationsPlugin::WarningNotification", @notification.type | |
| 62 | + end | |
| 63 | + | |
| 64 | + should 'an user not to be able to edit a notification' do | |
| 65 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 66 | + :target => @environment, | |
| 67 | + :message => "Message", | |
| 68 | + :active => true, | |
| 69 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 70 | + ) | |
| 71 | + post :edit, :notifications => { | |
| 72 | + :message => "Edited Message", | |
| 73 | + :active => false, | |
| 74 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 75 | + } | |
| 76 | + @notification.reload | |
| 77 | + assert_redirected_to :root | |
| 78 | + assert_equal "Message", @notification.message | |
| 79 | + assert @notification.active | |
| 80 | + end | |
| 81 | + | |
| 82 | + should 'an admin be able to destroy a notification' do | |
| 83 | + @environment.add_admin(@person) | |
| 84 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 85 | + :target => @environment, | |
| 86 | + :message => "Message", | |
| 87 | + :active => true, | |
| 88 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 89 | + ) | |
| 90 | + delete :destroy, :id => @notification.id | |
| 91 | + assert_nil AdminNotificationsPlugin::Notification.find_by id: @notification.id | |
| 92 | + end | |
| 93 | + | |
| 94 | + should 'an user not to be able to destroy a notification' do | |
| 95 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 96 | + :target => @environment, | |
| 97 | + :message => "Message", | |
| 98 | + :active => true, | |
| 99 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 100 | + ) | |
| 101 | + delete :destroy, :id => @notification.id | |
| 102 | + | |
| 103 | + assert_redirected_to :root | |
| 104 | + assert_not_nil AdminNotificationsPlugin::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 = AdminNotificationsPlugin::Notification.create( | |
| 110 | + :target => @environment, | |
| 111 | + :message => "Message", | |
| 112 | + :active => true, | |
| 113 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 114 | + ) | |
| 115 | + post :change_status, :id => @notification.id | |
| 116 | + assert_redirected_to :action => 'index' | |
| 117 | + | |
| 118 | + @notification.reload | |
| 119 | + assert !@notification.active | |
| 120 | + end | |
| 121 | + | |
| 122 | + should 'an user not be able to change Notification status' do | |
| 123 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 124 | + :target => @environment, | |
| 125 | + :message => "Message", | |
| 126 | + :active => true, | |
| 127 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 128 | + ) | |
| 129 | + post :change_status, :id => @notification.id | |
| 130 | + assert_redirected_to :root | |
| 131 | + | |
| 132 | + @notification.reload | |
| 133 | + assert @notification.active | |
| 134 | + end | |
| 135 | + | |
| 136 | +end | ... | ... |
plugins/admin_notifications/test/functional/admin_notifications_plugin_myprofile_controller_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,147 @@ |
| 1 | +require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' | |
| 2 | +require( | |
| 3 | + File.expand_path(File.dirname(__FILE__)) + | |
| 4 | + '/../../controllers/admin_notifications_plugin_myprofile_controller' | |
| 5 | +) | |
| 6 | + | |
| 7 | +class AdminNotificationsPluginMyprofileControllerTest < ActionController::TestCase | |
| 8 | + def setup | |
| 9 | + @controller = AdminNotificationsPluginMyprofileController.new | |
| 10 | + @request = ActionController::TestRequest.new | |
| 11 | + @response = ActionController::TestResponse.new | |
| 12 | + @person = create_user('person').person | |
| 13 | + @community = fast_create(Community) | |
| 14 | + | |
| 15 | + environment = Environment.default | |
| 16 | + environment.enable_plugin('AdminNotificationsPlugin') | |
| 17 | + environment.save! | |
| 18 | + | |
| 19 | + login_as(@person.user.login) | |
| 20 | + AdminNotificationsPluginMyprofileController.any_instance.stubs(:profile).returns(@community) | |
| 21 | + end | |
| 22 | + | |
| 23 | + attr_accessor :person | |
| 24 | + | |
| 25 | + should 'profile admin be able to create a notification' do | |
| 26 | + @community.add_admin(@person) | |
| 27 | + post :new, :profile => @community.identifier, | |
| 28 | + :notifications => { | |
| 29 | + :message => "Message", | |
| 30 | + :active => true, | |
| 31 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 32 | + } | |
| 33 | + assert_redirected_to :action => 'index' | |
| 34 | + notification = AdminNotificationsPlugin::Notification.last | |
| 35 | + assert_equal "Message", notification.message | |
| 36 | + assert notification.active | |
| 37 | + assert_equal "AdminNotificationsPlugin::DangerNotification", notification.type | |
| 38 | + end | |
| 39 | + | |
| 40 | + should 'a regular user not to be able to create a notification' do | |
| 41 | + post :new, :profile => @community.identifier, | |
| 42 | + :notifications => { | |
| 43 | + :message => "Message", | |
| 44 | + :active => true, | |
| 45 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 46 | + } | |
| 47 | + | |
| 48 | + assert_redirected_to :root | |
| 49 | + assert_nil AdminNotificationsPlugin::Notification.last | |
| 50 | + end | |
| 51 | + | |
| 52 | + should 'profile admin be able to edit a notification' do | |
| 53 | + @community.add_admin(@person) | |
| 54 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 55 | + :target => @community, | |
| 56 | + :message => "Message", | |
| 57 | + :active => true, | |
| 58 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 59 | + ) | |
| 60 | + | |
| 61 | + post :edit, :profile => @community.identifier, :id => @notification.id, | |
| 62 | + :notifications => { | |
| 63 | + :message => "Edited Message", | |
| 64 | + :active => false, | |
| 65 | + :type => "AdminNotificationsPlugin::WarningNotification" | |
| 66 | + } | |
| 67 | + @notification = AdminNotificationsPlugin::Notification.last | |
| 68 | + assert_redirected_to :action => 'index' | |
| 69 | + assert_equal "Edited Message", @notification.message | |
| 70 | + assert !@notification.active | |
| 71 | + assert_equal "AdminNotificationsPlugin::WarningNotification", @notification.type | |
| 72 | + end | |
| 73 | + | |
| 74 | + should 'a regular user not be able to edit a notification' do | |
| 75 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 76 | + :target => @community, | |
| 77 | + :message => "Message", | |
| 78 | + :active => true, | |
| 79 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 80 | + ) | |
| 81 | + post :edit, :profile => @community.identifier, | |
| 82 | + :notifications => { | |
| 83 | + :message => "Edited Message", | |
| 84 | + :active => false, | |
| 85 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 86 | + } | |
| 87 | + @notification.reload | |
| 88 | + assert_redirected_to :root | |
| 89 | + assert_equal "Message", @notification.message | |
| 90 | + assert @notification.active | |
| 91 | + end | |
| 92 | + | |
| 93 | + should 'a profile admin be able to destroy a notification' do | |
| 94 | + @community.add_admin(@person) | |
| 95 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 96 | + :target => @community, | |
| 97 | + :message => "Message", | |
| 98 | + :active => true, | |
| 99 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 100 | + ) | |
| 101 | + delete :destroy, :profile => @community.identifier, :id => @notification.id | |
| 102 | + assert_nil AdminNotificationsPlugin::Notification.find_by_id(@notification.id) | |
| 103 | + end | |
| 104 | + | |
| 105 | + should 'a regular user not be able to destroy a notification' do | |
| 106 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 107 | + :target => @community, | |
| 108 | + :message => "Message", | |
| 109 | + :active => true, | |
| 110 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 111 | + ) | |
| 112 | + delete :destroy, :profile => @community.identifier, :id => @notification.id | |
| 113 | + | |
| 114 | + assert_redirected_to :root | |
| 115 | + assert_not_nil AdminNotificationsPlugin::Notification.find_by_id(@notification.id) | |
| 116 | + end | |
| 117 | + | |
| 118 | + should 'a profile admin be able to change Notification status' do | |
| 119 | + @community.add_admin(@person) | |
| 120 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 121 | + :target => @community, | |
| 122 | + :message => "Message", | |
| 123 | + :active => true, | |
| 124 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 125 | + ) | |
| 126 | + post :change_status, :profile => @community.identifier, :id => @notification.id | |
| 127 | + assert_redirected_to :action => 'index' | |
| 128 | + | |
| 129 | + @notification.reload | |
| 130 | + assert !@notification.active | |
| 131 | + end | |
| 132 | + | |
| 133 | + should 'a regular user not be able to change Notification status' do | |
| 134 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 135 | + :target => @community, | |
| 136 | + :message => "Message", | |
| 137 | + :active => true, | |
| 138 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 139 | + ) | |
| 140 | + post :change_status, :profile => @community.identifier, :id => @notification.id | |
| 141 | + assert_redirected_to :root | |
| 142 | + | |
| 143 | + @notification.reload | |
| 144 | + assert @notification.active | |
| 145 | + end | |
| 146 | + | |
| 147 | +end | ... | ... |
plugins/admin_notifications/test/functional/admin_notifications_plugin_public_controller_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,65 @@ |
| 1 | +require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' | |
| 2 | +require( | |
| 3 | + File.expand_path(File.dirname(__FILE__)) + | |
| 4 | + '/../../controllers/public/admin_notifications_plugin_public_controller' | |
| 5 | +) | |
| 6 | + | |
| 7 | +class AdminNotificationsPluginPublicControllerTest < ActionController::TestCase | |
| 8 | + def setup | |
| 9 | + @controller = AdminNotificationsPluginPublicController.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('AdminNotificationsPlugin') | |
| 16 | + @environment.save! | |
| 17 | + | |
| 18 | + login_as(@person.user.login) | |
| 19 | + end | |
| 20 | + | |
| 21 | + should 'a logged in user be able to permanently hide notifications' do | |
| 22 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 23 | + :target => @environment, | |
| 24 | + :message => "Message", | |
| 25 | + :active => true, | |
| 26 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 27 | + ) | |
| 28 | + post :close_notification, :notification_id => @notification.id | |
| 29 | + assert_equal "true", @response.body | |
| 30 | + assert @notification.users.include?(@person.user) | |
| 31 | + end | |
| 32 | + | |
| 33 | + should 'a logged in user be able to momentarily hide notifications' do | |
| 34 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 35 | + :target => @environment, | |
| 36 | + :message => "Message", | |
| 37 | + :active => true, | |
| 38 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 39 | + ) | |
| 40 | + | |
| 41 | + @another_notification = AdminNotificationsPlugin::Notification.create( | |
| 42 | + :target => @environment, | |
| 43 | + :message => "Another Message", | |
| 44 | + :active => true, | |
| 45 | + :type => "AdminNotificationsPlugin::WarningNotification" | |
| 46 | + ) | |
| 47 | + post :hide_notification, :notification_id => @notification.id | |
| 48 | + assert_equal "true", @response.body | |
| 49 | + assert @controller.hide_notifications.include?(@notification.id) | |
| 50 | + assert !@controller.hide_notifications.include?(@another_notification.id) | |
| 51 | + end | |
| 52 | + | |
| 53 | + should 'not momentarily hide any notification if its id is not found' do | |
| 54 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 55 | + :target => @environment, | |
| 56 | + :message => "Message", | |
| 57 | + :active => true, | |
| 58 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 59 | + ) | |
| 60 | + | |
| 61 | + post :hide_notification, :notification_id => nil | |
| 62 | + assert_equal "false", @response.body | |
| 63 | + assert !@controller.hide_notifications.include?(@notification.id) | |
| 64 | + end | |
| 65 | +end | ... | ... |
plugins/admin_notifications/test/functional/home_controller_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,120 @@ |
| 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('AdminNotificationsPlugin') | |
| 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 = AdminNotificationsPlugin::Notification.create( | |
| 24 | + :target => @environment, | |
| 25 | + :message => "Hello, this is a Notification Message", | |
| 26 | + :active => true, | |
| 27 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 28 | + ) | |
| 29 | + get :index | |
| 30 | + assert_match /Hello, this is a Notification Message/, @response.body | |
| 31 | + end | |
| 32 | + | |
| 33 | + | |
| 34 | + should 'an active notification not be displayed on home page for unlogged user' do | |
| 35 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 36 | + :target => @environment, | |
| 37 | + :message => "Hello, this is a Notification Message", | |
| 38 | + :active => true, | |
| 39 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 40 | + ) | |
| 41 | + get :index | |
| 42 | + assert_no_match /Hello, this is a Notification Message/, @response.body | |
| 43 | + end | |
| 44 | + | |
| 45 | + should 'an active notification be displayed on home page for unlogged user' do | |
| 46 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 47 | + :target => @environment, | |
| 48 | + :message => "Hello, this is a Notification Message", | |
| 49 | + :display_to_all_users => true, | |
| 50 | + :active => true, | |
| 51 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 52 | + ) | |
| 53 | + get :index | |
| 54 | + assert_match /Hello, this is a Notification Message/, @response.body | |
| 55 | + end | |
| 56 | + | |
| 57 | + should 'only display the notification with display_to_all_users option for unlogged user ' do | |
| 58 | + @notification1 = AdminNotificationsPlugin::Notification.create( | |
| 59 | + :target => @environment, | |
| 60 | + :message => "Hello, this is an old Notification Message", | |
| 61 | + :active => true, | |
| 62 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 63 | + ) | |
| 64 | + | |
| 65 | + @notification2 = AdminNotificationsPlugin::Notification.create( | |
| 66 | + :target => @environment, | |
| 67 | + :message => "Hello, this is a new Notification Message", | |
| 68 | + :display_to_all_users => true, | |
| 69 | + :active => true, | |
| 70 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 71 | + ) | |
| 72 | + | |
| 73 | + | |
| 74 | + get :index | |
| 75 | + assert_no_match /Hello, this is a Notification Message/, @response.body | |
| 76 | + assert_match /Hello, this is a new Notification Message/, @response.body | |
| 77 | + end | |
| 78 | + | |
| 79 | + should 'an inactive notification not be displayed on home page' do | |
| 80 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 81 | + :target => @environment, | |
| 82 | + :message => "Hello, this is a Notification Message", | |
| 83 | + :active => false, | |
| 84 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 85 | + ) | |
| 86 | + get :index | |
| 87 | + assert_no_match /Hello, this is a Notification Message/, @response.body | |
| 88 | + end | |
| 89 | + | |
| 90 | + | |
| 91 | + should 'an active notification not be displayed to a logged in user after been closed by him' do | |
| 92 | + login_as(@person.user.login) | |
| 93 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 94 | + :target => @environment, | |
| 95 | + :message => "Hello, this is a Notification Message", | |
| 96 | + :active => true, | |
| 97 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 98 | + ) | |
| 99 | + @notification.users << @person.user | |
| 100 | + @notification.save! | |
| 101 | + assert_equal true, @notification.users.include?(@person.user) | |
| 102 | + get :index | |
| 103 | + assert_no_match /Hello, this is a Notification Message/, @response.body | |
| 104 | + end | |
| 105 | + | |
| 106 | + should 'a notification be displayed with a Popup' do | |
| 107 | + login_as(@person.user.login) | |
| 108 | + @notification = AdminNotificationsPlugin::Notification.create( | |
| 109 | + :target => @environment, | |
| 110 | + :message => "Message", | |
| 111 | + :display_popup => true, | |
| 112 | + :active => true, | |
| 113 | + :type => "AdminNotificationsPlugin::DangerNotification" | |
| 114 | + ) | |
| 115 | + assert_equal true, @notification.display_popup? | |
| 116 | + | |
| 117 | + get :index | |
| 118 | + assert_no_match /div id="cboxWrapper"/, @response.body | |
| 119 | + end | |
| 120 | +end | ... | ... |
plugins/admin_notifications/test/helpers/notification_test_helper.rb
0 → 100644
| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | +module NotificationTestHelper | |
| 2 | + def create_notification target, display_only_in_homepage=false, message="any_message", active=true | |
| 3 | + AdminNotificationsPlugin::WarningNotification.create!( | |
| 4 | + :target => target, | |
| 5 | + :message => message, | |
| 6 | + :active => active, | |
| 7 | + :display_only_in_homepage => display_only_in_homepage | |
| 8 | + ) | |
| 9 | + end | |
| 10 | +end | ... | ... |
plugins/admin_notifications/test/unit/notification_helper_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | +require 'test_helper' | |
| 2 | + | |
| 3 | +class NotificationHelperTest < ActiveSupport::TestCase | |
| 4 | + def setup | |
| 5 | + @env = Environment.default | |
| 6 | + @env.enable_plugin('AdminNotificationsPlugin') | |
| 7 | + | |
| 8 | + @user = User.create!(:environment_id => @env.id, :email => "user@domain.com", :login => "new_user", :password => "test", :password_confirmation => "test", :name => "UserName") | |
| 9 | + end | |
| 10 | + | |
| 11 | + should 'substitute all email variables to the current user email' do | |
| 12 | + message = "Hello user with email %{email}! please, update your current email (%{email})." | |
| 13 | + | |
| 14 | + new_message = AdminNotificationsPlugin::NotificationHelper.substitute_variables(message, @user) | |
| 15 | + | |
| 16 | + assert message != new_message | |
| 17 | + assert_equal new_message, "Hello user with email user@domain.com! please, update your current email (user@domain.com)." | |
| 18 | + end | |
| 19 | + | |
| 20 | + should 'not substitute emails variables if there is no current user' do | |
| 21 | + message = "Hello user with email %{email}! please, update your current email (%{email})." | |
| 22 | + | |
| 23 | + new_message = AdminNotificationsPlugin::NotificationHelper.substitute_variables(message, nil) | |
| 24 | + | |
| 25 | + assert_equal message, new_message | |
| 26 | + assert_not_includes new_message, "user@domain.com" | |
| 27 | + end | |
| 28 | + | |
| 29 | + should 'substitute all name variables to the current user name' do | |
| 30 | + message = "Hello %{name}! is %{name} your real name?." | |
| 31 | + | |
| 32 | + new_message = AdminNotificationsPlugin::NotificationHelper.substitute_variables(message, @user) | |
| 33 | + | |
| 34 | + assert message != new_message | |
| 35 | + assert_equal new_message, "Hello UserName! is UserName your real name?." | |
| 36 | + end | |
| 37 | + | |
| 38 | + should 'not substitute name variables if there is no current user' do | |
| 39 | + message = "Hello %{name}! is %{name} your real name?." | |
| 40 | + | |
| 41 | + new_message = AdminNotificationsPlugin::NotificationHelper.substitute_variables(message, nil) | |
| 42 | + | |
| 43 | + assert_equal message, new_message | |
| 44 | + assert_not_includes new_message, "UserName" | |
| 45 | + end | |
| 46 | +end | ... | ... |
plugins/admin_notifications/test/unit/notification_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,193 @@ |
| 1 | +require_relative '../../../../test/test_helper' | |
| 2 | +require_relative '../helpers/notification_test_helper' | |
| 3 | + | |
| 4 | +class NotificationTest < ActiveSupport::TestCase | |
| 5 | + | |
| 6 | + include NotificationTestHelper | |
| 7 | + | |
| 8 | + def setup | |
| 9 | + @env = Environment.default | |
| 10 | + @env.enable_plugin('AdminNotificationsPlugin') | |
| 11 | + | |
| 12 | + @user = User.create!(:environment_id => @env.id, :email => "user@domain.com", :login => "new_user", :password => "test", :password_confirmation => "test") | |
| 13 | + @danger_notification = AdminNotificationsPlugin::DangerNotification.create!( | |
| 14 | + :target => @env, | |
| 15 | + :message => "Danger Message", | |
| 16 | + :active => true, | |
| 17 | + ) | |
| 18 | + | |
| 19 | + @warning_notification = AdminNotificationsPlugin::WarningNotification.create!( | |
| 20 | + :target => @env, | |
| 21 | + :message => "Warning Message", | |
| 22 | + :active => true, | |
| 23 | + ) | |
| 24 | + | |
| 25 | + @information_notification = AdminNotificationsPlugin::InformationNotification.create!( | |
| 26 | + :target => @env, | |
| 27 | + :message => "Information Message", | |
| 28 | + :active => true, | |
| 29 | + ) | |
| 30 | + end | |
| 31 | + | |
| 32 | + should 'get all notifications that a user did not close' do | |
| 33 | + @information_notification.users << @user | |
| 34 | + | |
| 35 | + notifications = AdminNotificationsPlugin::Notification.visibles(@env, @user, nil) | |
| 36 | + | |
| 37 | + assert notifications.include?(@danger_notification) | |
| 38 | + assert notifications.include?(@warning_notification) | |
| 39 | + assert !notifications.include?(@information_notification) | |
| 40 | + end | |
| 41 | + | |
| 42 | + should 'get only notifications configured to be displayed to all users' do | |
| 43 | + @information_notification.display_to_all_users = true | |
| 44 | + @information_notification.save! | |
| 45 | + | |
| 46 | + notifications = AdminNotificationsPlugin::Notification.visibles(@env, nil, nil) | |
| 47 | + | |
| 48 | + assert !notifications.include?(@danger_notification) | |
| 49 | + assert !notifications.include?(@warning_notification) | |
| 50 | + assert notifications.include?(@information_notification) | |
| 51 | + end | |
| 52 | + | |
| 53 | + should 'get only notifications configured to be displayed to all users and in all pages' do | |
| 54 | + @information_notification.display_to_all_users = true | |
| 55 | + @information_notification.display_only_in_homepage = true | |
| 56 | + @information_notification.save! | |
| 57 | + | |
| 58 | + @danger_notification.display_to_all_users = true | |
| 59 | + @danger_notification.save! | |
| 60 | + | |
| 61 | + @warning_notification.display_only_in_homepage = true | |
| 62 | + @warning_notification.save! | |
| 63 | + | |
| 64 | + notifications = AdminNotificationsPlugin::Notification.visibles(@env, nil, 'not_home') | |
| 65 | + | |
| 66 | + assert notifications.include?(@danger_notification) | |
| 67 | + assert !notifications.include?(@warning_notification) | |
| 68 | + assert !notifications.include?(@information_notification) | |
| 69 | + end | |
| 70 | + | |
| 71 | + should 'get only notifications configured to be displayed in all pages' do | |
| 72 | + @danger_notification.display_to_all_users = true | |
| 73 | + @danger_notification.display_only_in_homepage = true | |
| 74 | + @danger_notification.save! | |
| 75 | + | |
| 76 | + notifications = AdminNotificationsPlugin::Notification.visibles(@env, @user, "not_home") | |
| 77 | + | |
| 78 | + assert !notifications.include?(@danger_notification) | |
| 79 | + assert notifications.include?(@warning_notification) | |
| 80 | + assert notifications.include?(@information_notification) | |
| 81 | + | |
| 82 | + notifications = AdminNotificationsPlugin::Notification.visibles(@env, nil, "home") | |
| 83 | + | |
| 84 | + assert notifications.include?(@danger_notification) | |
| 85 | + assert !notifications.include?(@warning_notification) | |
| 86 | + assert !notifications.include?(@information_notification) | |
| 87 | + end | |
| 88 | + | |
| 89 | + should 'get notifications configured to be displayed on profile' do | |
| 90 | + community = fast_create(Community) | |
| 91 | + | |
| 92 | + AdminNotificationsPlugin::Notification.destroy_all | |
| 93 | + env_home_notification = create_notification(@env, true) | |
| 94 | + env_not_home_notification = create_notification(@env, false) | |
| 95 | + profile_not_home_notification = create_notification(community, false) | |
| 96 | + profile_home_notification = create_notification(community, true) | |
| 97 | + | |
| 98 | + notifications = AdminNotificationsPlugin::Notification.visibles(community, @user, "profile") | |
| 99 | + assert_equivalent notifications.to_a, [env_not_home_notification, profile_not_home_notification, profile_home_notification] | |
| 100 | + | |
| 101 | + notifications = AdminNotificationsPlugin::Notification.visibles(community, @user, "profile_but_bot_homepage") | |
| 102 | + assert_equivalent notifications.to_a, [env_not_home_notification, profile_not_home_notification] | |
| 103 | + end | |
| 104 | + | |
| 105 | + should 'get notifications configured to be displayed on environment' do | |
| 106 | + community = fast_create(Community) | |
| 107 | + | |
| 108 | + AdminNotificationsPlugin::Notification.destroy_all | |
| 109 | + env_home_notification = create_notification(@env, true) | |
| 110 | + env_not_home_notification = create_notification(@env, false) | |
| 111 | + profile_not_home_notification = create_notification(community, false) | |
| 112 | + profile_home_notification = create_notification(community, true) | |
| 113 | + | |
| 114 | + notifications = AdminNotificationsPlugin::Notification.visibles(@env, @user, "home") | |
| 115 | + assert_equivalent notifications.to_a, [env_home_notification, env_not_home_notification] | |
| 116 | + | |
| 117 | + notifications = AdminNotificationsPlugin::Notification.visibles(@env, @user, "not_home_not_profile") | |
| 118 | + assert_equivalent notifications.to_a, [env_not_home_notification] | |
| 119 | + end | |
| 120 | + | |
| 121 | + should 'get only notifications configured to be displayed to all users and in all pages and not closed by an user' do | |
| 122 | + @information_notification.display_to_all_users = true | |
| 123 | + @information_notification.save! | |
| 124 | + | |
| 125 | + @danger_notification.display_to_all_users = true | |
| 126 | + @danger_notification.display_only_in_homepage = true | |
| 127 | + @danger_notification.save! | |
| 128 | + | |
| 129 | + @warning_notification.display_to_all_users = true | |
| 130 | + @warning_notification.save! | |
| 131 | + | |
| 132 | + @warning_notification.users << @user | |
| 133 | + | |
| 134 | + notifications = AdminNotificationsPlugin::Notification.visibles(@env, @user, 'not_home') | |
| 135 | + | |
| 136 | + assert !notifications.include?(@danger_notification) | |
| 137 | + assert !notifications.include?(@warning_notification) | |
| 138 | + assert notifications.include?(@information_notification) | |
| 139 | + end | |
| 140 | + | |
| 141 | + should 'get only active notifications' do | |
| 142 | + @information_notification.active = false | |
| 143 | + @information_notification.save! | |
| 144 | + | |
| 145 | + notifications = AdminNotificationsPlugin::Notification.visibles(@env, @user, 'home') | |
| 146 | + | |
| 147 | + assert notifications.include?(@danger_notification) | |
| 148 | + assert notifications.include?(@warning_notification) | |
| 149 | + assert !notifications.include?(@information_notification) | |
| 150 | + end | |
| 151 | + | |
| 152 | + should 'get only notifications with popup' do | |
| 153 | + @information_notification.display_popup = true | |
| 154 | + @information_notification.display_to_all_users = true | |
| 155 | + @information_notification.save! | |
| 156 | + | |
| 157 | + notifications = AdminNotificationsPlugin::Notification.with_popup(@env, @user, 'home') | |
| 158 | + | |
| 159 | + assert !notifications.include?(@danger_notification) | |
| 160 | + assert !notifications.include?(@warning_notification) | |
| 161 | + assert notifications.include?(@information_notification) | |
| 162 | + | |
| 163 | + notifications = AdminNotificationsPlugin::Notification.with_popup(@env, nil, nil) | |
| 164 | + | |
| 165 | + assert !notifications.include?(@danger_notification) | |
| 166 | + assert !notifications.include?(@warning_notification) | |
| 167 | + assert notifications.include?(@information_notification) | |
| 168 | + end | |
| 169 | + | |
| 170 | + should 'get only notifications with popup not closed by an user' do | |
| 171 | + @information_notification.display_popup = true | |
| 172 | + @information_notification.display_to_all_users = true | |
| 173 | + @information_notification.save! | |
| 174 | + | |
| 175 | + @danger_notification.display_popup = true | |
| 176 | + @danger_notification.display_to_all_users = true | |
| 177 | + @danger_notification.save! | |
| 178 | + | |
| 179 | + @danger_notification.users << @user | |
| 180 | + | |
| 181 | + notifications = AdminNotificationsPlugin::Notification.with_popup(@env, @user, 'home') | |
| 182 | + | |
| 183 | + assert !notifications.include?(@danger_notification) | |
| 184 | + assert !notifications.include?(@warning_notification) | |
| 185 | + assert notifications.include?(@information_notification) | |
| 186 | + | |
| 187 | + notifications = AdminNotificationsPlugin::Notification.with_popup(@env, nil, nil) | |
| 188 | + | |
| 189 | + assert notifications.include?(@danger_notification) | |
| 190 | + assert !notifications.include?(@warning_notification) | |
| 191 | + assert notifications.include?(@information_notification) | |
| 192 | + end | |
| 193 | +end | ... | ... |
plugins/admin_notifications/views/admin_notifications_plugin_admin/edit.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<%= render :partial => "shared/form" %> | ... | ... |
plugins/admin_notifications/views/admin_notifications_plugin_admin/index.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<%= render :partial => "shared/notifications_list" %> | ... | ... |
plugins/admin_notifications/views/admin_notifications_plugin_admin/new.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<%= render :partial => "shared/form" %> | ... | ... |
plugins/admin_notifications/views/admin_notifications_plugin_myprofile/edit.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<%= render :partial => "shared/form" %> | ... | ... |
plugins/admin_notifications/views/admin_notifications_plugin_myprofile/index.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<%= render :partial => "shared/notifications_list" %> | ... | ... |
plugins/admin_notifications/views/admin_notifications_plugin_myprofile/new.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<%= render :partial => "shared/form" %> | ... | ... |
plugins/admin_notifications/views/admin_notifications_plugin_public/notifications_with_popup.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | +<% @notifications = AdminNotificationsPlugin::Notification.with_popup(environment, current_user, @previous_path).where("id NOT IN (?)", @hide_notifications) %> | |
| 2 | + | |
| 3 | +<div class="notification-plugin-notification-modal"> | |
| 4 | + <% @notifications.each do |notification| %> | |
| 5 | + <% if !notification.title.blank? %> | |
| 6 | + <div class="<%= notification.type.gsub("AdminNotificationsPlugin::", "").downcase %> notification notification-with-title" data-notification="<%=notification.id%>"> | |
| 7 | + <div class="notification-title"> | |
| 8 | + <%= notification.title %> | |
| 9 | + </div> | |
| 10 | + </div> | |
| 11 | + <div class="notification-message notification-with-title-message"> | |
| 12 | + <%= AdminNotificationsPlugin::NotificationHelper.substitute_variables(notification.message, current_user) %> | |
| 13 | + </div> | |
| 14 | + <% else %> | |
| 15 | + <div class="<%= notification.type.gsub("AdminNotificationsPlugin::", "").downcase %> notification notification-without-title" data-notification="<%=notification.id%>"> | |
| 16 | + <div class="notification-message"> | |
| 17 | + <%= AdminNotificationsPlugin::NotificationHelper.substitute_variables(notification.message, current_user) %> | |
| 18 | + </div> | |
| 19 | + </div> | |
| 20 | + <% end %> | |
| 21 | + <% end %> | |
| 22 | +</div> | ... | ... |
| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | +<div class="notification-plugin-form"> | |
| 2 | + | |
| 3 | + <% abstract_options = {:value => @notification.message, :style => 'width: 100%; height: 200px;', :class => 'mceEditor'} %> | |
| 4 | + | |
| 5 | + <%= button :back, _('Back'), :controller => 'admin_notifications_plugin_admin' %> | |
| 6 | + | |
| 7 | + <%= form_for :notifications do |f| %> | |
| 8 | + | |
| 9 | + <%= render :file => 'shared/tiny_mce', :locals => {:mode => 'restricted'} %> | |
| 10 | + | |
| 11 | + <%= labelled_form_field(_("Optional Title:"), f.text_field(:title, value: @notification.title)) %> | |
| 12 | + | |
| 13 | + <%= labelled_form_field(_("Enter your message here:"), f.text_area(:message, abstract_options)) %> | |
| 14 | + <small class="notification-variables-options"> | |
| 15 | + <%= _("Obs: You can use %{name} and %{email} variables to put the user's name and email in the message.") %> | |
| 16 | + </small> | |
| 17 | + | |
| 18 | + <%= labelled_form_field(_('Notifications Status'), select(:notifications, :active, options_for_select_with_title({_("Active") => true, _("Inactive") => false}, @notification.active))) %> | |
| 19 | + | |
| 20 | + <%= labelled_form_field(_('Notifications Color/Type'), select(:notifications, :type, options_for_select_with_title({_("Blue - Information") => "AdminNotificationsPlugin::InformationNotification", _("Yellow - Warning") => "AdminNotificationsPlugin::WarningNotification", _("Green - Success") => "AdminNotificationsPlugin::SuccessNotification", _("Red - Danger") => "AdminNotificationsPlugin::DangerNotification"}, @notification.type))) %> | |
| 21 | + | |
| 22 | + <div> | |
| 23 | + <%= labelled_check_box(_("Display only in the homepage"), 'notifications[display_only_in_homepage]', '1', @notification.display_only_in_homepage?) %> | |
| 24 | + </div> | |
| 25 | + | |
| 26 | + <div> | |
| 27 | + <%= labelled_check_box(_("Display to not logged users too"), 'notifications[display_to_all_users]', '1', @notification.display_to_all_users?) %> | |
| 28 | + </div> | |
| 29 | + | |
| 30 | + <div> | |
| 31 | + <%= labelled_check_box(_("Display popup until user close the notification"), 'notifications[display_popup]', '1', @notification.display_popup?) %> | |
| 32 | + </div> | |
| 33 | + | |
| 34 | + <% button_bar do %> | |
| 35 | + <%= submit_button 'save', _('Save'), :cancel => { :action => 'index' } %> | |
| 36 | + <% end %> | |
| 37 | + | |
| 38 | + <% end %> | |
| 39 | +</div> | ... | ... |
plugins/admin_notifications/views/shared/_notifications_list.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | +<div id="notification-plugin-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 | + | |
| 23 | + <% @notifications.each do |notification| %> | |
| 24 | + <div class="notification-line"> | |
| 25 | + <div class="notification-message"> | |
| 26 | + <%= truncate(notification.message, length: 50) %> | |
| 27 | + </div> | |
| 28 | + <div class="notification-action"> | |
| 29 | + <% if notification.active? %> | |
| 30 | + <%= button_without_text :deactivate, _('Deactivate'), {:action => :change_status, :id => notification}, :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 => notification}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %> | |
| 33 | + <% end %> | |
| 34 | + <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => notification.id} if !remove_content_button(:edit, notification) %> | |
| 35 | + <%= button_without_text :delete, _('Delete'), {:action => :destroy, :id => notification}, :method => :delete, :confirm => _("Do you want to delete this notification?") %> | |
| 36 | + </div> | |
| 37 | + </div> | |
| 38 | + <% end %> | |
| 39 | +</div> | ... | ... |
plugins/admin_notifications/views/shared/show_notification.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | +<% if current_user && current_user.person.is_admin? %> | |
| 2 | + <% active_notifications = AdminNotificationsPlugin::Notification.active(environment) %> | |
| 3 | + <% unless active_notifications.blank? %> | |
| 4 | + <div class="notification-plugin-notification-bar"> | |
| 5 | + <div class="adminnotification notification"> | |
| 6 | + <div class="notification-message"> | |
| 7 | + <p> | |
| 8 | + <%= _("There are active notifications in this environment!") %> | |
| 9 | + <%= link_to _("Manage all notifications here."), AdminNotificationsPlugin.admin_url %> | |
| 10 | + </p> | |
| 11 | + </div> | |
| 12 | + </div> | |
| 13 | + </div> | |
| 14 | + <% end %> | |
| 15 | +<% end %> | |
| 16 | + | |
| 17 | +<% target = profile.present? ? profile : environment %> | |
| 18 | + | |
| 19 | +<% @notifications = AdminNotificationsPlugin::Notification.visibles(target, current_user, controller_path).where("id NOT IN (?)", hide_notifications) %> | |
| 20 | + | |
| 21 | +<div class="notification-plugin-notification-bar"> | |
| 22 | + <% @notifications.each do |notification| %> | |
| 23 | + <div class="<%= notification.type.gsub("AdminNotificationsPlugin::", "").downcase %> notification" data-notification="<%=notification.id%>" notification-display-popup="<%=notification.display_popup?%>"> | |
| 24 | + <div class="notification-message"> | |
| 25 | + <%= AdminNotificationsPlugin::NotificationHelper.substitute_variables(notification.message, current_user) %> | |
| 26 | + </div> | |
| 27 | + <% if logged_in? %> | |
| 28 | + <div class="notification-close" title="<%= _('Do not show anymore') %>"></div> | |
| 29 | + <div class="notification-hide" title="<%= _('Hide for now') %>"></div> | |
| 30 | + <% end %> | |
| 31 | + </div> | |
| 32 | + <% end %> | |
| 33 | +</div> | ... | ... |
| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | +**This plugin is deprecated. Please use "admin_notifications" plugin instead.** | |
| 2 | + | |
| 3 | +If you already were using this plugin, migrating* it will switch automatically to the new plugin. | |
| 4 | +If you want to start using this plugin from scratch, activate and use the new one instead. | |
| 5 | + | |
| 6 | +*NOTE: running Noosfero in production mode already runs | |
| 7 | + the migrations and therefore switch plugins automatically. | ... | ... |
plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb
| ... | ... | @@ -1,103 +0,0 @@ |
| 1 | -class EnvironmentNotificationPluginAdminController < AdminController | |
| 2 | - | |
| 3 | - helper EnvironmentNotificationHelper | |
| 4 | - include EnvironmentNotificationHelper | |
| 5 | - | |
| 6 | - before_filter :admin_required, :except => [:close_notification, :hide_notification] | |
| 7 | - | |
| 8 | - def index | |
| 9 | - @notifications = environment.environment_notifications.order('updated_at DESC') | |
| 10 | - end | |
| 11 | - | |
| 12 | - def new | |
| 13 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.new | |
| 14 | - if request.post? | |
| 15 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.new(params[:notifications]) | |
| 16 | - @notification.message = @notification.message.html_safe | |
| 17 | - @notification.environment_id = environment.id | |
| 18 | - if @notification.save | |
| 19 | - session[:notice] = _("Notification successfully created") | |
| 20 | - redirect_to :action => :index | |
| 21 | - else | |
| 22 | - session[:notice] = _("Notification couldn't be created") | |
| 23 | - end | |
| 24 | - end | |
| 25 | - end | |
| 26 | - | |
| 27 | - def destroy | |
| 28 | - if request.delete? | |
| 29 | - notification = environment.environment_notifications.find_by id: params[:id] | |
| 30 | - if notification && notification.destroy | |
| 31 | - session[:notice] = _('The notification was deleted.') | |
| 32 | - else | |
| 33 | - session[:notice] = _('Could not remove the notification') | |
| 34 | - end | |
| 35 | - end | |
| 36 | - redirect_to :action => :index | |
| 37 | - end | |
| 38 | - | |
| 39 | - def edit | |
| 40 | - @notification = environment.environment_notifications.find_by id: params[:id] | |
| 41 | - if request.post? | |
| 42 | - if @notification.update_attributes(params[:notifications]) | |
| 43 | - session[:notice] = _('The notification was edited.') | |
| 44 | - else | |
| 45 | - session[:notice] = _('Could not edit the notification.') | |
| 46 | - end | |
| 47 | - redirect_to :action => :index | |
| 48 | - end | |
| 49 | - end | |
| 50 | - | |
| 51 | - def change_status | |
| 52 | - @notification = environment.environment_notifications.find_by id: params[:id] | |
| 53 | - | |
| 54 | - @notification.active = !@notification.active | |
| 55 | - | |
| 56 | - if @notification.save! | |
| 57 | - session[:notice] = _('The status of the notification was changed.') | |
| 58 | - else | |
| 59 | - session[:notice] = _('Could not change the status of the notification.') | |
| 60 | - end | |
| 61 | - | |
| 62 | - redirect_to :action => :index | |
| 63 | - end | |
| 64 | - | |
| 65 | - def close_notification | |
| 66 | - result = false | |
| 67 | - | |
| 68 | - if logged_in? | |
| 69 | - @notification = environment.environment_notifications.find_by id: params[:notification_id] | |
| 70 | - | |
| 71 | - if @notification | |
| 72 | - @notification.users << current_user | |
| 73 | - result = @notification.users.include?(current_user) | |
| 74 | - end | |
| 75 | - end | |
| 76 | - | |
| 77 | - render json: result | |
| 78 | - end | |
| 79 | - | |
| 80 | - def hide_notification | |
| 81 | - result = false | |
| 82 | - | |
| 83 | - if logged_in? | |
| 84 | - @notification = environment.environment_notifications.find_by id: params[:notification_id] | |
| 85 | - | |
| 86 | - if @notification | |
| 87 | - current_notificaions = [] | |
| 88 | - current_notificaions = JSON.parse(cookies[:hide_notifications]) unless cookies[:hide_notifications].blank? | |
| 89 | - current_notificaions << @notification.id unless current_notificaions.include? @notification.id | |
| 90 | - cookies[:hide_notifications] = JSON.generate(current_notificaions) | |
| 91 | - result = current_notificaions.include? @notification.id | |
| 92 | - end | |
| 93 | - end | |
| 94 | - | |
| 95 | - render json: result | |
| 96 | - end | |
| 97 | - | |
| 98 | - protected | |
| 99 | - def admin_required | |
| 100 | - redirect_to :root unless current_user.person.is_admin? | |
| 101 | - end | |
| 102 | - | |
| 103 | -end |
plugins/environment_notification/controllers/public/environment_notification_plugin_public_controller.rb
| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | -class EnvironmentNotificationPluginPublicController < PublicController | |
| 2 | - | |
| 3 | - helper EnvironmentNotificationHelper | |
| 4 | - include EnvironmentNotificationHelper | |
| 5 | - | |
| 6 | - def notifications_with_popup | |
| 7 | - @hide_notifications = hide_notifications | |
| 8 | - if params[:previous_path] | |
| 9 | - @previous_path = params[:previous_path] | |
| 10 | - else | |
| 11 | - @previous_path = nil | |
| 12 | - end | |
| 13 | - end | |
| 14 | - | |
| 15 | -end |
plugins/environment_notification/db/migrate/20150721132025_create_notification_table.rb
| ... | ... | @@ -1,28 +0,0 @@ |
| 1 | -class CreateNotificationTable < ActiveRecord::Migration | |
| 2 | - def up | |
| 3 | - create_table :environment_notifications do |t| | |
| 4 | - t.text :message | |
| 5 | - t.integer :environment_id | |
| 6 | - t.string :type | |
| 7 | - t.string :title | |
| 8 | - t.boolean :active | |
| 9 | - t.boolean :display_only_in_homepage, :default => false | |
| 10 | - t.boolean :display_to_all_users, :default => false | |
| 11 | - t.boolean :display_popup, :default => false | |
| 12 | - t.column :created_at, :datetime | |
| 13 | - t.column :updated_at, :datetime | |
| 14 | - end | |
| 15 | - | |
| 16 | - create_table :environment_notifications_users, id: false do |t| | |
| 17 | - t.belongs_to :environment_notification | |
| 18 | - t.belongs_to :user | |
| 19 | - end | |
| 20 | - add_index :environment_notifications_users, [:environment_notification_id], name: :index_Zaem6uuw | |
| 21 | - add_index :environment_notifications_users, [:user_id], name: :index_ap3nohR9 | |
| 22 | - end | |
| 23 | - | |
| 24 | - def down | |
| 25 | - drop_table :environment_notifications | |
| 26 | - drop_table :environment_notifications_users | |
| 27 | - end | |
| 28 | -end |
plugins/environment_notification/db/migrate/20160321190725_reactivate_plugin_after_rename.rb
0 → 100644
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +class ReactivatePluginAfterRename < ActiveRecord::Migration | |
| 2 | + def up | |
| 3 | + script_path = Rails.root.join('script').to_s | |
| 4 | + system(script_path + '/noosfero-plugins disable environment_notification') | |
| 5 | + system(script_path + '/noosfero-plugins enable admin_notifications') | |
| 6 | + | |
| 7 | + system("rake db:migrate") | |
| 8 | + end | |
| 9 | + | |
| 10 | + def down | |
| 11 | + raise ActiveRecord::IrreversibleMigration | |
| 12 | + end | |
| 13 | + | |
| 14 | +end | ... | ... |
plugins/environment_notification/features/message_edition.feature
| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | -Feature: Create envronment notification message | |
| 2 | - As an admin user | |
| 3 | - I want to create an environment notification | |
| 4 | - In order to notificate users | |
| 5 | - | |
| 6 | - @selenium | |
| 7 | - Scenario: mce restricted mode should show on message creation | |
| 8 | - Given I am logged in as admin | |
| 9 | - And I follow "Administration" | |
| 10 | - And I follow "Plugins" | |
| 11 | - And I follow "Configuration" | |
| 12 | - And I follow "New Notification" | |
| 13 | - Then The tinymce "toolbar1" should be "bold italic underline | link" | |
| 14 | - Then The tinymce "menubar" should be "false" |
plugins/environment_notification/lib/environment_notification_helper.rb
| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | -module EnvironmentNotificationHelper | |
| 2 | - | |
| 3 | - def hide_notifications | |
| 4 | - invalid_id = -1 | |
| 5 | - hide_notifications_ids = [invalid_id] | |
| 6 | - hide_notifications_ids = JSON.parse(cookies[:hide_notifications]) unless cookies[:hide_notifications].blank? | |
| 7 | - hide_notifications_ids | |
| 8 | - end | |
| 9 | - | |
| 10 | - def self.substitute_variables(message, user) | |
| 11 | - if user | |
| 12 | - message = message.gsub("%{email}", user.person.email).gsub("%{name}", user.person.name) | |
| 13 | - end | |
| 14 | - | |
| 15 | - message | |
| 16 | - end | |
| 17 | - | |
| 18 | -end |
plugins/environment_notification/lib/environment_notification_plugin.rb
| 1 | 1 | class EnvironmentNotificationPlugin < Noosfero::Plugin |
| 2 | - | |
| 3 | 2 | def self.plugin_name |
| 4 | - "Environment Notifications Plugin" | |
| 3 | + "Environment Notifications Plugin *DEPRECATED*" | |
| 5 | 4 | end |
| 6 | 5 | |
| 7 | 6 | 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/environment_notification_plugin.js | |
| 18 | - ) | |
| 19 | - end | |
| 20 | - | |
| 21 | - def body_beginning | |
| 22 | - lambda do | |
| 23 | - extend EnvironmentNotificationHelper | |
| 24 | - render template: 'environment_notification_plugin_admin/show_notification' | |
| 25 | - end | |
| 26 | - end | |
| 27 | - | |
| 28 | - def admin_panel_links | |
| 29 | - {:title => _('Notification Manager'), :url => {:controller => 'environment_notification_plugin_admin', :action => 'index'}} | |
| 30 | - end | |
| 31 | - | |
| 32 | - def account_controller_filters | |
| 33 | - block = proc do | |
| 34 | - if !logged_in? | |
| 35 | - cookies[:hide_notifications] = nil | |
| 36 | - end | |
| 37 | - end | |
| 38 | - | |
| 39 | - [{ | |
| 40 | - :type => "after_filter", | |
| 41 | - :method_name => "clean_hide_notifications_cookie", | |
| 42 | - :options => { }, | |
| 43 | - :block => block | |
| 44 | - }] | |
| 7 | + _("A plugin for environment notifications. *DEPRECATED*") | |
| 45 | 8 | end |
| 46 | 9 | end | ... | ... |
plugins/environment_notification/lib/environment_notifications_user.rb
| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | -class EnvironmentNotificationsUser < ApplicationRecord | |
| 2 | - self.table_name = "environment_notifications_users" | |
| 3 | - | |
| 4 | - belongs_to :user | |
| 5 | - belongs_to :environment_notification, class_name: 'EnvironmentNotificationPlugin::EnvironmentNotification' | |
| 6 | - | |
| 7 | - attr_accessible :user_id, :environment_notification_id | |
| 8 | - | |
| 9 | - validates_uniqueness_of :user_id, :scope => :environment_notification_id | |
| 10 | -end |
plugins/environment_notification/lib/ext/environment.rb
plugins/environment_notification/lib/ext/user.rb
plugins/environment_notification/models/environment_notification_plugin/danger_notification.rb
plugins/environment_notification/models/environment_notification_plugin/environment_notification.rb
| ... | ... | @@ -1,50 +0,0 @@ |
| 1 | -class EnvironmentNotificationPlugin::EnvironmentNotification < ApplicationRecord | |
| 2 | - | |
| 3 | - self.table_name = "environment_notifications" | |
| 4 | - | |
| 5 | - TYPE_LIST = [ | |
| 6 | - "EnvironmentNotificationPlugin::WarningNotification", | |
| 7 | - "EnvironmentNotificationPlugin::SuccessNotification", | |
| 8 | - "EnvironmentNotificationPlugin::InformationNotification", | |
| 9 | - "EnvironmentNotificationPlugin::DangerNotification" | |
| 10 | - ] | |
| 11 | - | |
| 12 | - attr_accessible :message, :environment_id, :active, :type, :display_only_in_homepage, :display_to_all_users, :display_popup, :title | |
| 13 | - | |
| 14 | - has_many :environment_notifications_users | |
| 15 | - has_many :users, :through => :environment_notifications_users | |
| 16 | - | |
| 17 | - validates_presence_of :message | |
| 18 | - validates_presence_of :environment_id | |
| 19 | - validate :notification_type_must_be_in_type_list | |
| 20 | - | |
| 21 | - def notification_type_must_be_in_type_list | |
| 22 | - unless TYPE_LIST.include?(type) | |
| 23 | - errors.add(:type, "invalid notification type") | |
| 24 | - end | |
| 25 | - end | |
| 26 | - | |
| 27 | - scope :active, -> environment { where environment_id: environment.id, active: true } | |
| 28 | - | |
| 29 | - def self.visibles(environment, user, controller_path) | |
| 30 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.active(environment).order('updated_at DESC') | |
| 31 | - | |
| 32 | - if user | |
| 33 | - active_notifications_ids = notifications.pluck(:id) - user.environment_notifications.pluck(:id) | |
| 34 | - | |
| 35 | - notifications = notifications.where(id: active_notifications_ids) | |
| 36 | - else | |
| 37 | - notifications = notifications.where(display_to_all_users: true) | |
| 38 | - end | |
| 39 | - | |
| 40 | - if controller_path != "home" | |
| 41 | - notifications = notifications.where(display_only_in_homepage: false) | |
| 42 | - end | |
| 43 | - | |
| 44 | - notifications | |
| 45 | - end | |
| 46 | - | |
| 47 | - def self.with_popup(environment, user, previous_path) | |
| 48 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(environment, user, previous_path).where(display_popup: true) | |
| 49 | - end | |
| 50 | -end |
plugins/environment_notification/models/environment_notification_plugin/information_notification.rb
plugins/environment_notification/models/environment_notification_plugin/success_notification.rb
plugins/environment_notification/models/environment_notification_plugin/warning_notification.rb
plugins/environment_notification/po/environment_notification.pot
| ... | ... | @@ -1,177 +0,0 @@ |
| 1 | -# SOME DESCRIPTIVE TITLE. | |
| 2 | -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | |
| 3 | -# This file is distributed under the same license as the PACKAGE package. | |
| 4 | -# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | |
| 5 | -# | |
| 6 | -#, fuzzy | |
| 7 | -msgid "" | |
| 8 | -msgstr "" | |
| 9 | -"Project-Id-Version: 1.3~rc2-1-ga15645d\n" | |
| 10 | -"POT-Creation-Date: 2015-10-30 16:35-0300\n" | |
| 11 | -"PO-Revision-Date: 2015-09-14 12:12-0000\n" | |
| 12 | -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
| 13 | -"Language-Team: LANGUAGE <LL@li.org>\n" | |
| 14 | -"Language: \n" | |
| 15 | -"MIME-Version: 1.0\n" | |
| 16 | -"Content-Type: text/plain; charset=UTF-8\n" | |
| 17 | -"Content-Transfer-Encoding: 8bit\n" | |
| 18 | -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" | |
| 19 | - | |
| 20 | -#: plugins/environment_notification/lib/environment_notification_plugin.rb:8 | |
| 21 | -msgid "A plugin for environment notifications." | |
| 22 | -msgstr "" | |
| 23 | - | |
| 24 | -#: plugins/environment_notification/lib/environment_notification_plugin.rb:29 | |
| 25 | -msgid "Notification Manager" | |
| 26 | -msgstr "" | |
| 27 | - | |
| 28 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:19 | |
| 29 | -msgid "Notification successfully created" | |
| 30 | -msgstr "" | |
| 31 | - | |
| 32 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:22 | |
| 33 | -msgid "Notification couldn't be created" | |
| 34 | -msgstr "" | |
| 35 | - | |
| 36 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:31 | |
| 37 | -msgid "The notification was deleted." | |
| 38 | -msgstr "" | |
| 39 | - | |
| 40 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:33 | |
| 41 | -msgid "Could not remove the notification" | |
| 42 | -msgstr "" | |
| 43 | - | |
| 44 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:43 | |
| 45 | -msgid "The notification was edited." | |
| 46 | -msgstr "" | |
| 47 | - | |
| 48 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:45 | |
| 49 | -msgid "Could not edit the notification." | |
| 50 | -msgstr "" | |
| 51 | - | |
| 52 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:57 | |
| 53 | -msgid "The status of the notification was changed." | |
| 54 | -msgstr "" | |
| 55 | - | |
| 56 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:59 | |
| 57 | -msgid "Could not change the status of the notification." | |
| 58 | -msgstr "" | |
| 59 | - | |
| 60 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb:8 | |
| 61 | -msgid "There are active notifications in this environment!" | |
| 62 | -msgstr "" | |
| 63 | - | |
| 64 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb:9 | |
| 65 | -msgid "Manage all notifications here." | |
| 66 | -msgstr "" | |
| 67 | - | |
| 68 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb:26 | |
| 69 | -msgid "Do not show anymore" | |
| 70 | -msgstr "" | |
| 71 | - | |
| 72 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb:27 | |
| 73 | -msgid "Hide for now" | |
| 74 | -msgstr "" | |
| 75 | - | |
| 76 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:4 | |
| 77 | -msgid "Back" | |
| 78 | -msgstr "" | |
| 79 | - | |
| 80 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:10 | |
| 81 | -msgid "Optional Title:" | |
| 82 | -msgstr "" | |
| 83 | - | |
| 84 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:12 | |
| 85 | -msgid "Enter your message here:" | |
| 86 | -msgstr "" | |
| 87 | - | |
| 88 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:14 | |
| 89 | -msgid "" | |
| 90 | -"Obs: You can use %{name} and %{email} variables to put the user's name and " | |
| 91 | -"email in the message." | |
| 92 | -msgstr "" | |
| 93 | - | |
| 94 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:17 | |
| 95 | -msgid "Notifications Status" | |
| 96 | -msgstr "" | |
| 97 | - | |
| 98 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:19 | |
| 99 | -msgid "Notifications Color/Type" | |
| 100 | -msgstr "" | |
| 101 | - | |
| 102 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:19 | |
| 103 | -msgid "Blue - Information" | |
| 104 | -msgstr "" | |
| 105 | - | |
| 106 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:19 | |
| 107 | -msgid "Yellow - Warning" | |
| 108 | -msgstr "" | |
| 109 | - | |
| 110 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:19 | |
| 111 | -msgid "Green - Success" | |
| 112 | -msgstr "" | |
| 113 | - | |
| 114 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:19 | |
| 115 | -msgid "Red - Danger" | |
| 116 | -msgstr "" | |
| 117 | - | |
| 118 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:22 | |
| 119 | -msgid "Display only in the homepage" | |
| 120 | -msgstr "" | |
| 121 | - | |
| 122 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:26 | |
| 123 | -msgid "Display to not logged users too" | |
| 124 | -msgstr "" | |
| 125 | - | |
| 126 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:30 | |
| 127 | -msgid "Display popup until user close the notification" | |
| 128 | -msgstr "" | |
| 129 | - | |
| 130 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:34 | |
| 131 | -msgid "Save" | |
| 132 | -msgstr "" | |
| 133 | - | |
| 134 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:3 | |
| 135 | -msgid "Environment Notifications" | |
| 136 | -msgstr "" | |
| 137 | - | |
| 138 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:7 | |
| 139 | -msgid "New Notification" | |
| 140 | -msgstr "" | |
| 141 | - | |
| 142 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:10 | |
| 143 | -msgid "Back to control panel" | |
| 144 | -msgstr "" | |
| 145 | - | |
| 146 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:16 | |
| 147 | -msgid "Notifications" | |
| 148 | -msgstr "" | |
| 149 | - | |
| 150 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:19 | |
| 151 | -msgid "Actions" | |
| 152 | -msgstr "" | |
| 153 | - | |
| 154 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:30 | |
| 155 | -msgid "Deactivate" | |
| 156 | -msgstr "" | |
| 157 | - | |
| 158 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:30 | |
| 159 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:32 | |
| 160 | -msgid "Do you want to change the status of this notification?" | |
| 161 | -msgstr "" | |
| 162 | - | |
| 163 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:32 | |
| 164 | -msgid "Activate" | |
| 165 | -msgstr "" | |
| 166 | - | |
| 167 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:34 | |
| 168 | -msgid "Edit" | |
| 169 | -msgstr "" | |
| 170 | - | |
| 171 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:35 | |
| 172 | -msgid "Delete" | |
| 173 | -msgstr "" | |
| 174 | - | |
| 175 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:35 | |
| 176 | -msgid "Do you want to delete this notification?" | |
| 177 | -msgstr "" |
plugins/environment_notification/po/pt/environment_notification.po
| ... | ... | @@ -1,178 +0,0 @@ |
| 1 | -# SOME DESCRIPTIVE TITLE. | |
| 2 | -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | |
| 3 | -# This file is distributed under the same license as the PACKAGE package. | |
| 4 | -# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | |
| 5 | -# | |
| 6 | -msgid "" | |
| 7 | -msgstr "" | |
| 8 | -"Project-Id-Version: 1.3~rc2-1-ga15645d\n" | |
| 9 | -"POT-Creation-Date: 2015-10-30 16:35-0300\n" | |
| 10 | -"PO-Revision-Date: 2015-09-14 12:12-0000\n" | |
| 11 | -"Last-Translator: FULL NAME <arthurmde@gmail.com>\n" | |
| 12 | -"Language-Team: Portuguese\n" | |
| 13 | -"Language: Portuguese\n" | |
| 14 | -"MIME-Version: 1.0\n" | |
| 15 | -"Content-Type: text/plain; charset=UTF-8\n" | |
| 16 | -"Content-Transfer-Encoding: 8bit\n" | |
| 17 | -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" | |
| 18 | - | |
| 19 | -#: plugins/environment_notification/lib/environment_notification_plugin.rb:8 | |
| 20 | -msgid "A plugin for environment notifications." | |
| 21 | -msgstr "Plugin para notificações do ambiente" | |
| 22 | - | |
| 23 | -#: plugins/environment_notification/lib/environment_notification_plugin.rb:29 | |
| 24 | -msgid "Notification Manager" | |
| 25 | -msgstr "Gerenciador de Notificações" | |
| 26 | - | |
| 27 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:19 | |
| 28 | -msgid "Notification successfully created" | |
| 29 | -msgstr "Notificação criada com sucesso" | |
| 30 | - | |
| 31 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:22 | |
| 32 | -msgid "Notification couldn't be created" | |
| 33 | -msgstr "Não foi possível criar notificação" | |
| 34 | - | |
| 35 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:31 | |
| 36 | -msgid "The notification was deleted." | |
| 37 | -msgstr "A notificação foi removida" | |
| 38 | - | |
| 39 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:33 | |
| 40 | -msgid "Could not remove the notification" | |
| 41 | -msgstr "Não foi possível remover a notificação" | |
| 42 | - | |
| 43 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:43 | |
| 44 | -msgid "The notification was edited." | |
| 45 | -msgstr "A notificação foi editada." | |
| 46 | - | |
| 47 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:45 | |
| 48 | -msgid "Could not edit the notification." | |
| 49 | -msgstr "Não foi possível editar a notificação." | |
| 50 | - | |
| 51 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:57 | |
| 52 | -msgid "The status of the notification was changed." | |
| 53 | -msgstr "O status da notificação foi modificado" | |
| 54 | - | |
| 55 | -#: plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb:59 | |
| 56 | -msgid "Could not change the status of the notification." | |
| 57 | -msgstr "Não foi possível alterar o status da notificação" | |
| 58 | - | |
| 59 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb:8 | |
| 60 | -msgid "There are active notifications in this environment!" | |
| 61 | -msgstr "Existem notificações ativas neste ambiente!" | |
| 62 | - | |
| 63 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb:9 | |
| 64 | -msgid "Manage all notifications here." | |
| 65 | -msgstr "Gerencie todas as notificações aqui." | |
| 66 | - | |
| 67 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb:26 | |
| 68 | -msgid "Do not show anymore" | |
| 69 | -msgstr "Não mostrar mais" | |
| 70 | - | |
| 71 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb:27 | |
| 72 | -msgid "Hide for now" | |
| 73 | -msgstr "Ocultar momentaneamente" | |
| 74 | - | |
| 75 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:4 | |
| 76 | -msgid "Back" | |
| 77 | -msgstr "Voltar" | |
| 78 | - | |
| 79 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:10 | |
| 80 | -msgid "Optional Title:" | |
| 81 | -msgstr "Título Opcional:" | |
| 82 | - | |
| 83 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:12 | |
| 84 | -msgid "Enter your message here:" | |
| 85 | -msgstr "Entre com a sua mensagem aqui:" | |
| 86 | - | |
| 87 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:14 | |
| 88 | -msgid "" | |
| 89 | -"Obs: You can use %{name} and %{email} variables to put the user's name and " | |
| 90 | -"email in the message." | |
| 91 | -msgstr "" | |
| 92 | -"Obs: Você pode usar as variáveis %{name} e %{email} para inserir o nome e " | |
| 93 | -"email do usuário logado na mensagem." | |
| 94 | - | |
| 95 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:17 | |
| 96 | -msgid "Notifications Status" | |
| 97 | -msgstr "Status da Notificação" | |
| 98 | - | |
| 99 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:19 | |
| 100 | -msgid "Notifications Color/Type" | |
| 101 | -msgstr "Cor/Tipo de Notificação" | |
| 102 | - | |
| 103 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:19 | |
| 104 | -msgid "Blue - Information" | |
| 105 | -msgstr "Azul - Informação" | |
| 106 | - | |
| 107 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:19 | |
| 108 | -msgid "Yellow - Warning" | |
| 109 | -msgstr "Amarelo - Atenção" | |
| 110 | - | |
| 111 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:19 | |
| 112 | -msgid "Green - Success" | |
| 113 | -msgstr "Verde - Sucesso" | |
| 114 | - | |
| 115 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:19 | |
| 116 | -msgid "Red - Danger" | |
| 117 | -msgstr "Vermelho - Perigo" | |
| 118 | - | |
| 119 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:22 | |
| 120 | -msgid "Display only in the homepage" | |
| 121 | -msgstr "Apresentar apenas na página inicial" | |
| 122 | - | |
| 123 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:26 | |
| 124 | -msgid "Display to not logged users too" | |
| 125 | -msgstr "Apresentar notificação para usuários não logados também" | |
| 126 | - | |
| 127 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:30 | |
| 128 | -msgid "Display popup until user close the notification" | |
| 129 | -msgstr "Apresentar Popup da notificação até que o usuário a feche" | |
| 130 | - | |
| 131 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb:34 | |
| 132 | -msgid "Save" | |
| 133 | -msgstr "Salvar" | |
| 134 | - | |
| 135 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:3 | |
| 136 | -msgid "Environment Notifications" | |
| 137 | -msgstr "Notificações do Ambiente" | |
| 138 | - | |
| 139 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:7 | |
| 140 | -msgid "New Notification" | |
| 141 | -msgstr "Nova Notificação" | |
| 142 | - | |
| 143 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:10 | |
| 144 | -msgid "Back to control panel" | |
| 145 | -msgstr "Voltar ao Painel de Controle" | |
| 146 | - | |
| 147 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:16 | |
| 148 | -msgid "Notifications" | |
| 149 | -msgstr "Notificações" | |
| 150 | - | |
| 151 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:19 | |
| 152 | -msgid "Actions" | |
| 153 | -msgstr "Ações" | |
| 154 | - | |
| 155 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:30 | |
| 156 | -msgid "Deactivate" | |
| 157 | -msgstr "Desativar" | |
| 158 | - | |
| 159 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:30 | |
| 160 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:32 | |
| 161 | -msgid "Do you want to change the status of this notification?" | |
| 162 | -msgstr "Você quer alterar o status dessa notificação?" | |
| 163 | - | |
| 164 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:32 | |
| 165 | -msgid "Activate" | |
| 166 | -msgstr "Ativar" | |
| 167 | - | |
| 168 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:34 | |
| 169 | -msgid "Edit" | |
| 170 | -msgstr "Editar" | |
| 171 | - | |
| 172 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:35 | |
| 173 | -msgid "Delete" | |
| 174 | -msgstr "Remover" | |
| 175 | - | |
| 176 | -#: plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb:35 | |
| 177 | -msgid "Do you want to delete this notification?" | |
| 178 | -msgstr "Você quer remover essa notificação?" |
plugins/environment_notification/public/environment_notification_plugin.js
| ... | ... | @@ -1,84 +0,0 @@ |
| 1 | -(function($) { | |
| 2 | - "use strict"; | |
| 3 | - | |
| 4 | - var environment_notification_plugin = { | |
| 5 | - | |
| 6 | - | |
| 7 | - notificationBar: function() { | |
| 8 | - var completeMessage = $(".environment-notification-plugin-notification-bar").remove(); | |
| 9 | - $("#content-inner").before(completeMessage); | |
| 10 | - }, | |
| 11 | - | |
| 12 | - closeNotification: function(){ | |
| 13 | - var notification = $(this).parent(); | |
| 14 | - var id = notification.attr("data-notification"); | |
| 15 | - | |
| 16 | - $.ajax({ | |
| 17 | - url: noosfero_root()+"/admin/plugin/environment_notification/close_notification", | |
| 18 | - type: "POST", | |
| 19 | - data: {notification_id: id}, | |
| 20 | - success: function(response) { | |
| 21 | - notification.fadeOut(); | |
| 22 | - } | |
| 23 | - }); | |
| 24 | - }, | |
| 25 | - | |
| 26 | - hideNotification: function(){ | |
| 27 | - var notification = $(this).parent(); | |
| 28 | - var id = notification.attr("data-notification"); | |
| 29 | - | |
| 30 | - $.ajax({ | |
| 31 | - url: noosfero_root()+"/admin/plugin/environment_notification/hide_notification", | |
| 32 | - type: "POST", | |
| 33 | - data: {notification_id: id}, | |
| 34 | - success: function(response) { | |
| 35 | - notification.fadeOut(); | |
| 36 | - } | |
| 37 | - }); | |
| 38 | - }, | |
| 39 | - | |
| 40 | - hideUserNotification: function(){ | |
| 41 | - var ids = $.cookie('hide_notifications'); | |
| 42 | - if(ids === null) { | |
| 43 | - return null; | |
| 44 | - } | |
| 45 | - | |
| 46 | - if(ids.startsWith('[') && ids.endsWith(']')){ | |
| 47 | - ids = ids.substring(1, ids.length - 1); | |
| 48 | - ids = ids.split(","); | |
| 49 | - | |
| 50 | - for(var i = 0; i < ids.length; i++) { | |
| 51 | - $('[data-notification="' + ids[i] + '"]').fadeOut(); | |
| 52 | - } | |
| 53 | - } | |
| 54 | - }, | |
| 55 | - | |
| 56 | - showPopup: function() { | |
| 57 | - if($('.action-home-index').length > 0) { | |
| 58 | - jQuery(function($){ | |
| 59 | - $.colorbox({href: noosfero_root()+'/plugin/environment_notification/public/notifications_with_popup?previous_path=home'}); | |
| 60 | - }); | |
| 61 | - } | |
| 62 | - else { | |
| 63 | - jQuery(function($){ | |
| 64 | - $.colorbox({href: noosfero_root()+'/plugin/environment_notification/public/notifications_with_popup'}); | |
| 65 | - }); | |
| 66 | - } | |
| 67 | - }, | |
| 68 | - }; | |
| 69 | - | |
| 70 | - $(document).ready(function(){ | |
| 71 | - environment_notification_plugin.notificationBar(); | |
| 72 | - $(".environment-notification-plugin-notification-bar .notification-close").on("click", environment_notification_plugin.closeNotification); | |
| 73 | - $(".environment-notification-plugin-notification-bar .notification-hide").on("click", environment_notification_plugin.hideNotification); | |
| 74 | - | |
| 75 | - if($('.environment-notification-plugin-notification-bar').length > 0){ | |
| 76 | - environment_notification_plugin.hideUserNotification(); | |
| 77 | - } | |
| 78 | - | |
| 79 | - if($('.environment-notification-plugin-notification-bar [notification-display-popup="true"]').length > 0){ | |
| 80 | - environment_notification_plugin.showPopup(); | |
| 81 | - } | |
| 82 | - }); | |
| 83 | - | |
| 84 | -})($); |
plugins/environment_notification/public/images/close.png
240 Bytes
plugins/environment_notification/public/images/greenhide.png
794 Bytes
plugins/environment_notification/public/images/hide.png
389 Bytes
plugins/environment_notification/public/images/redclose.png
552 Bytes
plugins/environment_notification/public/images/show.png
364 Bytes
plugins/environment_notification/public/style.css
| ... | ... | @@ -1,250 +0,0 @@ |
| 1 | -.environment-notification-plugin-notification-bar{ | |
| 2 | - display: block; | |
| 3 | -} | |
| 4 | - | |
| 5 | -.environment-notification-plugin-notification-bar .notification:hover, | |
| 6 | -.environment-notification-plugin-notification-notification-modal .notification:hover{ | |
| 7 | - opacity: 0.8; | |
| 8 | -} | |
| 9 | - | |
| 10 | -#environment-notification-plugin-notification-manager{ | |
| 11 | - overflow: auto; | |
| 12 | -} | |
| 13 | - | |
| 14 | -.environment-notification-plugin-notification-bar .notification .notification-close, | |
| 15 | -.environment-notification-plugin-notification-notification-modal .notification .notification-close{ | |
| 16 | - background: url(images/close.png) no-repeat; | |
| 17 | - background-position: center; | |
| 18 | - width: 20px; | |
| 19 | - height: 20px; | |
| 20 | -} | |
| 21 | - | |
| 22 | -.environment-notification-plugin-notification-bar .warningnotification, | |
| 23 | -.environment-notification-plugin-notification-bar .informationnotification, | |
| 24 | -.environment-notification-plugin-notification-bar .successnotification, | |
| 25 | -.environment-notification-plugin-notification-bar .dangernotification, | |
| 26 | -.environment-notification-plugin-notification-bar .adminnotification, | |
| 27 | -.environment-notification-plugin-notification-notification-modal .warningnotification, | |
| 28 | -.environment-notification-plugin-notification-notification-modal .informationnotification, | |
| 29 | -.environment-notification-plugin-notification-notification-modal .successnotification, | |
| 30 | -.environment-notification-plugin-notification-notification-modal .dangernotification{ | |
| 31 | - margin-bottom: 10px; | |
| 32 | - padding: 7px 10px; | |
| 33 | - border-radius: 5px; | |
| 34 | - border: 1px solid blue; | |
| 35 | - font-size: 16px; | |
| 36 | - color: white; | |
| 37 | - overflow: auto; | |
| 38 | -} | |
| 39 | - | |
| 40 | -.environment-notification-plugin-notification-bar .warningnotification p, | |
| 41 | -.environment-notification-plugin-notification-bar .informationnotification p, | |
| 42 | -.environment-notification-plugin-notification-bar .successnotification p, | |
| 43 | -.environment-notification-plugin-notification-bar .dangernotification p, | |
| 44 | -.environment-notification-plugin-notification-bar .adminnotification p, | |
| 45 | -.environment-notification-plugin-notification-notification-modal .warningnotification p, | |
| 46 | -.environment-notification-plugin-notification-notification-modal .informationnotification p, | |
| 47 | -.environment-notification-plugin-notification-notification-modal .successnotification p, | |
| 48 | -.environment-notification-plugin-notification-notification-modal .dangernotification p{ | |
| 49 | - margin: 0px; | |
| 50 | -} | |
| 51 | - | |
| 52 | -.environment-notification-plugin-notification-bar .warningnotification, | |
| 53 | -.environment-notification-plugin-notification-notification-modal .warningnotification{ | |
| 54 | - background: #fcf8e3; | |
| 55 | - border: 1px solid #faebcc; | |
| 56 | - color: #8a6d3b; | |
| 57 | -} | |
| 58 | - | |
| 59 | -.environment-notification-plugin-notification-bar .warningnotification p a, | |
| 60 | -.environment-notification-plugin-notification-notification-modal .warningnotification p a{ | |
| 61 | - font-weight: bold; | |
| 62 | - color: #8a6d3b; | |
| 63 | -} | |
| 64 | - | |
| 65 | - | |
| 66 | -.environment-notification-plugin-notification-bar .informationnotification, | |
| 67 | -.environment-notification-plugin-notification-notification-modal .informationnotification{ | |
| 68 | - background: #d9edf7; | |
| 69 | - border: 1px solid #bce8f1; | |
| 70 | - color: #31708f; | |
| 71 | -} | |
| 72 | - | |
| 73 | -.environment-notification-plugin-notification-bar .informationnotification p a, | |
| 74 | -.environment-notification-plugin-notification-notification-modal .informationnotification p a{ | |
| 75 | - font-weight: bold; | |
| 76 | - color: #31708f; | |
| 77 | -} | |
| 78 | - | |
| 79 | -.environment-notification-plugin-notification-bar .successnotification, | |
| 80 | -.environment-notification-plugin-notification-notification-modal .successnotification{ | |
| 81 | - background: #dff0d8; | |
| 82 | - border: 1px solid #d6e9c6; | |
| 83 | - color: #3c763d; | |
| 84 | -} | |
| 85 | - | |
| 86 | -.environment-notification-plugin-notification-bar .successnotification p a | |
| 87 | -.environment-notification-plugin-notification-notification-modal .successnotification p a{ | |
| 88 | - font-weight: bold; | |
| 89 | - color: #3c763d; | |
| 90 | -} | |
| 91 | - | |
| 92 | -.environment-notification-plugin-notification-bar .dangernotification, | |
| 93 | -.environment-notification-plugin-notification-notification-modal .dangernotification{ | |
| 94 | - background: #f2dede; | |
| 95 | - border: 1px solid #ebccd1; | |
| 96 | - color: #a94442; | |
| 97 | -} | |
| 98 | - | |
| 99 | -.environment-notification-plugin-notification-bar .dangernotification p a, | |
| 100 | -.environment-notification-plugin-notification-notification-modal .dangernotification p a{ | |
| 101 | - font-weight: bold; | |
| 102 | - color: #a94442; | |
| 103 | -} | |
| 104 | - | |
| 105 | -.environment-notification-plugin-notification-bar .adminnotification, | |
| 106 | -.environment-notification-plugin-notification-notification-modal .adminnotification{ | |
| 107 | - background: #9a959a; | |
| 108 | - border: 1px solid #9a959a; | |
| 109 | -} | |
| 110 | - | |
| 111 | -.environment-notification-plugin-notification-bar .adminnotification p a, | |
| 112 | -.environment-notification-plugin-notification-notification-modal .adminnotification p a{ | |
| 113 | - font-weight: bold; | |
| 114 | - color: white; | |
| 115 | -} | |
| 116 | - | |
| 117 | -#environment-notification-plugin-notification-manager a.button.icon-deactivate{ | |
| 118 | - background: url(images/hide.png) no-repeat; | |
| 119 | - background-position: center; | |
| 120 | -} | |
| 121 | - | |
| 122 | -#environment-notification-plugin-notification-manager a.button.icon-activate{ | |
| 123 | - background: url(images/show.png) no-repeat; | |
| 124 | - background-position: center; | |
| 125 | -} | |
| 126 | - | |
| 127 | -#environment-notification-plugin-notification-manager .notification-line{ | |
| 128 | - display: inline; | |
| 129 | - padding-top: 10px; | |
| 130 | - vertical-align: middle; | |
| 131 | - border-bottom: 1px solid #ccc; | |
| 132 | -} | |
| 133 | - | |
| 134 | -#environment-notification-plugin-notification-manager .notification-title-bar{ | |
| 135 | - float: left; | |
| 136 | - width: 100%; | |
| 137 | - font-style: 14px; | |
| 138 | - font-weight: 700; | |
| 139 | - border-bottom: 2px solid black; | |
| 140 | - padding: 9px 0; | |
| 141 | -} | |
| 142 | - | |
| 143 | -#environment-notification-plugin-notification-manager .notification-title{ | |
| 144 | - width: 80%; | |
| 145 | - float: left; | |
| 146 | - text-align: center; | |
| 147 | -} | |
| 148 | - | |
| 149 | -.environment-notification-plugin-notification-notification-modal .notification-with-title{ | |
| 150 | - margin-bottom: 0px; | |
| 151 | -} | |
| 152 | - | |
| 153 | -.environment-notification-plugin-notification-notification-modal .notification .notification-title{ | |
| 154 | - width: 100%; | |
| 155 | - float: left; | |
| 156 | - font-weight: bold; | |
| 157 | - text-align: left; | |
| 158 | -} | |
| 159 | - | |
| 160 | -.environment-notification-plugin-notification-notification-modal .notification-with-title-message{ | |
| 161 | - width: 100%; | |
| 162 | - float: left; | |
| 163 | - border-radius: 3px; | |
| 164 | - margin-bottom: 10px; | |
| 165 | - background-color: #f5f5f5; | |
| 166 | - font-size: 14px; | |
| 167 | - overflow: auto; | |
| 168 | -} | |
| 169 | - | |
| 170 | -.environment-notification-plugin-notification-notification-modal .notification-with-title-message p{ | |
| 171 | - padding: 0px 7px; | |
| 172 | -} | |
| 173 | - | |
| 174 | -.environment-notification-plugin-notification-notification-modal .notification-with-title-message p a{ | |
| 175 | - color: black; | |
| 176 | - font-weight: bold; | |
| 177 | -} | |
| 178 | - | |
| 179 | - | |
| 180 | -#environment-notification-plugin-notification-manager .action-title{ | |
| 181 | - width: 20%; | |
| 182 | - float: left; | |
| 183 | - text-align: center; | |
| 184 | -} | |
| 185 | - | |
| 186 | -#environment-notification-plugin-notification-manager .notification-action{ | |
| 187 | - width: 18%; | |
| 188 | - float: left; | |
| 189 | - height: 30px; | |
| 190 | - padding-top: 9px; | |
| 191 | -} | |
| 192 | - | |
| 193 | -#environment-notification-plugin-notification-manager .main-bar .button, | |
| 194 | -#environment-notification-plugin-notification-manager .notification-action .button{ | |
| 195 | - border-radius: 3px; | |
| 196 | -} | |
| 197 | - | |
| 198 | -#environment-notification-plugin-notification-manager .notification-message{ | |
| 199 | - width: 82%; | |
| 200 | - float: left; | |
| 201 | -} | |
| 202 | - | |
| 203 | -#environment-notification-plugin-notification-manager .new-notification{ | |
| 204 | - float: right; | |
| 205 | - width: auto; | |
| 206 | -} | |
| 207 | - | |
| 208 | -#environment-notification-plugin-notification-manager .back-button{ | |
| 209 | - float: left; | |
| 210 | -} | |
| 211 | - | |
| 212 | -#environment-notification-plugin-notification-manager .main-bar{ | |
| 213 | - display: inline; | |
| 214 | - width: 100%; | |
| 215 | -} | |
| 216 | - | |
| 217 | -.environment-notification-plugin-notification-bar .notification .notification-message, | |
| 218 | -.environment-notification-plugin-notification-notification-modal .notification .notification-message{ | |
| 219 | - width: 90%; | |
| 220 | - float: left; | |
| 221 | -} | |
| 222 | - | |
| 223 | -.environment-notification-plugin-notification-bar .notification .notification-close{ | |
| 224 | - background: url(images/redclose.png) no-repeat; | |
| 225 | - background-position: center; | |
| 226 | - width: 20px; | |
| 227 | - height: 20px; | |
| 228 | - float: right; | |
| 229 | - cursor: pointer; | |
| 230 | -} | |
| 231 | - | |
| 232 | -.environment-notification-plugin-notification-bar .notification .notification-hide{ | |
| 233 | - background: url(images/greenhide.png) no-repeat; | |
| 234 | - background-position: center; | |
| 235 | - width: 20px; | |
| 236 | - height: 20px; | |
| 237 | - float: right; | |
| 238 | - cursor: pointer; | |
| 239 | -} | |
| 240 | - | |
| 241 | -.environment-notification-plugin-notification-notification-modal{ | |
| 242 | - display: block; | |
| 243 | - min-width: 400px; | |
| 244 | - max-width: 700px; | |
| 245 | -} | |
| 246 | - | |
| 247 | -.environment-notification-plugin-form .notification-variables-options{ | |
| 248 | - font-style: italic; | |
| 249 | - color: red; | |
| 250 | -} |
plugins/environment_notification/test/functional/account_controller_test.rb
| ... | ... | @@ -1,36 +0,0 @@ |
| 1 | -require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' | |
| 2 | -require 'account_controller' | |
| 3 | - | |
| 4 | -class AccountController | |
| 5 | - include EnvironmentNotificationHelper | |
| 6 | -end | |
| 7 | - | |
| 8 | -class AccountControllerTest < ActionController::TestCase | |
| 9 | - def setup | |
| 10 | - @controller = AccountController.new | |
| 11 | - @request = ActionController::TestRequest.new | |
| 12 | - @response = ActionController::TestResponse.new | |
| 13 | - @person = create_user('person').person | |
| 14 | - | |
| 15 | - @environment = Environment.default | |
| 16 | - @environment.enable_plugin('EnvironmentNotificationPlugin') | |
| 17 | - @environment.save! | |
| 18 | - | |
| 19 | - login_as(@person.user.login) | |
| 20 | - end | |
| 21 | - | |
| 22 | - attr_accessor :person | |
| 23 | - | |
| 24 | - should 'clean hide_notifications cookie after logout' do | |
| 25 | - @request.cookies[:hide_notifications] = JSON.generate([1,2]) | |
| 26 | - get :index | |
| 27 | - assert !@request.cookies[:hide_notifications].blank? | |
| 28 | - | |
| 29 | - @request.cookies[:hide_notifications] = nil | |
| 30 | - get :logout | |
| 31 | - assert_nil session[:user] | |
| 32 | - assert_response :redirect | |
| 33 | - assert_equal 1, @controller.hide_notifications.count | |
| 34 | - assert @controller.hide_notifications.include?(-1) | |
| 35 | - end | |
| 36 | -end |
plugins/environment_notification/test/functional/environment_notification_plugin_admin_controller_test.rb
| ... | ... | @@ -1,183 +0,0 @@ |
| 1 | -require 'test_helper' | |
| 2 | -require_relative '../../controllers/environment_notification_plugin_admin_controller' | |
| 3 | - | |
| 4 | -class EnvironmentNotificationPluginAdminController; def rescue_action(e) raise e end; | |
| 5 | -end | |
| 6 | - | |
| 7 | -class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestCase | |
| 8 | - def setup | |
| 9 | - @controller = EnvironmentNotificationPluginAdminController.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 | - | |
| 18 | - login_as(@person.user.login) | |
| 19 | - end | |
| 20 | - | |
| 21 | - attr_accessor :person | |
| 22 | - | |
| 23 | - should 'an admin be able to create a notification' do | |
| 24 | - @environment.add_admin(@person) | |
| 25 | - post :new, :notifications => { | |
| 26 | - :message => "Message", | |
| 27 | - :active => true, | |
| 28 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 29 | - } | |
| 30 | - assert_redirected_to :action => 'index' | |
| 31 | - notification = EnvironmentNotificationPlugin::EnvironmentNotification.last | |
| 32 | - assert_equal "Message", notification.message | |
| 33 | - assert notification.active | |
| 34 | - assert_equal "EnvironmentNotificationPlugin::DangerNotification", notification.type | |
| 35 | - end | |
| 36 | - | |
| 37 | - should 'an user not to be able to create a notification' do | |
| 38 | - post :new, :notifications => { | |
| 39 | - :message => "Message", | |
| 40 | - :active => true, | |
| 41 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 42 | - } | |
| 43 | - assert_redirected_to :root | |
| 44 | - assert_nil EnvironmentNotificationPlugin::EnvironmentNotification.last | |
| 45 | - end | |
| 46 | - | |
| 47 | - should 'an admin be able to edit a notification' do | |
| 48 | - @environment.add_admin(@person) | |
| 49 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 50 | - :environment_id => @environment.id, | |
| 51 | - :message => "Message", | |
| 52 | - :active => true, | |
| 53 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 54 | - ) | |
| 55 | - post :edit, :id => @notification.id, :notifications => { | |
| 56 | - :message => "Edited Message", | |
| 57 | - :active => false, | |
| 58 | - :type => "EnvironmentNotificationPlugin::WarningNotification" | |
| 59 | - } | |
| 60 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.last | |
| 61 | - assert_redirected_to :action => 'index' | |
| 62 | - assert_equal "Edited Message", @notification.message | |
| 63 | - assert !@notification.active | |
| 64 | - assert_equal "EnvironmentNotificationPlugin::WarningNotification", @notification.type | |
| 65 | - end | |
| 66 | - | |
| 67 | - should 'an user not to be able to edit a notification' do | |
| 68 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 69 | - :environment_id => @environment.id, | |
| 70 | - :message => "Message", | |
| 71 | - :active => true, | |
| 72 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 73 | - ) | |
| 74 | - post :edit, :notifications => { | |
| 75 | - :message => "Edited Message", | |
| 76 | - :active => false, | |
| 77 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 78 | - } | |
| 79 | - @notification.reload | |
| 80 | - assert_redirected_to :root | |
| 81 | - assert_equal "Message", @notification.message | |
| 82 | - assert @notification.active | |
| 83 | - end | |
| 84 | - | |
| 85 | - should 'an admin be able to destroy a notification' do | |
| 86 | - @environment.add_admin(@person) | |
| 87 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 88 | - :environment_id => @environment.id, | |
| 89 | - :message => "Message", | |
| 90 | - :active => true, | |
| 91 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 92 | - ) | |
| 93 | - delete :destroy, :id => @notification.id | |
| 94 | - assert_nil EnvironmentNotificationPlugin::EnvironmentNotification.find_by(id: @notification.id) | |
| 95 | - end | |
| 96 | - | |
| 97 | - should 'an user not to be able to destroy a notification' do | |
| 98 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 99 | - :environment_id => @environment.id, | |
| 100 | - :message => "Message", | |
| 101 | - :active => true, | |
| 102 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 103 | - ) | |
| 104 | - delete :destroy, :id => @notification.id | |
| 105 | - | |
| 106 | - assert_redirected_to :root | |
| 107 | - assert_not_nil EnvironmentNotificationPlugin::EnvironmentNotification.find_by(id: @notification.id) | |
| 108 | - end | |
| 109 | - | |
| 110 | - should 'an admin be able to change Notification status' do | |
| 111 | - @environment.add_admin(@person) | |
| 112 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 113 | - :environment_id => @environment.id, | |
| 114 | - :message => "Message", | |
| 115 | - :active => true, | |
| 116 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 117 | - ) | |
| 118 | - post :change_status, :id => @notification.id | |
| 119 | - assert_redirected_to :action => 'index' | |
| 120 | - | |
| 121 | - @notification.reload | |
| 122 | - assert !@notification.active | |
| 123 | - end | |
| 124 | - | |
| 125 | - should 'an user not be able to change Notification status' do | |
| 126 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 127 | - :environment_id => @environment.id, | |
| 128 | - :message => "Message", | |
| 129 | - :active => true, | |
| 130 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 131 | - ) | |
| 132 | - post :change_status, :id => @notification.id | |
| 133 | - assert_redirected_to :root | |
| 134 | - | |
| 135 | - @notification.reload | |
| 136 | - assert @notification.active | |
| 137 | - end | |
| 138 | - | |
| 139 | - should 'a logged in user be able to permanently hide notifications' do | |
| 140 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 141 | - :environment_id => @environment.id, | |
| 142 | - :message => "Message", | |
| 143 | - :active => true, | |
| 144 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 145 | - ) | |
| 146 | - post :close_notification, :notification_id => @notification.id | |
| 147 | - assert_equal "true", @response.body | |
| 148 | - assert @notification.users.include?(@person.user) | |
| 149 | - end | |
| 150 | - | |
| 151 | - should 'a logged in user be able to momentarily hide notifications' do | |
| 152 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 153 | - :environment_id => @environment.id, | |
| 154 | - :message => "Message", | |
| 155 | - :active => true, | |
| 156 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 157 | - ) | |
| 158 | - | |
| 159 | - @another_notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 160 | - :environment_id => @environment.id, | |
| 161 | - :message => "Another Message", | |
| 162 | - :active => true, | |
| 163 | - :type => "EnvironmentNotificationPlugin::WarningNotification" | |
| 164 | - ) | |
| 165 | - post :hide_notification, :notification_id => @notification.id | |
| 166 | - assert_equal "true", @response.body | |
| 167 | - assert @controller.hide_notifications.include?(@notification.id) | |
| 168 | - assert !@controller.hide_notifications.include?(@another_notification.id) | |
| 169 | - end | |
| 170 | - | |
| 171 | - should 'not momentarily hide any notification if its id is not found' do | |
| 172 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 173 | - :environment_id => @environment.id, | |
| 174 | - :message => "Message", | |
| 175 | - :active => true, | |
| 176 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 177 | - ) | |
| 178 | - | |
| 179 | - post :hide_notification, :notification_id => nil | |
| 180 | - assert_equal "false", @response.body | |
| 181 | - assert !@controller.hide_notifications.include?(@notification.id) | |
| 182 | - end | |
| 183 | -end |
plugins/environment_notification/test/functional/home_controller_test.rb
| ... | ... | @@ -1,120 +0,0 @@ |
| 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 = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 24 | - :environment_id => @environment.id, | |
| 25 | - :message => "Hello, this is a Notification Message", | |
| 26 | - :active => true, | |
| 27 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 28 | - ) | |
| 29 | - get :index | |
| 30 | - assert_match /Hello, this is a Notification Message/, @response.body | |
| 31 | - end | |
| 32 | - | |
| 33 | - | |
| 34 | - should 'an active notification not be displayed on home page for unlogged user' do | |
| 35 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 36 | - :environment_id => @environment.id, | |
| 37 | - :message => "Hello, this is a Notification Message", | |
| 38 | - :active => true, | |
| 39 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 40 | - ) | |
| 41 | - get :index | |
| 42 | - assert_no_match /Hello, this is a Notification Message/, @response.body | |
| 43 | - end | |
| 44 | - | |
| 45 | - should 'an active notification be displayed on home page for unlogged user' do | |
| 46 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 47 | - :environment_id => @environment.id, | |
| 48 | - :message => "Hello, this is a Notification Message", | |
| 49 | - :display_to_all_users => true, | |
| 50 | - :active => true, | |
| 51 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 52 | - ) | |
| 53 | - get :index | |
| 54 | - assert_match /Hello, this is a Notification Message/, @response.body | |
| 55 | - end | |
| 56 | - | |
| 57 | - should 'only display the notification with display_to_all_users option for unlogged user ' do | |
| 58 | - @notification1 = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 59 | - :environment_id => @environment.id, | |
| 60 | - :message => "Hello, this is an old Notification Message", | |
| 61 | - :active => true, | |
| 62 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 63 | - ) | |
| 64 | - | |
| 65 | - @notification2 = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 66 | - :environment_id => @environment.id, | |
| 67 | - :message => "Hello, this is a new Notification Message", | |
| 68 | - :display_to_all_users => true, | |
| 69 | - :active => true, | |
| 70 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 71 | - ) | |
| 72 | - | |
| 73 | - | |
| 74 | - get :index | |
| 75 | - assert_no_match /Hello, this is a Notification Message/, @response.body | |
| 76 | - assert_match /Hello, this is a new Notification Message/, @response.body | |
| 77 | - end | |
| 78 | - | |
| 79 | - should 'an inactive notification not be displayed on home page' do | |
| 80 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 81 | - :environment_id => @environment.id, | |
| 82 | - :message => "Hello, this is a Notification Message", | |
| 83 | - :active => false, | |
| 84 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 85 | - ) | |
| 86 | - get :index | |
| 87 | - assert_no_match /Hello, this is a Notification Message/, @response.body | |
| 88 | - end | |
| 89 | - | |
| 90 | - | |
| 91 | - should 'an active notification not be displayed to a logged in user after been closed by him' do | |
| 92 | - login_as(@person.user.login) | |
| 93 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 94 | - :environment_id => @environment.id, | |
| 95 | - :message => "Hello, this is a Notification Message", | |
| 96 | - :active => true, | |
| 97 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 98 | - ) | |
| 99 | - @notification.users << @person.user | |
| 100 | - @notification.save! | |
| 101 | - assert_equal true, @notification.users.include?(@person.user) | |
| 102 | - get :index | |
| 103 | - assert_no_match /Hello, this is a Notification Message/, @response.body | |
| 104 | - end | |
| 105 | - | |
| 106 | - should 'a notification be displayed with a Popup' do | |
| 107 | - login_as(@person.user.login) | |
| 108 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | |
| 109 | - :environment_id => @environment.id, | |
| 110 | - :message => "Message", | |
| 111 | - :display_popup => true, | |
| 112 | - :active => true, | |
| 113 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | |
| 114 | - ) | |
| 115 | - assert_equal true, @notification.display_popup? | |
| 116 | - | |
| 117 | - get :index | |
| 118 | - assert_no_match /div id="cboxWrapper"/, @response.body | |
| 119 | - end | |
| 120 | -end |
plugins/environment_notification/test/unit/environment_notification_helper_test.rb
| ... | ... | @@ -1,46 +0,0 @@ |
| 1 | -require 'test_helper' | |
| 2 | - | |
| 3 | -class EnvironmentNotificationHelperTest < ActiveSupport::TestCase | |
| 4 | - def setup | |
| 5 | - @env = Environment.default | |
| 6 | - @env.enable_plugin('EnvironmentNotificationPlugin') | |
| 7 | - | |
| 8 | - @user = User.create!(:environment_id => @env.id, :email => "user@domain.com", :login => "new_user", :password => "test", :password_confirmation => "test", :name => "UserName") | |
| 9 | - end | |
| 10 | - | |
| 11 | - should 'substitute all email variables to the current user email' do | |
| 12 | - message = "Hello user with email %{email}! please, update your current email (%{email})." | |
| 13 | - | |
| 14 | - new_message = EnvironmentNotificationHelper.substitute_variables(message, @user) | |
| 15 | - | |
| 16 | - assert message != new_message | |
| 17 | - assert_equal new_message, "Hello user with email user@domain.com! please, update your current email (user@domain.com)." | |
| 18 | - end | |
| 19 | - | |
| 20 | - should 'not substitute emails variables if there is no current user' do | |
| 21 | - message = "Hello user with email %{email}! please, update your current email (%{email})." | |
| 22 | - | |
| 23 | - new_message = EnvironmentNotificationHelper.substitute_variables(message, nil) | |
| 24 | - | |
| 25 | - assert_equal message, new_message | |
| 26 | - assert_not_includes new_message, "user@domain.com" | |
| 27 | - end | |
| 28 | - | |
| 29 | - should 'substitute all name variables to the current user name' do | |
| 30 | - message = "Hello %{name}! is %{name} your real name?." | |
| 31 | - | |
| 32 | - new_message = EnvironmentNotificationHelper.substitute_variables(message, @user) | |
| 33 | - | |
| 34 | - assert message != new_message | |
| 35 | - assert_equal new_message, "Hello UserName! is UserName your real name?." | |
| 36 | - end | |
| 37 | - | |
| 38 | - should 'not substitute name variables if there is no current user' do | |
| 39 | - message = "Hello %{name}! is %{name} your real name?." | |
| 40 | - | |
| 41 | - new_message = EnvironmentNotificationHelper.substitute_variables(message, nil) | |
| 42 | - | |
| 43 | - assert_equal message, new_message | |
| 44 | - assert_not_includes new_message, "UserName" | |
| 45 | - end | |
| 46 | -end |
plugins/environment_notification/test/unit/environment_notification_test.rb
| ... | ... | @@ -1,162 +0,0 @@ |
| 1 | -require_relative '../../../../test/test_helper' | |
| 2 | - | |
| 3 | -class EnvironmentNotificationTest < ActiveSupport::TestCase | |
| 4 | - | |
| 5 | - def setup | |
| 6 | - @env = Environment.default | |
| 7 | - @env.enable_plugin('EnvironmentNotificationPlugin') | |
| 8 | - | |
| 9 | - User.destroy_all | |
| 10 | - EnvironmentNotificationPlugin::EnvironmentNotification.destroy_all | |
| 11 | - EnvironmentNotificationsUser.destroy_all | |
| 12 | - | |
| 13 | - @user = User.create!(:environment_id => @env.id, :email => "user@domain.com", :login => "new_user", :password => "test", :password_confirmation => "test") | |
| 14 | - @danger_notification = EnvironmentNotificationPlugin::DangerNotification.create!( | |
| 15 | - :environment_id => @env.id, | |
| 16 | - :message => "Danger Message", | |
| 17 | - :active => true, | |
| 18 | - ) | |
| 19 | - | |
| 20 | - @warning_notification = EnvironmentNotificationPlugin::WarningNotification.create!( | |
| 21 | - :environment_id => @env.id, | |
| 22 | - :message => "Warning Message", | |
| 23 | - :active => true, | |
| 24 | - ) | |
| 25 | - | |
| 26 | - @information_notification = EnvironmentNotificationPlugin::InformationNotification.create!( | |
| 27 | - :environment_id => @env.id, | |
| 28 | - :message => "Information Message", | |
| 29 | - :active => true, | |
| 30 | - ) | |
| 31 | - end | |
| 32 | - | |
| 33 | - should 'get all notifications that a user did not closed' do | |
| 34 | - @information_notification.users << @user | |
| 35 | - | |
| 36 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(@env, @user, nil) | |
| 37 | - | |
| 38 | - assert notifications.include?(@danger_notification) | |
| 39 | - assert notifications.include?(@warning_notification) | |
| 40 | - assert !notifications.include?(@information_notification) | |
| 41 | - end | |
| 42 | - | |
| 43 | - should 'get only notifications configured to be displayed to all users' do | |
| 44 | - @information_notification.display_to_all_users = true | |
| 45 | - @information_notification.save! | |
| 46 | - | |
| 47 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(@env, nil, nil) | |
| 48 | - | |
| 49 | - assert !notifications.include?(@danger_notification) | |
| 50 | - assert !notifications.include?(@warning_notification) | |
| 51 | - assert notifications.include?(@information_notification) | |
| 52 | - end | |
| 53 | - | |
| 54 | - should 'get only notifications configured to be displayed to all users and in all pages' do | |
| 55 | - @information_notification.display_to_all_users = true | |
| 56 | - @information_notification.display_only_in_homepage = true | |
| 57 | - @information_notification.save! | |
| 58 | - | |
| 59 | - @danger_notification.display_to_all_users = true | |
| 60 | - @danger_notification.save! | |
| 61 | - | |
| 62 | - @warning_notification.display_only_in_homepage = true | |
| 63 | - @warning_notification.save! | |
| 64 | - | |
| 65 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(@env, nil, 'not_home') | |
| 66 | - | |
| 67 | - assert notifications.include?(@danger_notification) | |
| 68 | - assert !notifications.include?(@warning_notification) | |
| 69 | - assert !notifications.include?(@information_notification) | |
| 70 | - end | |
| 71 | - | |
| 72 | - should 'get only notifications configured to be displayed in all pages' do | |
| 73 | - @danger_notification.display_to_all_users = true | |
| 74 | - @danger_notification.display_only_in_homepage = true | |
| 75 | - @danger_notification.save! | |
| 76 | - | |
| 77 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(@env, @user, "not_home") | |
| 78 | - | |
| 79 | - assert !notifications.include?(@danger_notification) | |
| 80 | - assert notifications.include?(@warning_notification) | |
| 81 | - assert notifications.include?(@information_notification) | |
| 82 | - | |
| 83 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(@env, nil, "home") | |
| 84 | - | |
| 85 | - assert notifications.include?(@danger_notification) | |
| 86 | - assert !notifications.include?(@warning_notification) | |
| 87 | - assert !notifications.include?(@information_notification) | |
| 88 | - end | |
| 89 | - | |
| 90 | - should 'get only notifications configured to be displayed to all users and in all pages and not closed by an user' do | |
| 91 | - @information_notification.display_to_all_users = true | |
| 92 | - @information_notification.save! | |
| 93 | - | |
| 94 | - @danger_notification.display_to_all_users = true | |
| 95 | - @danger_notification.display_only_in_homepage = true | |
| 96 | - @danger_notification.save! | |
| 97 | - | |
| 98 | - @warning_notification.display_to_all_users = true | |
| 99 | - @warning_notification.save! | |
| 100 | - | |
| 101 | - @warning_notification.users << @user | |
| 102 | - | |
| 103 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(@env, @user, 'not_home') | |
| 104 | - | |
| 105 | - assert !notifications.include?(@danger_notification) | |
| 106 | - assert !notifications.include?(@warning_notification) | |
| 107 | - assert notifications.include?(@information_notification) | |
| 108 | - end | |
| 109 | - | |
| 110 | - should 'get only active notifications' do | |
| 111 | - @information_notification.active = false | |
| 112 | - @information_notification.save! | |
| 113 | - | |
| 114 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(@env, @user, 'home') | |
| 115 | - | |
| 116 | - assert notifications.include?(@danger_notification) | |
| 117 | - assert notifications.include?(@warning_notification) | |
| 118 | - assert !notifications.include?(@information_notification) | |
| 119 | - end | |
| 120 | - | |
| 121 | - should 'get only notifications with popup' do | |
| 122 | - @information_notification.display_popup = true | |
| 123 | - @information_notification.display_to_all_users = true | |
| 124 | - @information_notification.save! | |
| 125 | - | |
| 126 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.with_popup(@env, @user, 'home') | |
| 127 | - | |
| 128 | - assert !notifications.include?(@danger_notification) | |
| 129 | - assert !notifications.include?(@warning_notification) | |
| 130 | - assert notifications.include?(@information_notification) | |
| 131 | - | |
| 132 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.with_popup(@env, nil, nil) | |
| 133 | - | |
| 134 | - assert !notifications.include?(@danger_notification) | |
| 135 | - assert !notifications.include?(@warning_notification) | |
| 136 | - assert notifications.include?(@information_notification) | |
| 137 | - end | |
| 138 | - | |
| 139 | - should 'get only notifications with popup not closed by an user' do | |
| 140 | - @information_notification.display_popup = true | |
| 141 | - @information_notification.display_to_all_users = true | |
| 142 | - @information_notification.save! | |
| 143 | - | |
| 144 | - @danger_notification.display_popup = true | |
| 145 | - @danger_notification.display_to_all_users = true | |
| 146 | - @danger_notification.save! | |
| 147 | - | |
| 148 | - @danger_notification.users << @user | |
| 149 | - | |
| 150 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.with_popup(@env, @user, 'home') | |
| 151 | - | |
| 152 | - assert !notifications.include?(@danger_notification) | |
| 153 | - assert !notifications.include?(@warning_notification) | |
| 154 | - assert notifications.include?(@information_notification) | |
| 155 | - | |
| 156 | - notifications = EnvironmentNotificationPlugin::EnvironmentNotification.with_popup(@env, nil, nil) | |
| 157 | - | |
| 158 | - assert notifications.include?(@danger_notification) | |
| 159 | - assert !notifications.include?(@warning_notification) | |
| 160 | - assert notifications.include?(@information_notification) | |
| 161 | - end | |
| 162 | -end |
plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb
| ... | ... | @@ -1,39 +0,0 @@ |
| 1 | -<div class="environment-notification-plugin-form"> | |
| 2 | - | |
| 3 | - <% abstract_options = {:value => @notification.message, :style => 'width: 100%; height: 200px;', :class => 'mceEditor'} %> | |
| 4 | - | |
| 5 | - <%= button :back, _('Back'), :controller => 'environment_notification_plugin_admin' %> | |
| 6 | - | |
| 7 | - <%= form_for :notifications do |f| %> | |
| 8 | - | |
| 9 | - <%= render :file => 'shared/tiny_mce', :locals => {:mode => 'restricted'} %> | |
| 10 | - | |
| 11 | - <%= labelled_form_field(_("Optional Title:"), f.text_field(:title, value: @notification.title)) %> | |
| 12 | - | |
| 13 | - <%= labelled_form_field(_("Enter your message here:"), f.text_area(:message, abstract_options)) %> | |
| 14 | - <small class="notification-variables-options"> | |
| 15 | - <%= _("Obs: You can use %{name} and %{email} variables to put the user's name and email in the message.") %> | |
| 16 | - </small> | |
| 17 | - | |
| 18 | - <%= labelled_form_field(_('Notifications Status'), select(:notifications, :active, options_for_select_with_title({"Active" => true, "Inactive" => false}, @notification.active))) %> | |
| 19 | - | |
| 20 | - <%= 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))) %> | |
| 21 | - | |
| 22 | - <div> | |
| 23 | - <%= labelled_check_box(_("Display only in the homepage"), 'notifications[display_only_in_homepage]', '1', @notification.display_only_in_homepage?) %> | |
| 24 | - </div> | |
| 25 | - | |
| 26 | - <div> | |
| 27 | - <%= labelled_check_box(_("Display to not logged users too"), 'notifications[display_to_all_users]', '1', @notification.display_to_all_users?) %> | |
| 28 | - </div> | |
| 29 | - | |
| 30 | - <div> | |
| 31 | - <%= labelled_check_box(_("Display popup until user close the notification"), 'notifications[display_popup]', '1', @notification.display_popup?) %> | |
| 32 | - </div> | |
| 33 | - | |
| 34 | - <% button_bar do %> | |
| 35 | - <%= submit_button 'save', _('Save'), :cancel => { :action => 'index' } %> | |
| 36 | - <% end %> | |
| 37 | - | |
| 38 | - <% end %> | |
| 39 | -</div> |
plugins/environment_notification/views/environment_notification_plugin_admin/edit.html.erb
| ... | ... | @@ -1 +0,0 @@ |
| 1 | -<%= render :partial => "form" %> |
plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb
| ... | ... | @@ -1,40 +0,0 @@ |
| 1 | -<div id="environment-notification-plugin-notification-manager"> | |
| 2 | - <div class="notification-manager-title"> | |
| 3 | - <h1><%= _("Environment 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 | - | |
| 23 | - <% @notifications.each do |notification| %> | |
| 24 | - <div class="notification-line"> | |
| 25 | - <div class="notification-message"> | |
| 26 | - <%= truncate(notification.message, length: 50) %> | |
| 27 | - </div> | |
| 28 | - <div class="notification-action"> | |
| 29 | - <% if notification.active? %> | |
| 30 | - <%= button_without_text :deactivate, _('Deactivate'), {:action => :change_status, :id => notification}, :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 => notification}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %> | |
| 33 | - <% end %> | |
| 34 | - <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => notification.id} if !remove_content_button(:edit, notification) %> | |
| 35 | - <%= button_without_text :delete, _('Delete'), {:action => :destroy, :id => notification}, :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
| ... | ... | @@ -1 +0,0 @@ |
| 1 | -<%= render :partial => "form" %> |
plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb
| ... | ... | @@ -1,31 +0,0 @@ |
| 1 | -<% if current_user && current_user.person.is_admin? %> | |
| 2 | - <% active_notifications = EnvironmentNotificationPlugin::EnvironmentNotification.active(environment) %> | |
| 3 | - <% unless active_notifications.blank? %> | |
| 4 | - <div class="environment-notification-plugin-notification-bar"> | |
| 5 | - <div class="adminnotification notification"> | |
| 6 | - <div class="notification-message"> | |
| 7 | - <p> | |
| 8 | - <%= _("There are active notifications in this environment!") %> | |
| 9 | - <%= link_to _("Manage all notifications here."), EnvironmentNotificationPlugin.admin_url %> | |
| 10 | - </p> | |
| 11 | - </div> | |
| 12 | - </div> | |
| 13 | - </div> | |
| 14 | - <% end %> | |
| 15 | -<% end %> | |
| 16 | - | |
| 17 | -<% @notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(environment, current_user, controller_path).where("id NOT IN (?)", hide_notifications) %> | |
| 18 | - | |
| 19 | -<div class="environment-notification-plugin-notification-bar"> | |
| 20 | - <% @notifications.each do |notification| %> | |
| 21 | - <div class="<%= notification.type.gsub("EnvironmentNotificationPlugin::", "").downcase %> notification" data-notification="<%=notification.id%>" notification-display-popup="<%=notification.display_popup?%>"> | |
| 22 | - <div class="notification-message"> | |
| 23 | - <%= EnvironmentNotificationHelper.substitute_variables(notification.message, current_user) %> | |
| 24 | - </div> | |
| 25 | - <% if logged_in? %> | |
| 26 | - <div class="notification-close" title="<%= _('Do not show anymore') %>"></div> | |
| 27 | - <div class="notification-hide" title="<%= _('Hide for now') %>"></div> | |
| 28 | - <% end %> | |
| 29 | - </div> | |
| 30 | - <% end %> | |
| 31 | -</div> |
plugins/environment_notification/views/environment_notification_plugin_public/notifications_with_popup.html.erb
| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | -<% @notifications = EnvironmentNotificationPlugin::EnvironmentNotification.with_popup(environment, current_user, @previous_path).where("id NOT IN (?)", @hide_notifications) %> | |
| 2 | - | |
| 3 | -<div class="environment-notification-plugin-notification-notification-modal"> | |
| 4 | - <% @notifications.each do |notification| %> | |
| 5 | - <% if !notification.title.blank? %> | |
| 6 | - <div class="<%= notification.type.gsub("EnvironmentNotificationPlugin::", "").downcase %> notification notification-with-title" data-notification="<%=notification.id%>"> | |
| 7 | - <div class="notification-title"> | |
| 8 | - <%= notification.title %> | |
| 9 | - </div> | |
| 10 | - </div> | |
| 11 | - <div class="notification-message notification-with-title-message"> | |
| 12 | - <%= EnvironmentNotificationHelper.substitute_variables(notification.message, current_user) %> | |
| 13 | - </div> | |
| 14 | - <% else %> | |
| 15 | - <div class="<%= notification.type.gsub("EnvironmentNotificationPlugin::", "").downcase %> notification notification-without-title" data-notification="<%=notification.id%>"> | |
| 16 | - <div class="notification-message"> | |
| 17 | - <%= EnvironmentNotificationHelper.substitute_variables(notification.message, current_user) %> | |
| 18 | - </div> | |
| 19 | - </div> | |
| 20 | - <% end %> | |
| 21 | - <% end %> | |
| 22 | -</div> |
public/designs/themes/base/style.scss
| ... | ... | @@ -1555,3 +1555,21 @@ table#recaptcha_table tr:hover td { |
| 1555 | 1555 | clear: both; |
| 1556 | 1556 | } |
| 1557 | 1557 | |
| 1558 | + | |
| 1559 | +/*************************** join community confirmation ********************************/ | |
| 1560 | + | |
| 1561 | +.join-community-confirmation h1 { | |
| 1562 | + font-variant: small-caps; | |
| 1563 | + font-size: 20px; | |
| 1564 | + color: #555753; | |
| 1565 | + text-align: left; | |
| 1566 | +} | |
| 1567 | + | |
| 1568 | +.join-community-confirmation { | |
| 1569 | + padding: 5px 20px 0px 20px; | |
| 1570 | +} | |
| 1571 | + | |
| 1572 | +.join-community-confirmation input.button.with-text { | |
| 1573 | + padding-right: 4px; | |
| 1574 | +} | |
| 1575 | + | ... | ... |
public/javascripts/add-and-join.js
| ... | ... | @@ -18,9 +18,11 @@ jQuery(function($) { |
| 18 | 18 | }) |
| 19 | 19 | |
| 20 | 20 | $(".join-community").live('click', function(){ |
| 21 | + $('#cboxClose').remove(); | |
| 21 | 22 | clicked = $(this); |
| 22 | 23 | url = clicked.attr("href"); |
| 23 | - loading_for_button(this); | |
| 24 | + if (!clicked.hasClass('modal-toggle')) | |
| 25 | + loading_for_button(this); | |
| 24 | 26 | $.post(url, function(data){ |
| 25 | 27 | clicked.fadeOut(function(){ |
| 26 | 28 | clicked.css("display","none"); | ... | ... |
public/javascripts/profile_editor.js
| ... | ... | @@ -23,4 +23,14 @@ |
| 23 | 23 | }); |
| 24 | 24 | |
| 25 | 25 | }); |
| 26 | + | |
| 27 | + $("#profile_data_closed_false").click(function(){ | |
| 28 | + $("#requires_email_option").prop("checked",false); | |
| 29 | + $("#requires_email_option").hide(); | |
| 30 | + }); | |
| 31 | + | |
| 32 | + $("#profile_data_closed_true").click(function(){ | |
| 33 | + $("#requires_email_option").show(); | |
| 34 | + }); | |
| 35 | + | |
| 26 | 36 | })(jQuery); | ... | ... |
test/functional/profile_controller_test.rb
| ... | ... | @@ -3,6 +3,8 @@ require 'profile_controller' |
| 3 | 3 | |
| 4 | 4 | class ProfileControllerTest < ActionController::TestCase |
| 5 | 5 | |
| 6 | + include MembershipsHelper | |
| 7 | + | |
| 6 | 8 | self.default_params = {profile: 'testuser'} |
| 7 | 9 | def setup |
| 8 | 10 | @profile = create_user('testuser').person |
| ... | ... | @@ -384,6 +386,61 @@ class ProfileControllerTest < ActionController::TestCase |
| 384 | 386 | assert_redirected_to :controller => 'account', :action => 'login' |
| 385 | 387 | end |
| 386 | 388 | |
| 389 | + should 'show regular join button for person with public email' do | |
| 390 | + community = Community.create!(:name => 'my test community', :closed => true, :requires_email => true) | |
| 391 | + Person.any_instance.stubs(:public_fields).returns(["email"]) | |
| 392 | + login_as(@profile.identifier) | |
| 393 | + | |
| 394 | + get :index, :profile => community.identifier | |
| 395 | + assert_no_tag :tag => 'a', :attributes => { :class => /modal-toggle join-community/ } | |
| 396 | + end | |
| 397 | + | |
| 398 | + should 'show join modal for person with private email' do | |
| 399 | + community = Community.create!(:name => 'my test community', :closed => true, :requires_email => true) | |
| 400 | + Person.any_instance.stubs(:public_fields).returns([]) | |
| 401 | + login_as(@profile.identifier) | |
| 402 | + | |
| 403 | + get :index, :profile => community.identifier | |
| 404 | + assert_tag :tag => 'a', :attributes => { :class => /modal-toggle join-community/ } | |
| 405 | + end | |
| 406 | + | |
| 407 | + should 'show regular join button for community without email visibility requirement' do | |
| 408 | + community = Community.create!(:name => 'my test community', :closed => true, :requires_email => false) | |
| 409 | + Person.any_instance.stubs(:public_fields).returns([]) | |
| 410 | + login_as(@profile.identifier) | |
| 411 | + | |
| 412 | + get :index, :profile => community.identifier | |
| 413 | + assert_no_tag :tag => 'a', :attributes => { :class => /modal-toggle join-community/ } | |
| 414 | + end | |
| 415 | + | |
| 416 | + should 'show regular join button for community without email visibility requirement and person with public email' do | |
| 417 | + community = Community.create!(:name => 'my test community', :closed => true, :requires_email => false) | |
| 418 | + Person.any_instance.stubs(:public_fields).returns(['email']) | |
| 419 | + login_as(@profile.identifier) | |
| 420 | + | |
| 421 | + get :index, :profile => community.identifier | |
| 422 | + assert_no_tag :tag => 'a', :attributes => { :class => /modal-toggle join-community/ } | |
| 423 | + end | |
| 424 | + | |
| 425 | + should 'render join modal for community with email visibility requirement and person with private email' do | |
| 426 | + community = Community.create!(:name => 'my test community', :closed => true, :requires_email => true) | |
| 427 | + login_as @profile.identifier | |
| 428 | + post :join, :profile => community.identifier | |
| 429 | + assert_template "join" | |
| 430 | + end | |
| 431 | + | |
| 432 | + should 'create add member task from join-community modal' do | |
| 433 | + community = Community.create!(:name => 'my test community', :closed => true, :requires_email => true) | |
| 434 | + admin = create_user('community-admin').person | |
| 435 | + community.add_admin(admin) | |
| 436 | + | |
| 437 | + login_as @profile.identifier | |
| 438 | + assert_difference 'AddMember.count' do | |
| 439 | + post :join_modal, :profile => community.identifier | |
| 440 | + end | |
| 441 | + assert_redirected_to :action => 'index' | |
| 442 | + end | |
| 443 | + | |
| 387 | 444 | should 'actually leave profile' do |
| 388 | 445 | community = fast_create(Community) |
| 389 | 446 | admin = fast_create(Person) | ... | ... |