#328: Send email on project change
This commit is contained in:
parent
04964f0171
commit
126cdf1e68
|
@ -52,7 +52,7 @@ class UserMailer < ActionMailer::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_list_notification(build_list, user)
|
def build_list_notification(build_list, user)
|
||||||
I18n.locale = user.language if user.language
|
set_locale user
|
||||||
@user, @build_list = user, build_list
|
@user, @build_list = user, build_list
|
||||||
|
|
||||||
subject = "[№ #{build_list.id}] "
|
subject = "[№ #{build_list.id}] "
|
||||||
|
@ -69,7 +69,7 @@ class UserMailer < ActionMailer::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def invite_approve_notification(register_request)
|
def invite_approve_notification(register_request)
|
||||||
I18n.locale = register_request.language if register_request.language
|
set_locale register_request
|
||||||
@register_request = register_request
|
@register_request = register_request
|
||||||
mail(
|
mail(
|
||||||
:to => register_request.email,
|
:to => register_request.email,
|
||||||
|
@ -79,8 +79,32 @@ class UserMailer < ActionMailer::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def git_delete_branch_notification(user, options)
|
||||||
|
set_locale user
|
||||||
|
mail(
|
||||||
|
:to => user.email,
|
||||||
|
:subject => I18n.t('notifications.subjects.new_commit')
|
||||||
|
) do |format|
|
||||||
|
format.html { render 'git_delete_branch_notification', :locals => options }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def git_new_push_notification(user, options)
|
||||||
|
set_locale user
|
||||||
|
mail(
|
||||||
|
:to => user.email,
|
||||||
|
:subject => I18n.t('notifications.subjects.new_commit')
|
||||||
|
) do |format|
|
||||||
|
format.html { render 'git_new_push_notification', :locals => options }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def set_locale(user)
|
||||||
|
I18n.locale = user.language if user.language
|
||||||
|
end
|
||||||
|
|
||||||
def email_with_name(user, email = APP_CONFIG['do-not-reply-email'])
|
def email_with_name(user, email = APP_CONFIG['do-not-reply-email'])
|
||||||
"\"#{user.user_appeal}\" <#{email}>"
|
"\"#{user.user_appeal}\" <#{email}>"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
json.user do
|
json.user do
|
||||||
json.(@user, :id)
|
json.(@user, :id)
|
||||||
json.notifiers do
|
json.notifiers do
|
||||||
json.(@user.notifier, :can_notify, :new_comment, :new_comment_reply, :new_issue, :issue_assign, :new_comment_commit_owner, :new_comment_commit_repo_owner, :new_comment_commit_commentor, :new_build, :new_associated_build)
|
json.(@user.notifier, :can_notify, :new_comment, :new_comment_reply, :new_issue, :issue_assign, :new_comment_commit_owner, :new_comment_commit_repo_owner, :new_comment_commit_commentor, :new_build, :new_associated_build,
|
||||||
|
:new_commit)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
- user = User.where(:email => user_email).first || User.new(:email => user_email) if defined?(user_email)
|
||||||
|
|
||||||
|
%p
|
||||||
|
- _user_link = defined?(user_email) ? user_link(user, defined?(user_name) ? user_name : user_email) : nil
|
||||||
|
= t('notifications.bodies.delete_branch', :branch_name => branch_name, :user_link => _user_link).html_safe
|
||||||
|
= raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) )
|
||||||
|
|
||||||
|
= render 'footer'
|
|
@ -0,0 +1,20 @@
|
||||||
|
- user = User.where(:email => user_email).first || User.new(:email => user_email) if defined?(user_email)
|
||||||
|
|
||||||
|
|
||||||
|
%p
|
||||||
|
- _user_link = defined?(user_email) ? user_link(user, defined?(user_name) ? user_name : user_email) : nil
|
||||||
|
= raw t("notifications.bodies.#{change_type}_branch", {:branch_name => branch_name, :user_link => _user_link})
|
||||||
|
= raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) )
|
||||||
|
|
||||||
|
|
||||||
|
%p
|
||||||
|
- last_commits.each do |commit|
|
||||||
|
= link_to shortest_hash_id(commit[0]), commit_path(project_owner, project_name, commit[0])
|
||||||
|
= commit[1]
|
||||||
|
%br
|
||||||
|
- if defined? other_commits
|
||||||
|
%br
|
||||||
|
=link_to t('notifications.bodies.more_commits', :count => other_commits_count, :commits => commits_pluralize(other_commits_count)),
|
||||||
|
diff_path(project_owner, project_name, :diff => other_commits)
|
||||||
|
|
||||||
|
= render 'footer'
|
|
@ -9,7 +9,7 @@
|
||||||
= form_for @user.notifier, :url => notifiers_settings_path, :html => {:class => :form} do |f|
|
= form_for @user.notifier, :url => notifiers_settings_path, :html => {:class => :form} do |f|
|
||||||
= render 'notifier', :f => f, :field => :can_notify
|
= render 'notifier', :f => f, :field => :can_notify
|
||||||
%h3= t("layout.settings.notifiers.code_header")
|
%h3= t("layout.settings.notifiers.code_header")
|
||||||
- [:new_comment_commit_owner, :new_comment_commit_repo_owner, :new_comment_commit_commentor].each do |field|
|
- [:new_commit, :new_comment_commit_owner, :new_comment_commit_repo_owner, :new_comment_commit_commentor].each do |field|
|
||||||
= render 'notifier', :f => f, :field => field
|
= render 'notifier', :f => f, :field => field
|
||||||
%h3= t("layout.settings.notifiers.tracker_header")
|
%h3= t("layout.settings.notifiers.tracker_header")
|
||||||
- [:new_comment, :new_comment_reply, :new_issue, :issue_assign].each do |field|
|
- [:new_comment, :new_comment_reply, :new_issue, :issue_assign].each do |field|
|
||||||
|
|
|
@ -154,11 +154,11 @@ en:
|
||||||
group_already_added: Group already added
|
group_already_added: Group already added
|
||||||
successfully_added: Member %s successfully added
|
successfully_added: Member %s successfully added
|
||||||
error_in_adding: Member %s adding error
|
error_in_adding: Member %s adding error
|
||||||
wrong_user: User with nickname '%{uname}' not found!
|
wrong_user: "User with nickname '%{uname}' not found!"
|
||||||
|
|
||||||
blob:
|
blob:
|
||||||
successfully_updated: File '%{name}' successfully updated
|
successfully_updated: "File '%{name}' successfully updated"
|
||||||
updating_error: Error updating file '%{name}'
|
updating_error: "Error updating file '%{name}'"
|
||||||
|
|
||||||
attributes:
|
attributes:
|
||||||
password: Password
|
password: Password
|
||||||
|
@ -188,6 +188,7 @@ en:
|
||||||
new_comment_reply: New reply of comment notifications
|
new_comment_reply: New reply of comment notifications
|
||||||
new_issue: New task notifications
|
new_issue: New task notifications
|
||||||
issue_assign: New task assignment notifications
|
issue_assign: New task assignment notifications
|
||||||
|
new_commit: Notify about new commits in my projects
|
||||||
new_comment_commit_owner: Notify about comments to my commit
|
new_comment_commit_owner: Notify about comments to my commit
|
||||||
new_comment_commit_repo_owner: Notify about comments to my repository commits
|
new_comment_commit_repo_owner: Notify about comments to my repository commits
|
||||||
new_comment_commit_commentor: Notify about comments after my commit
|
new_comment_commit_commentor: Notify about comments after my commit
|
||||||
|
|
|
@ -12,6 +12,7 @@ en:
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
subjects:
|
subjects:
|
||||||
|
new_commit: "[%{ project_name }] Update of project"
|
||||||
new_comment_notification: New comment to your task
|
new_comment_notification: New comment to your task
|
||||||
new_commit_comment_notification: New comment to commit
|
new_commit_comment_notification: New comment to commit
|
||||||
new_issue_notification: New task added to project
|
new_issue_notification: New task added to project
|
||||||
|
|
|
@ -12,6 +12,7 @@ ru:
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
subjects:
|
subjects:
|
||||||
|
new_commit: "[%{ project_name }] Обновление проекта"
|
||||||
new_comment_notification: Новый комментарий к Вашей задаче
|
new_comment_notification: Новый комментарий к Вашей задаче
|
||||||
new_commit_comment_notification: Новый комментарий к коммиту
|
new_commit_comment_notification: Новый комментарий к коммиту
|
||||||
new_issue_notification: Новая задача добавлена к проекту
|
new_issue_notification: Новая задача добавлена к проекту
|
||||||
|
|
|
@ -154,11 +154,11 @@ ru:
|
||||||
group_already_added: Группа уже добавлена
|
group_already_added: Группа уже добавлена
|
||||||
successfully_added: Участник %s успешно добавлен
|
successfully_added: Участник %s успешно добавлен
|
||||||
error_in_adding: Ошибка при добавлении участника %s
|
error_in_adding: Ошибка при добавлении участника %s
|
||||||
wrong_user: Пользователь с ником '%{uname}' не найден.
|
wrong_user: "Пользователь с ником '%{uname}' не найден."
|
||||||
|
|
||||||
blob:
|
blob:
|
||||||
successfully_updated: Файл '%{name}' успешно обновлен
|
successfully_updated: "Файл '%{name}' успешно обновлен"
|
||||||
updating_error: Ошибка обновления файла '%{name}'
|
updating_error: "Ошибка обновления файла '%{name}'"
|
||||||
|
|
||||||
attributes:
|
attributes:
|
||||||
password: Пароль
|
password: Пароль
|
||||||
|
@ -188,6 +188,7 @@ ru:
|
||||||
new_comment_reply: Оповещать о новом ответе на мой комментарий
|
new_comment_reply: Оповещать о новом ответе на мой комментарий
|
||||||
new_issue: Оповещать о новых задачах в моих проектах
|
new_issue: Оповещать о новых задачах в моих проектах
|
||||||
issue_assign: Оповещать, когда на меня выставляют задачу
|
issue_assign: Оповещать, когда на меня выставляют задачу
|
||||||
|
new_commit: Оповещать о новых коммитах в моих проектах
|
||||||
new_comment_commit_owner: Оповещать о комментариях к моему коммиту
|
new_comment_commit_owner: Оповещать о комментариях к моему коммиту
|
||||||
new_comment_commit_repo_owner: Оповещать о комментариях к коммитам в моем репозитории
|
new_comment_commit_repo_owner: Оповещать о комментариях к коммитам в моем репозитории
|
||||||
new_comment_commit_commentor: Оповещать о комментариях к коммиту после моего
|
new_comment_commit_commentor: Оповещать о комментариях к коммиту после моего
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddNewCommitToSettingsNotifier < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :settings_notifiers, :new_commit, :boolean, :default => false
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20131107152408) do
|
ActiveRecord::Schema.define(:version => 20131126154305) do
|
||||||
|
|
||||||
create_table "activity_feeds", :force => true do |t|
|
create_table "activity_feeds", :force => true do |t|
|
||||||
t.integer "user_id", :null => false
|
t.integer "user_id", :null => false
|
||||||
|
@ -21,6 +21,8 @@ ActiveRecord::Schema.define(:version => 20131107152408) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "activity_feeds", ["user_id", "kind"], :name => "index_activity_feeds_on_user_id_and_kind"
|
||||||
|
|
||||||
create_table "advisories", :force => true do |t|
|
create_table "advisories", :force => true do |t|
|
||||||
t.string "advisory_id"
|
t.string "advisory_id"
|
||||||
t.text "description", :default => ""
|
t.text "description", :default => ""
|
||||||
|
@ -522,6 +524,7 @@ ActiveRecord::Schema.define(:version => 20131107152408) do
|
||||||
t.boolean "new_comment_commit_commentor", :default => true
|
t.boolean "new_comment_commit_commentor", :default => true
|
||||||
t.boolean "new_build", :default => true
|
t.boolean "new_build", :default => true
|
||||||
t.boolean "new_associated_build", :default => true
|
t.boolean "new_associated_build", :default => true
|
||||||
|
t.boolean "new_commit", :default => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "ssh_keys", :force => true do |t|
|
create_table "ssh_keys", :force => true do |t|
|
||||||
|
|
|
@ -44,6 +44,9 @@ module Modules::Observers::ActivityFeed::Git
|
||||||
:kind => kind,
|
:kind => kind,
|
||||||
:data => options
|
:data => options
|
||||||
)
|
)
|
||||||
|
if recipient.notifier.can_notify && recipient.notifier.new_commit
|
||||||
|
UserMailer.send(kind, recipient, options).deliver
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
when 'Hash' # 'Gollum::Committer'
|
when 'Hash' # 'Gollum::Committer'
|
||||||
|
|
Loading…
Reference in New Issue