diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index fed9711ee..b8015af79 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -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 diff --git a/app/models/group.rb b/app/models/group.rb index 934b53bd3..0e69accaa 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -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 diff --git a/app/models/platform.rb b/app/models/platform.rb index ea4db6d70..aefa55ffd 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -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 diff --git a/app/views/user_mailer/metadata_regeneration_notification.en.haml b/app/views/user_mailer/metadata_regeneration_notification.en.haml new file mode 100644 index 000000000..b9589a3d8 --- /dev/null +++ b/app/views/user_mailer/metadata_regeneration_notification.en.haml @@ -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' \ No newline at end of file diff --git a/app/views/user_mailer/metadata_regeneration_notification.ru.haml b/app/views/user_mailer/metadata_regeneration_notification.ru.haml new file mode 100644 index 000000000..20febac8c --- /dev/null +++ b/app/views/user_mailer/metadata_regeneration_notification.ru.haml @@ -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' \ No newline at end of file diff --git a/config/locales/models/activity_feed.en.yml b/config/locales/models/activity_feed.en.yml index 221fcf0ca..cdea9e975 100644 --- a/config/locales/models/activity_feed.en.yml +++ b/config/locales/models/activity_feed.en.yml @@ -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 diff --git a/config/locales/models/activity_feed.ru.yml b/config/locales/models/activity_feed.ru.yml index 3a4bd70e4..3f5988f86 100644 --- a/config/locales/models/activity_feed.ru.yml +++ b/config/locales/models/activity_feed.ru.yml @@ -20,6 +20,7 @@ ru: issue_assign_notification: Вам назначили задачу invite_approve_notification: Приглашение в ABF for_arch: для архитектуры %{arch}. + metadata_regeneration: Регенерация метаданных «%{status}» bodies: view_it_on: Смотрите это на