adds email sending preferences [#23]
This commit is contained in:
@@ -17,7 +17,7 @@ class AccountController < ApplicationController
|
||||
end
|
||||
|
||||
def account_params
|
||||
params.require(:account).permit(:first_name, :last_name, :nickname, :use_nickname)
|
||||
params.require(:account).permit(:first_name, :last_name, :nickname, :use_nickname, :email_on_debate_comment, :email_on_comment_reply)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,8 +8,8 @@ class CommentsController < ApplicationController
|
||||
@comment.save!
|
||||
@comment.move_to_child_of(@parent) if reply?
|
||||
|
||||
Mailer.comment(@comment).deliver_now
|
||||
Mailer.reply(@comment).deliver_now
|
||||
Mailer.comment(@comment).deliver_now if email_on_debate_comment?
|
||||
Mailer.reply(@comment).deliver_now if email_on_comment_reply?
|
||||
|
||||
respond_with @comment
|
||||
end
|
||||
@@ -36,4 +36,12 @@ class CommentsController < ApplicationController
|
||||
def reply?
|
||||
@parent.class == Comment
|
||||
end
|
||||
|
||||
def email_on_debate_comment?
|
||||
@comment.debate.author.email_on_debate_comment?
|
||||
end
|
||||
|
||||
def email_on_comment_reply?
|
||||
reply? && @parent.author.email_on_comment_reply?
|
||||
end
|
||||
end
|
||||
@@ -15,6 +15,16 @@
|
||||
<%= f.label :nickname, t("account.show.nickname_label") %>
|
||||
<%= f.text_field :nickname %>
|
||||
|
||||
<div>
|
||||
<%= f.check_box :email_on_debate_comment %>
|
||||
<%= f.label :email_on_debate_comment, t("account.show.email_on_debate_comment_label") %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= f.check_box :email_on_comment_reply %>
|
||||
<%= f.label :email_on_comment_reply, t("account.show.email_on_comment_reply_label") %>
|
||||
</div>
|
||||
|
||||
<%= f.submit t("account.show.save_changes_submit"), class: "button radius" %>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ en:
|
||||
show:
|
||||
title: "My account"
|
||||
save_changes_submit: "Save changes"
|
||||
email_on_debate_comment_label: "Receive email when someone comments on my debates"
|
||||
email_on_comment_reply_label: "Receive email when someone replies to my comments"
|
||||
change_credentials_link: "Change my credentials"
|
||||
first_name_label: "First Name"
|
||||
last_name_label: "Last Name"
|
||||
|
||||
@@ -62,6 +62,8 @@ es:
|
||||
show:
|
||||
title: "Mi cuenta"
|
||||
save_changes_submit: "Guardar cambios"
|
||||
email_on_debate_comment_label: "Recibir un email cuando alguien commenta en mis debates"
|
||||
email_on_comment_reply_label: "Recibir un email cuando alguien contesta a mis comentarios"
|
||||
change_credentials_link: "Cambiar mi contraseña"
|
||||
first_name_label: "Nombre"
|
||||
last_name_label: "Apellidos"
|
||||
|
||||
6
db/migrate/20150806163142_add_preferences_to_users.rb
Normal file
6
db/migrate/20150806163142_add_preferences_to_users.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AddPreferencesToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :email_on_debate_comment, :boolean, default: false
|
||||
add_column :users, :email_on_comment_reply, :boolean, default: false
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150806140048) do
|
||||
ActiveRecord::Schema.define(version: 20150806163142) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -82,6 +82,8 @@ ActiveRecord::Schema.define(version: 20150806140048) do
|
||||
t.string "unconfirmed_email"
|
||||
t.string "nickname"
|
||||
t.boolean "use_nickname", default: false, null: false
|
||||
t.boolean "email_on_debate_comment", default: false
|
||||
t.boolean "email_on_comment_reply", default: false
|
||||
end
|
||||
|
||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
|
||||
|
||||
Reference in New Issue
Block a user