diff --git a/app/models/profile.rb b/app/models/profile.rb index 23ec42d..3ea1cd2 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -5,7 +5,7 @@ class Profile < ActiveRecord::Base attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, :redirection_after_login, :custom_url_redirection, - :email_suggestions, :allow_members_to_invite, :invite_friends_only, :secret + :email_suggestions, :allow_members_to_invite, :invite_friends_only, :secret, :profile_admin_mail_notification # use for internationalizable human type names in search facets # reimplement on subclasses @@ -245,6 +245,7 @@ class Profile < ActiveRecord::Base settings_items :description settings_items :fields_privacy, :type => :hash, :default => {} settings_items :email_suggestions, :type => :boolean, :default => false + settings_items :profile_admin_mail_notification, :type => :boolean, :default => true validates_length_of :description, :maximum => 550, :allow_nil => true diff --git a/app/models/task.rb b/app/models/task.rb index eceee59..6e1c2e4 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -67,7 +67,9 @@ class Task < ActiveRecord::Base begin target_msg = task.target_notification_message if target_msg && task.target && !task.target.notification_emails.empty? - TaskMailer.target_notification(task, target_msg).deliver + if target_profile_accepts_notification?(task) + TaskMailer.target_notification(task, target_msg).deliver + end end rescue NotImplementedError => ex Rails.logger.info ex.to_s @@ -75,6 +77,14 @@ class Task < ActiveRecord::Base end end + def target_profile_accepts_notification?(task) + if task.target.kind_of? Organization + return task.target.profile_admin_mail_notification + else + true + end + end + # this method finished the task. It calls #perform, which must be overriden # by subclasses. At the end a message (as returned by #finish_message) is # sent to the requestor with #notify_requestor. diff --git a/app/views/profile_editor/_moderation.html.erb b/app/views/profile_editor/_moderation.html.erb index 749c653..0d3cb54 100644 --- a/app/views/profile_editor/_moderation.html.erb +++ b/app/views/profile_editor/_moderation.html.erb @@ -1,6 +1,16 @@