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, :remember_me,
:getting_started, :getting_started,
email_preferences: [ email_preferences: [
:someone_reported,
:also_commented, :also_commented,
:mentioned, :mentioned,
:comment_on_post, :comment_on_post,

View file

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

View file

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

View file

@ -125,11 +125,22 @@
= f.fields_for :email_preferences do |type| = f.fields_for :email_preferences do |type|
#email_prefs #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 %p.checkbox_select
= type.label :started_sharing, t('.started_sharing') = type.label :started_sharing, t('.started_sharing')
= type.check_box :started_sharing, {:checked => @email_prefs['started_sharing']}, false, true = type.check_box :started_sharing, {:checked => @email_prefs['started_sharing']}, false, true
%br %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 %p.checkbox_select
= type.label :mentioned, t('.mentioned') = type.label :mentioned, t('.mentioned')
= type.check_box :mentioned, {:checked => @email_prefs['mentioned']}, false, true = type.check_box :mentioned, {:checked => @email_prefs['mentioned']}, false, true

View file

@ -113,11 +113,22 @@
= f.fields_for :email_preferences do |type| = f.fields_for :email_preferences do |type|
#email_prefs #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 %p.checkbox_select
= type.label :started_sharing, t('.started_sharing') = type.label :started_sharing, t('.started_sharing')
= type.check_box :started_sharing, {:checked => @email_prefs['started_sharing']}, false, true = type.check_box :started_sharing, {:checked => @email_prefs['started_sharing']}, false, true
%br %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 %p.checkbox_select
= type.label :mentioned, t('.mentioned') = type.label :mentioned, t('.mentioned')
= type.check_box :mentioned, {:checked => @email_prefs['mentioned']}, false, true = type.check_box :mentioned, {:checked => @email_prefs['mentioned']}, false, true

View file

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