Skip to content

Commit

Permalink
add user and admin mailer
Browse files Browse the repository at this point in the history
  • Loading branch information
ismail Akbudak committed Jun 21, 2016
1 parent bda5265 commit aaa838d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 11 deletions.
11 changes: 10 additions & 1 deletion lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ def copy_files
say 'Coping files..'
remove_file 'config/locales/en.yml'
remove_file 'config/locales/simple_form.en.yml'
directory 'config/locales', 'config/locales'
copy_file 'config/locales/models.tr.yml', 'config/locales/models.tr.yml'
copy_file 'config/locales/show_for.tr.yml', 'config/locales/show_for.tr.yml'
copy_file 'config/locales/simple_form.tr.yml', 'config/locales/simple_form.tr.yml'
copy_file 'config/locales/view.tr.yml', 'config/locales/view.tr.yml'
copy_file 'config/locales/email.tr.yml', 'config/locales/email.tr.yml'

# Model files
remove_file 'app/models/admin.rb'
Expand Down Expand Up @@ -428,6 +432,11 @@ def copy_files
copy_file 'config/initializers/devise_async.rb', 'config/initializers/devise_async.rb'
copy_file 'config/schedule.yml', 'config/schedule.yml'
copy_file 'config/sidekiq.yml', 'config/sidekiq.yml'

# Mailer files
directory 'app/mailers', 'app/mailers'
directory 'app/views/admin_mailer', 'app/views/admin_mailer'
directory 'app/views/user_mailer', 'app/views/user_mailer'
end

private
Expand Down
4 changes: 2 additions & 2 deletions templates/app/mailers/admin_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class AdminMailer < BaseMailer

def send_login_information(admin_id, password)
def login_info(admin_id, password)
@admin = Admin.find admin_id
@password = password
@subject = t('email.admin.send_login_information.title')
@subject = t('email.admin.login_info.title')
mail(to: @admin.email, subject: @subject)
end

Expand Down
4 changes: 2 additions & 2 deletions templates/app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class UserMailer < BaseMailer

def send_login_information(user_id, password)
def login_info(user_id, password)
@user = User.find user_id
@password = password
@subject = t('email.user.send_login_information.title')
@subject = t('email.user.login_info.title')
mail(to: @user.email, subject: @subject)
end

Expand Down
6 changes: 3 additions & 3 deletions templates/app/models/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Admin < ActiveRecord::Base
:validatable

# Validations
validates_presence_of :name, :email
validates_presence_of :name, :email, :surname
validates :email, uniqueness: true

# Callbacks
Expand All @@ -31,7 +31,7 @@ def inactive_message
end

def full_name
"#{self.name}"
"#{self.name} #{self.surname}"
end

private
Expand All @@ -46,7 +46,7 @@ def create_password
end

def send_login_info
AdminMailer.send_login_information(self.id, self.password).deliver_later! if self.is_generated_password
AdminMailer.login_info(self.id, self.password).deliver_later! if self.is_generated_password
end

end
2 changes: 1 addition & 1 deletion templates/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ def create_password
end

def send_login_info
UserMailer.send_login_information(self.id, self.password).deliver_later! if self.is_generated_password
UserMailer.login_info(self.id, self.password).deliver_later! if self.is_generated_password
end
end
13 changes: 13 additions & 0 deletions templates/app/views/admin_mailer/login_info.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
%h2= t('email.only_hello')

%p= t('email.admin.login_info.first_info')
%p= "#{t('email.admin.login_info.second_info')} :"
%p
%strong= "#{t('activerecord.attributes.admin.email')} :"
= @admin.email
%p
%strong= "#{t('activerecord.attributes.admin.password')} :"
= @password
%p= link_to t('email.admin.login_info.btn_login'), new_admin_session_url

%p= t('email.admin.login_info.last_info', link: new_admin_session_url ).html_safe
13 changes: 13 additions & 0 deletions templates/app/views/user_mailer/login_info.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
%h2= t('email.only_hello')

%p= t('email.user.login_info.first_info')
%p= t('email.user.login_info.second_info')
%p
%strong= "#{t('activerecord.attributes.user.email')} :"
= @user.email
%p
%strong= "#{t('activerecord.attributes.user.password')} :"
= @password
%p= link_to t('email.user.login_info.btn_login'), new_user_session_url

%p= t('email.user.login_info.last_info', link: new_user_session_url ).html_safe
4 changes: 2 additions & 2 deletions templates/config/locales/email.tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ tr:
desc2: Eğer bu isteği siz yapmadıysanız bu e-posta'yı yok sayınız.
desc3: Parolanız yukarıdaki link'e erişip yeni bir parola oluşturmadığınız sürece değişmeyecektir.
admin:
send_login_information:
login_info:
title: Yönetici Giriş Bilgileriniz
first_info: Portal üzerinden yönetici hesabınız oluşturuldu. Artık yönetici portalına giriş yapabilirsiniz.
second_info: Giriş bilgileriniz şu şekildedir
btn_login: Giriş yapmak için tıklayınız
last_info: "Eğer 'Giriş Yap' butonunu kullanamıyorsanız giriş linkiniz şu şekildedir <br/> <strong> Link : </strong> %{link} </br> Bu linki kopyalayıp tarayıcınıza yapıştırınız.."
user:
send_login_information:
login_info:
title: Kullanıcı Giriş Bilgileriniz
first_info: Portal üzerinden kullanıcı hesabınız oluşturuldu. Artık kullanıcı portalına giriş yapabilirsiniz.
second_info: Giriş bilgileriniz şu şekildedir
Expand Down

0 comments on commit aaa838d

Please sign in to comment.