spud_inquiries 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,24 @@
|
|
1
1
|
class ContactsController < ApplicationController
|
2
|
+
caches_action :show,:if => Proc.new { |c| Spud::Inquiries.enable_action_caching }
|
3
|
+
caches_action :thankyou,:if => Proc.new { |c| Spud::Inquiries.enable_action_caching }
|
2
4
|
def show
|
3
5
|
url_name = !params[:id].blank? ? params[:id] : Spud::Inquiries.default_contact_form
|
4
6
|
@inquiry_form = SpudInquiryForm.where(:url_name => url_name).includes(:spud_inquiry_form_fields).first
|
7
|
+
|
8
|
+
|
5
9
|
if @inquiry_form.blank?
|
6
10
|
flash[:error] = "Contact Inquiry Form not found!"
|
7
11
|
redirect_to root_url and return
|
8
12
|
end
|
13
|
+
@inquiry = SpudInquiry.new(:spud_inquiry_form_id => @inquiry_form.id)
|
9
14
|
render :layout => Spud::Inquiries.base_layout
|
10
15
|
end
|
11
16
|
|
12
17
|
def inquire
|
18
|
+
if !params[:other_email].blank?
|
19
|
+
flash[:error] = "You must be a robot! No robots allowed here!"
|
20
|
+
redirect_to request.referer and return
|
21
|
+
end
|
13
22
|
unless params[:spud_inquiry]
|
14
23
|
flash[:error] = "Inquiry Not Found!"
|
15
24
|
redirect_to request.referer and return
|
@@ -24,10 +33,22 @@ class ContactsController < ApplicationController
|
|
24
33
|
@inquiry.recipients = @inquiry_form.recipients
|
25
34
|
@inquiry.subject = @inquiry_form.subject
|
26
35
|
|
27
|
-
|
28
|
-
|
29
|
-
|
36
|
+
@inquiry_form.spud_inquiry_form_fields.order(:field_order).all.each do |field|
|
37
|
+
val = params[:spud_inquiry][field.name]
|
38
|
+
if field.required && val.blank?
|
39
|
+
flash[:error] = "Not all required fields were entered"
|
40
|
+
@inquiry.errors.add field.name,"is a required field"
|
41
|
+
# redirect_to request.referer and return
|
30
42
|
end
|
43
|
+
@inquiry.spud_inquiry_fields.new(:name => field.name,:value => val)
|
44
|
+
end
|
45
|
+
# params[:spud_inquiry].each_pair do |key,value|
|
46
|
+
# if key.to_s != "email" && key.to_s != "spud_inquiry_form_id"
|
47
|
+
# @inquiry.spud_inquiry_fields.new(:name => key,:value => value)
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
if !@inquiry.errors.empty?
|
51
|
+
render :action => "show" and return
|
31
52
|
end
|
32
53
|
if @inquiry.save
|
33
54
|
flash[:notice] = "Your inquiry was received!"
|
@@ -32,11 +32,17 @@ class Spud::Admin::InquiryFormsController < Spud::Admin::ApplicationController
|
|
32
32
|
def update
|
33
33
|
@page_name = "Edit Inquiry Form"
|
34
34
|
flash[:notice] = "Form saved successfully!" if @inquiry_form.update_attributes(params[:spud_inquiry_form])
|
35
|
+
if Spud::Inquiries.enable_action_caching
|
36
|
+
Rails.cache.clear
|
37
|
+
end
|
35
38
|
respond_with @inquiry_form, :location => spud_admin_inquiry_forms_url
|
36
39
|
end
|
37
40
|
|
38
41
|
def destroy
|
39
42
|
flash[:notice] = "Inquiry form removed!" if @inquiry_form.destroy
|
43
|
+
if Spud::Inquiries.enable_action_caching
|
44
|
+
Rails.cache.clear
|
45
|
+
end
|
40
46
|
respond_with @inquiry_form,:location => spud_admin_inquiry_forms_url
|
41
47
|
end
|
42
48
|
private
|
data/app/models/spud_inquiry.rb
CHANGED
@@ -2,12 +2,13 @@
|
|
2
2
|
<%=@inquiry_form.content.html_safe if !@inquiry_form.content.blank?%>
|
3
3
|
|
4
4
|
<%=form_for :spud_inquiry, :url => "/contact/inquire" do |f|%>
|
5
|
+
<%=error_messages_for(@inquiry)%>
|
5
6
|
<fieldset>
|
6
7
|
<%=f.hidden_field :spud_inquiry_form_id,:value => @inquiry_form.id%>
|
7
8
|
<ol>
|
8
9
|
<li>
|
9
10
|
<%=f.label :email%>
|
10
|
-
<%=f.text_field :email%>
|
11
|
+
<%=f.text_field :email,:value => @inquiry.email%>
|
11
12
|
</li>
|
12
13
|
<%@inquiry_form.spud_inquiry_form_fields.each do |field|%>
|
13
14
|
<li>
|
@@ -15,16 +16,20 @@
|
|
15
16
|
|
16
17
|
<%=case field.field_type
|
17
18
|
when '0'
|
18
|
-
f.text_field field.name,:value => field.default_value
|
19
|
+
f.text_field field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name]
|
19
20
|
when '1'
|
20
|
-
f.check_box field.name
|
21
|
+
f.check_box field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name]
|
21
22
|
when '2'
|
22
|
-
f.text_area field.name
|
23
|
+
f.text_area field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name]
|
23
24
|
when '3'
|
24
25
|
f.select field.name,field.options.split(",").collect {|opt| [opt,opt]},:include_blank => true
|
25
26
|
end%>
|
26
27
|
</li>
|
27
28
|
<%end%>
|
29
|
+
<li class="spud_inquiry_hide">
|
30
|
+
<label id='other_email_label' for='other_email'>Please leave blank:</label>
|
31
|
+
<input type='text' name='other_email' id='other_email'>
|
32
|
+
</li>
|
28
33
|
<li style="text-align:center;">
|
29
34
|
<%=f.submit "Submit Inquiry"%>
|
30
35
|
</li>
|
@@ -2,12 +2,13 @@ module Spud
|
|
2
2
|
module Inquiries
|
3
3
|
include ActiveSupport::Configurable
|
4
4
|
|
5
|
-
config_accessor :default_contact_form,:mail_delivery_format,:base_layout,:from_address,:enable_sitemap
|
5
|
+
config_accessor :default_contact_form,:mail_delivery_format,:base_layout,:from_address,:enable_sitemap,:enable_action_caching
|
6
6
|
|
7
7
|
self.default_contact_form = "contact"
|
8
8
|
self.base_layout = "application"
|
9
9
|
self.mail_delivery_format = :html
|
10
10
|
self.from_address = "no-reply@example.org"
|
11
11
|
self.enable_sitemap = true
|
12
|
+
self.enable_action_caching = false
|
12
13
|
end
|
13
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spud_inquiries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spud_core
|
16
|
-
requirement: &
|
16
|
+
requirement: &70192938617000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.5.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70192938617000
|
25
25
|
description:
|
26
26
|
email: destes@redwindsw.com
|
27
27
|
executables: []
|