Commit 3331bbc7585e87d11ca2f6bd029b968d6df0989e
1 parent
ebd4f04a
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Implemented the administrator task notification option
Showing
3 changed files
with
28 additions
and
2 deletions
Show diff stats
app/models/profile.rb
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | # which by default is the one returned by Environment:default. |
| 4 | 4 | class Profile < ActiveRecord::Base |
| 5 | 5 | |
| 6 | - 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, :email_suggestions, :allow_members_to_invite, :invite_friends_only, :secret | |
| 6 | + 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, :email_suggestions, :allow_members_to_invite, :invite_friends_only, :secret, :administrator_mail_notification | |
| 7 | 7 | |
| 8 | 8 | # use for internationalizable human type names in search facets |
| 9 | 9 | # reimplement on subclasses |
| ... | ... | @@ -178,6 +178,7 @@ class Profile < ActiveRecord::Base |
| 178 | 178 | settings_items :description |
| 179 | 179 | settings_items :fields_privacy, :type => :hash, :default => {} |
| 180 | 180 | settings_items :email_suggestions, :type => :boolean, :default => false |
| 181 | + settings_items :administrator_mail_notification, :type => :boolean, :default => true | |
| 181 | 182 | |
| 182 | 183 | validates_length_of :description, :maximum => 550, :allow_nil => true |
| 183 | 184 | ... | ... |
app/models/task.rb
| ... | ... | @@ -57,6 +57,7 @@ class Task < ActiveRecord::Base |
| 57 | 57 | end |
| 58 | 58 | |
| 59 | 59 | after_create do |task| |
| 60 | + binding.pry | |
| 60 | 61 | unless task.status == Task::Status::HIDDEN |
| 61 | 62 | begin |
| 62 | 63 | task.send(:send_notification, :created) |
| ... | ... | @@ -67,7 +68,9 @@ class Task < ActiveRecord::Base |
| 67 | 68 | begin |
| 68 | 69 | target_msg = task.target_notification_message |
| 69 | 70 | if target_msg && task.target && !task.target.notification_emails.empty? |
| 70 | - TaskMailer.target_notification(task, target_msg).deliver | |
| 71 | + if target_profile_accepts_notification?(task) | |
| 72 | + TaskMailer.target_notification(task, target_msg).deliver | |
| 73 | + end | |
| 71 | 74 | end |
| 72 | 75 | rescue NotImplementedError => ex |
| 73 | 76 | Rails.logger.info ex.to_s |
| ... | ... | @@ -75,6 +78,18 @@ class Task < ActiveRecord::Base |
| 75 | 78 | end |
| 76 | 79 | end |
| 77 | 80 | |
| 81 | + def target_profile_accepts_notification?(task) | |
| 82 | + if target_is_profile?(task) | |
| 83 | + return task.target.administrator_mail_notification | |
| 84 | + else | |
| 85 | + true | |
| 86 | + end | |
| 87 | + end | |
| 88 | + | |
| 89 | + def target_is_profile?(task) | |
| 90 | + task.target.kind_of? Profile | |
| 91 | + end | |
| 92 | + | |
| 78 | 93 | # this method finished the task. It calls #perform, which must be overriden |
| 79 | 94 | # by subclasses. At the end a message (as returned by #finish_message) is |
| 80 | 95 | # sent to the requestor with #notify_requestor. | ... | ... |
app/views/profile_editor/_moderation.html.erb
| 1 | 1 | <h2><%= _('Moderation options') %></h2> |
| 2 | 2 | <% if profile.community? %> |
| 3 | 3 | <div style='margin-bottom: 1em'> |
| 4 | + <h4><%= _('Email Configuration:')%></h4> | |
| 5 | + </div> | |
| 6 | + <div style='margin-bottom: 0.5em'> | |
| 7 | + <%= check_box(:profile_data, :administrator_mail_notification, :style => 'float: left') %> | |
| 8 | + <div style='margin-left: 30px'> | |
| 9 | + <%= _('Send administrator Email for every task (Default: yes)') %> | |
| 10 | + </div> | |
| 11 | + </div> | |
| 12 | + | |
| 13 | + <div style='margin-bottom: 1em'> | |
| 4 | 14 | <h4><%= _('Invitation moderation:')%></h4> |
| 5 | 15 | </div> |
| 6 | 16 | <div style='margin-bottom: 0.5em'> | ... | ... |