From 73446fe15e35c6e9d077b071bec7f06f64a1b6b9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 11 Sep 2013 21:17:28 +0300 Subject: [PATCH] Email templates when user was added to group --- app/mailers/emails/groups.rb | 11 +++++++++++ app/mailers/emails/profile.rb | 15 +++++++++++++++ app/mailers/emails/projects.rb | 1 - app/mailers/notify.rb | 14 ++------------ app/views/notify/group_access_granted_email.html.haml | 5 +++++ app/views/notify/group_access_granted_email.text.erb | 4 ++++ 6 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 app/mailers/emails/groups.rb create mode 100644 app/mailers/emails/profile.rb create mode 100644 app/views/notify/group_access_granted_email.html.haml create mode 100644 app/views/notify/group_access_granted_email.text.erb diff --git a/app/mailers/emails/groups.rb b/app/mailers/emails/groups.rb new file mode 100644 index 0000000..2e9d289 --- /dev/null +++ b/app/mailers/emails/groups.rb @@ -0,0 +1,11 @@ +module Emails + module Groups + def group_access_granted_email(user_group_id) + @membership = UsersGroup.find(user_group_id) + @group = @membership.group + + mail(to: @membership.user.email, + subject: subject("access to group was granted")) + end + end +end diff --git a/app/mailers/emails/profile.rb b/app/mailers/emails/profile.rb new file mode 100644 index 0000000..bcd44f9 --- /dev/null +++ b/app/mailers/emails/profile.rb @@ -0,0 +1,15 @@ +module Emails + module Profile + def new_user_email(user_id, password) + @user = User.find(user_id) + @password = password + mail(to: @user.email, subject: subject("Account was created for you")) + end + + def new_ssh_key_email(key_id) + @key = Key.find(key_id) + @user = @key.user + mail(to: @user.email, subject: subject("SSH key was added to your account")) + end + end +end diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index 1ad7ca5..4d5fe9e 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -7,7 +7,6 @@ module Emails subject: subject("access to project was granted")) end - def project_was_moved_email(project_id, user_id) @user = User.find user_id @project = Project.find project_id diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 7890ca7..2f7be00 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -3,6 +3,8 @@ class Notify < ActionMailer::Base include Emails::MergeRequests include Emails::Notes include Emails::Projects + include Emails::Profile + include Emails::Groups add_template_helper ApplicationHelper add_template_helper GitlabMarkdownHelper @@ -20,18 +22,6 @@ class Notify < ActionMailer::Base delay_for(2.seconds) end - def new_user_email(user_id, password) - @user = User.find(user_id) - @password = password - mail(to: @user.email, subject: subject("Account was created for you")) - end - - def new_ssh_key_email(key_id) - @key = Key.find(key_id) - @user = @key.user - mail(to: @user.email, subject: subject("SSH key was added to your account")) - end - private # Look up a User by their ID and return their email address diff --git a/app/views/notify/group_access_granted_email.html.haml b/app/views/notify/group_access_granted_email.html.haml new file mode 100644 index 0000000..5023ec7 --- /dev/null +++ b/app/views/notify/group_access_granted_email.html.haml @@ -0,0 +1,5 @@ +%p + = "You have been granted #{@membership.human_access} access to group" +%p + = link_to group_url(@group) do + = @group.name diff --git a/app/views/notify/group_access_granted_email.text.erb b/app/views/notify/group_access_granted_email.text.erb new file mode 100644 index 0000000..331bb98 --- /dev/null +++ b/app/views/notify/group_access_granted_email.text.erb @@ -0,0 +1,4 @@ + +You have been granted <%= @membership.human_access %> access to group <%= @group.name %> + +<%= url_for(group_url(@group)) %> -- libgit2 0.21.2