Added the ability to disable report-email-notification

Podmin can see a extra checkbox in Settings > Account
for disabling report-email-notification
This commit is contained in:
Lukas Matt 2014-03-21 10:48:48 -04:00
parent 719edcd1a7
commit 26d0c81dae
6 changed files with 33 additions and 5 deletions

View file

@ -179,6 +179,7 @@ class UsersController < ApplicationController
:remember_me,
:getting_started,
email_preferences: [
:someone_reported,
:also_commented,
:mentioned,
:comment_on_post,

View file

@ -9,8 +9,11 @@ class ReportMailer < ActionMailer::Base
:id => id
}
Role.admins.each do |role|
resource[:email] = User.find_by_id(role.person_id).email
format(resource).deliver
user = User.find_by_id(role.person_id)
if !user.user_preferences.exists?(:email_type => :someone_reported)
resource[:email] = user.email
format(resource).deliver
end
end
end

View file

@ -4,7 +4,8 @@ class UserPreference < ActiveRecord::Base
validate :must_be_valid_email_type
VALID_EMAIL_TYPES =
["mentioned",
["someone_reported",
"mentioned",
"comment_on_post",
"private_message",
"started_sharing",

View file

@ -125,11 +125,22 @@
= f.fields_for :email_preferences do |type|
#email_prefs
- if current_user.admin?
%p.checkbox_select
= type.label :someone_reported, t('.someone_reported')
= type.check_box :someone_reported, {:checked => @email_prefs['someone_reported']}, false, true
%br
%p.checkbox_select
= type.label :started_sharing, t('.started_sharing')
= type.check_box :started_sharing, {:checked => @email_prefs['started_sharing']}, false, true
%br
%p.checkbox_select
= type.label :also_commented, t('.also_commented')
= type.check_box :also_commented, {:checked => @email_prefs['also_commented']}, false, true
%br
%p.checkbox_select
= type.label :mentioned, t('.mentioned')
= type.check_box :mentioned, {:checked => @email_prefs['mentioned']}, false, true

View file

@ -113,14 +113,25 @@
= f.fields_for :email_preferences do |type|
#email_prefs
- if current_user.admin?
%p.checkbox_select
= type.label :someone_reported, t('.someone_reported')
= type.check_box :someone_reported, {:checked => @email_prefs['someone_reported']}, false, true
%br
%p.checkbox_select
= type.label :started_sharing, t('.started_sharing')
= type.check_box :started_sharing, {:checked => @email_prefs['started_sharing']}, false, true
%br
%p.checkbox_select
= type.label :mentioned, t('.mentioned')
= type.check_box :mentioned, {:checked => @email_prefs['mentioned']}, false, true
= type.label :also_commented, t('.also_commented')
= type.check_box :also_commented, {:checked => @email_prefs['also_commented']}, false, true
%br
%p.checkbox_select
= type.label :mentioned, t('.mentioned')
= type.check_box :mentioned, {:checked => @email_prefs['mentioned']}, false, true
%br
%p.checkbox_select

View file

@ -1221,6 +1221,7 @@ en:
edit_account: "Edit account"
receive_email_notifications: "Receive email notifications when:"
started_sharing: "someone starts sharing with you"
someone_reported: "someone sent a report"
mentioned: "you are mentioned in a post"
liked: "someone likes your post"
reshared: "someone reshares your post"