Desenv - adds the ability to set the from email #95

Closed
wants to merge 7 commits into
from
View
@@ -17,3 +17,5 @@ Refinery::Testing::Railtie.load_tasks
Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
load File.expand_path('../tasks/rspec.rake', __FILE__)
+
+task :default => :spec
@@ -41,7 +41,7 @@ def find_all_spam
end
def get_spam_count
- @spam_count = Refinery::Inquiries::Inquiry.count(:conditions => {:spam => true})
+ @spam_count = Refinery::Inquiries::Inquiry.where(:spam => true).count
end
end
@@ -6,15 +6,15 @@ def confirmation(inquiry, request)
@inquiry = inquiry
mail :subject => Refinery::Inquiries::Setting.confirmation_subject(Globalize.locale),
:to => inquiry.email,
- :from => "\"#{Refinery::Core.site_name}\" <no-reply@#{request.domain}>",
+ :from => "\"#{Refinery::Core.site_name}\" <#{Refinery::Inquiries.inquiry_from_email}>",

This comment has been minimized.

Show comment Hide comment
@ugisozols

ugisozols Oct 4, 2012

Member

I like request.domain because then user doesn't have to configure yet another thing. Maybe we could set Refinery::Inquiries.inquiry_from_email to nil by default and use something like this:

def from(request)
  Refinery::Inquiries.inquiry_from_email || "no-reply@#{request.domain}"
end

....

mail :from => "\"#{Refinery::Core.site_name}\" <#{from(request)}>"
@ugisozols

ugisozols Oct 4, 2012

Member

I like request.domain because then user doesn't have to configure yet another thing. Maybe we could set Refinery::Inquiries.inquiry_from_email to nil by default and use something like this:

def from(request)
  Refinery::Inquiries.inquiry_from_email || "no-reply@#{request.domain}"
end

....

mail :from => "\"#{Refinery::Core.site_name}\" <#{from(request)}>"
:reply_to => Refinery::Inquiries::Setting.notification_recipients.split(',').first
end
def notification(inquiry, request)
@inquiry = inquiry
mail :subject => Refinery::Inquiries::Setting.notification_subject,
:to => Refinery::Inquiries::Setting.notification_recipients,
- :from => "\"#{Refinery::Core.site_name}\" <no-reply@#{request.domain}>"
+ :from => "\"#{Refinery::Core.site_name}\" <#{Refinery::Inquiries.inquiry_from_email}>",

This comment has been minimized.

Show comment Hide comment
@ugisozols

ugisozols Oct 4, 2012

Member

Indent it as it was previously + we don't need , at the end.

@ugisozols

ugisozols Oct 4, 2012

Member

Indent it as it was previously + we don't need , at the end.

end
end
@@ -1,14 +1,16 @@
<li class='clearfix record <%= cycle("on", "on-hover") %>'>
<span class='title'>
<%= link_to inquiry.name, refinery.inquiries_admin_inquiry_path(inquiry) %> <%= t('.said') %>
- <span class="preview"><%= truncate(strip_tags(inquiry.message), :length => 60) -%></span>
+ <span class="preview"><%= truncate(strip_tags(sanitize(inquiry.message)), :length => 60) -%></span>
</span>
<span class='actions'>
<%= link_to refinery_icon_tag('delete.png'),
refinery.inquiries_admin_inquiry_path(inquiry),
:class => "cancel confirm-delete",
:title => t('refinery.inquiries.admin.inquiries.delete'),
- :confirm => t('refinery.admin.delete.message', :title => inquiry.name),
+ :data => {
+ :confirm => t('refinery.admin.delete.message', :title => inquiry.name)
+ },
:method => :delete -%>
<%= link_to refinery_icon_tag('zoom.png'), refinery.inquiries_admin_inquiry_path(inquiry),
@@ -20,7 +20,9 @@
refinery.inquiries_admin_inquiry_path(@inquiry),
:class => 'delete_icon no-tooltip confirm-delete',
:title => t('refinery.inquiries.admin.inquiries.delete'),
- :confirm => t('refinery.admin.delete.message', :title => @inquiry.name),
+ :data => {
+ :confirm => t('refinery.admin.delete.message', :title => @inquiry.name)
+ },
:method => :delete %>
</li>
</ul>
@@ -20,7 +20,7 @@
<label class='stripped'><%= t('.from') %></label>
</td>
<td>
- <%= "#{Refinery::Core.site_name} &lt;no-reply@#{request.domain}&gt;".html_safe %>
+ <%= "#{Refinery::Core.site_name} &lt;#{Refinery::Inquiries.inquiry_from_email}&gt;".html_safe %>
</td>
</tr>
<% (defined?(Refinery::I18n) && Refinery::I18n.frontend_locales || [::I18n.locale]).each do |locale| %>
@@ -1,4 +1,4 @@
-<% content_for :body_content_left do %>
+<% content_for :body do %>
<div class='inquiries'>
<%= form_for [refinery, :inquiries, @inquiry] do |f| %>
<%= render :partial => "/refinery/admin/error_messages",
@@ -1,4 +1,5 @@
Refinery::Inquiries.configure do |config|
# Configure whether to show privacy link
# config.show_contact_privacy_link = <%= Refinery::Inquiries.show_contact_privacy_link.inspect %>
-end
+ # config.inquiry_from_email = <%= Refinery::Inquiries.inquiry_from_email.inspect %>
+end
@@ -1,6 +1,7 @@
require 'refinerycms-core'
require 'refinerycms-settings'
require 'filters_spam'
+require 'acts_as_indexed'
module Refinery
autoload :InquiriesGenerator, 'generators/refinery/inquiries/inquiries_generator'
@@ -2,8 +2,10 @@ module Refinery
module Inquiries
include ActiveSupport::Configurable
- config_accessor :show_contact_privacy_link
+ config_accessor :show_contact_privacy_link, :inquiry_from_email
self.show_contact_privacy_link = true
+ self.inquiry_from_email = "no-reply@localhost"
+
end
-end
+end