From 41c0c26330aed8903083f5bf750413d3ce72276e Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 9 May 2012 11:38:29 +0800 Subject: [PATCH] Add mail_settings --- app/mailer/cron_mail.rb | 27 ++++++++++++++++++++- app/models/site.rb | 2 ++ app/views/admin/sites/mail_setting.html.erb | 19 ++++++++++++++- config/environments/development.rb | 20 +++++++-------- 4 files changed, 56 insertions(+), 12 deletions(-) diff --git a/app/mailer/cron_mail.rb b/app/mailer/cron_mail.rb index 8a4c9700..bda1d063 100644 --- a/app/mailer/cron_mail.rb +++ b/app/mailer/cron_mail.rb @@ -1,8 +1,33 @@ class CronMail < ActionMailer::Base default :from => "orbit_test@rulingcom.com" + def get_settings + # @@smtp_settings = { + # :address => "smtp.gmail.com", + # :port => '587', + # :domain => "smtp.gmail.com", + # :authentication => "plain", + # :user_name => "redmine@rulingcom.com", + # :password => "rulingredmine", + # :tls => true, + # :enable_starttls_auto => true + # } + @@smtp_settings = { + :address => @site['mail_settings']['address'], + :port => @site['mail_settings']['port'], + :domain => @site['mail_settings']['domain'], + :authentication => @site['mail_settings']['authentication'], + :user_name => @site['mail_settings']['user_name'], + :password => @site['mail_settings']['password'], + :tls => @site['mail_settings']['tls'], + :enable_starttls_auto => @site['mail_settings']['enable_starttls_auto'] + } + end + + def time_check(msg) + get_settings #attachments["rails.png"] = File.read("#{Rails.root}/public/images/rails.png") - mail(:to => "Matt ", :subject => msg) + mail(:to => "Chris ", :subject => msg) end end \ No newline at end of file diff --git a/app/models/site.rb b/app/models/site.rb index a0116bd3..55d6bfaf 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -12,6 +12,8 @@ class Site field :private_key, :type => Binary field :public_key, :type => Binary field :title_always_on, :type => Boolean, :default => false + + field :mail_settings, :type => Hash field :school field :department diff --git a/app/views/admin/sites/mail_setting.html.erb b/app/views/admin/sites/mail_setting.html.erb index aaef1857..5c94e174 100644 --- a/app/views/admin/sites/mail_setting.html.erb +++ b/app/views/admin/sites/mail_setting.html.erb @@ -2,4 +2,21 @@ <%= render 'side_bar' %> <% end %> -mail_setting.html.erb \ No newline at end of file +
+<%= form_for @site, :url => admin_site_path(@site), :html => {:class => "clear"} do |f| %> + <%= f.fields_for :site_settings, @site['site_settings'] do |f| %> + address: <%= f.text_field :address, :value => @site['site_settings']['address'] %> + port: <%= f.text_field :port, :value => @site['site_settings']['port'] %> + domain: <%= f.text_field :domain, :value => @site['site_settings']['domain'] %> + authentication: <%= f.text_field :authentication, :value => @site['site_settings']['authentication'] %> + user_name: <%= f.text_field :user_name, :value => @site['site_settings']['user_name'] %> + password: <%= f.text_field :password, :value => @site['site_settings']['password'] %> + tls: <%= f.check_box :tls, :checked => @site['site_settings']['tls'].eql?('1') %> + enable_starttls_auto: <%= f.check_box 'enable_starttls_auto', :checked => @site['site_settings']['enable_starttls_auto'].eql?('1') %> + <% end %> +
+ <%= f.submit t("submit"), :class => "btn btn-primary" %> + <%= f.submit t("cancel"), :class => "btn ", :type => 'reset' %> +
+<% end %> +
\ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 20f4519b..02624772 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -29,16 +29,16 @@ Orbit::Application.configure do # :sender_address => %{"notifier" }, # :exception_recipients => %w{chris@rulingcom.com} - config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { - :tls => true, - :enable_starttls_auto => true, - :address => "smtp.gmail.com", - :port => '587', - :domain => "smtp.gmail.com", - :authentication => "plain", - :user_name => "redmine@rulingcom.com", - :password => "rulingredmine" } + # config.action_mailer.delivery_method = :smtp + # config.action_mailer.smtp_settings = { + # :tls => true, + # :enable_starttls_auto => true, + # :address => "smtp.gmail.com", + # :port => '587', + # :domain => "smtp.gmail.com", + # :authentication => "plain", + # :user_name => "redmine@rulingcom.com", + # :password => "rulingredmine" } end