#349: send notifications to platform members

This commit is contained in:
Vokhmin Alexey V 2014-02-12 01:28:32 +04:00
parent 430e01f649
commit 672aa331be
7 changed files with 49 additions and 1 deletions

View File

@ -69,6 +69,21 @@ class UserMailer < ActionMailer::Base
end
end
def metadata_regeneration_notification(platform, user)
set_locale user
@user, @platform = user, platform
subject = "[#{platform.name}] "
subject << I18n.t("notifications.subjects.metadata_regeneration", status: I18n.t("layout.regeneration_statuses.last_regenerated_statuses.#{platform.human_regeneration_status}"))
mail(
to: email_with_name(user, user.email),
subject: subject,
from: email_with_name(platform.owner)
) do |format|
format.html
end
end
def invite_approve_notification(register_request)
set_locale register_request
@register_request = register_request

View File

@ -23,7 +23,7 @@ class Group < Avatar
attr_accessible :uname, :description
attr_readonly :uname
delegate :email, to: :owner
delegate :email, :user_appeal, to: :owner
after_create :add_owner_to_members

View File

@ -71,6 +71,9 @@ class Platform < ActiveRecord::Base
include Modules::Models::Owner
state_machine :status, initial: :ready do
after_transition on: :ready, do: :notify_users
event :ready do
transition regenerating: :ready
end
@ -265,4 +268,10 @@ class Platform < ActiveRecord::Base
repositories.update_all(publish_without_qa: false)
end
end
def notify_users
users = members.includes(:notifier).select{ |u| u.notifier.can_notify? }
users.each{ |u| UserMailer.metadata_regeneration_notification(self, u).deliver }
end
end

View File

@ -0,0 +1,11 @@
%p
Metadata regeneration for platform
= link_to @platform.name, platform_url(@platform)
completed with status
%b
= t("layout.regeneration_statuses.last_regenerated_statuses.#{@platform.human_regeneration_status}")
%p
More detailed information you can get by link:
= link_to t('layout.platforms.metadata'), edit_platform_url(@platform)
= render 'footer'

View File

@ -0,0 +1,11 @@
%p
Регенерация метаданных для платформы
= link_to @platform.name, platform_url(@platform)
завершена со статусом
%b
= t("layout.regeneration_statuses.last_regenerated_statuses.#{@platform.human_regeneration_status}")
%p
Более подробную информацию можно получить по ссылке:
= link_to t('layout.platforms.metadata'), edit_platform_url(@platform)
= render 'footer'

View File

@ -20,6 +20,7 @@ en:
issue_assign_notification: New task assigned
invite_approve_notification: Invitation to ABF
for_arch: for arch %{arch}.
metadata_regeneration: Metadata regeneration «%{status}»
bodies:
view_it_on: View it on

View File

@ -20,6 +20,7 @@ ru:
issue_assign_notification: Вам назначили задачу
invite_approve_notification: Приглашение в ABF
for_arch: для архитектуры %{arch}.
metadata_regeneration: Регенерация метаданных «%{status}»
bodies:
view_it_on: Смотрите это на