spud_inquiries 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +16 -5
- data/app/controllers/contacts_controller.rb +23 -17
- data/app/controllers/spud/admin/inquiries_controller.rb +2 -1
- data/app/controllers/spud/admin/inquiry_forms_controller.rb +3 -5
- data/app/controllers/spud/inquiries/sitemaps_controller.rb +3 -2
- data/app/mailers/spud/inquiry_mailer.rb +3 -2
- data/app/models/spud_inquiry.rb +2 -1
- data/app/models/spud_inquiry_field.rb +1 -0
- data/app/models/spud_inquiry_form.rb +8 -6
- data/app/models/spud_inquiry_form_field.rb +2 -5
- data/app/views/contacts/_show.html.erb +7 -5
- data/app/views/contacts/_show_liquid.html.erb +34 -0
- data/app/views/contacts/show.html.erb +4 -4
- data/app/views/contacts/show.js.erb +1 -0
- data/app/views/contacts/thankyou.js.erb +1 -0
- data/app/views/spud/admin/inquiry_forms/_form.html.erb +15 -9
- data/app/views/spud/admin/inquiry_forms/_spud_inquiry_form_field_fields.html.erb +8 -2
- data/app/views/spud/admin/inquiry_forms/index.html.erb +1 -1
- data/app/views/spud/admin/inquiry_forms/new.html.erb +1 -1
- data/app/views/spud/inquiries/sitemaps/show.xml.builder +1 -1
- data/config/routes.rb +15 -21
- data/db/migrate/20120117133412_create_spud_inquiry_fields.rb +1 -1
- data/db/migrate/20120122173829_add_field_order_to_spud_inquiry_form_fields.rb +1 -1
- data/db/migrate/20120126132407_add_spud_inquiry_form_id_to_spud_inquiries.rb +2 -2
- data/db/migrate/20120127023335_add_url_name_to_spud_inquiry_forms.rb +1 -1
- data/db/migrate/20121228145215_add_thank_you_content_to_spud_inquiry_form.rb +5 -0
- data/db/migrate/20130627121030_add_placeholder_to_spud_inquiry_form_fields.rb +5 -0
- data/lib/spud_inquiries/configuration.rb +2 -1
- data/lib/spud_inquiries/engine.rb +4 -0
- data/lib/spud_inquiries/liquid_form.rb +2 -1
- data/lib/spud_inquiries/version.rb +1 -1
- data/spec/controllers/contacts_controller_spec.rb +69 -0
- data/spec/controllers/spud/admin/inquiries_controller_spec.rb +55 -0
- data/spec/controllers/spud/admin/inquiry_forms_controller_spec.rb +97 -0
- data/spec/controllers/spud/inquiries/sitemaps_controller_spec.rb +23 -0
- data/spec/dummy/config/database.yml +0 -28
- data/spec/dummy/db/schema.rb +10 -8
- data/spec/dummy/log/development.log +87 -72
- data/spec/dummy/log/test.log +1244 -0
- data/spec/models/spud_inquiry_field_spec.rb +18 -0
- data/spec/models/spud_inquiry_form_field_spec.rb +36 -0
- data/spec/models/spud_inquiry_form_spec.rb +28 -0
- data/spec/models/spud_inquiry_spec.rb +22 -0
- data/spec/spec_helper.rb +9 -0
- metadata +28 -5
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Spud Inquiries
|
2
2
|
==============
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/spud-rails/spud_inquiries.png?branch=master)](https://travis-ci.org/spud-rails/spud_inquiries)
|
4
4
|
Spud Inquiries is a Spud Engine designed to make it easier to generate contact forms and send email notifications when these inquiries occur. This engine works great with the spud_cms engine but it is fully capable of running standalone with spud_core.
|
5
5
|
|
6
6
|
Installation/Usage
|
@@ -19,12 +19,17 @@ Installation/Usage
|
|
19
19
|
|
20
20
|
4. run a rails server instance and point your browser to /spud/admin
|
21
21
|
|
22
|
+
Creating a Contact Form
|
23
|
+
-----------------------
|
24
|
+
Creating a contact form is still fairly new and improvements will be made as time goes on. To create a new form, go to the Inquiries app inside of your spud admin panel. Click the forms button to manage various forms. Here you can set the form name, any content (html safe) you wish to render before the form renders, and add the form fields to the form (Email address is currently at the top of all forms and not adjustable).
|
25
|
+
|
22
26
|
Routing to the Inquiries Engine
|
23
27
|
-------------------------------
|
24
28
|
By default the inquiries gem routes the "/contact" url to the form named "contact". However this and other configuration options can be changed as shown below.
|
25
29
|
|
26
30
|
|
27
31
|
Spud::Inquiries.configure do |config|
|
32
|
+
config.enable_routes = true
|
28
33
|
config.default_contact_form = "contact"
|
29
34
|
config.base_layout = "application"
|
30
35
|
config.from_address = "no-reply@example.org"
|
@@ -36,9 +41,15 @@ Where "contact" is the name of the form you wish to use (downcased,parameterized
|
|
36
41
|
|
37
42
|
Inquiry will default render to the 'application' layout of your application. You can change this by adjusting the configuration option called "base_layout". More configuration options can be found in the Wiki "Configuration" page.
|
38
43
|
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
Injecting Forms into Spud CMS Pages
|
45
|
+
-----------------------------------
|
46
|
+
Spud Supports the use of liquid tags to inject dynamic content into pages. In order to inject a contact form into a spud page simply use the following liquid tag in your content:
|
47
|
+
|
48
|
+
```html
|
49
|
+
{% inquiry Contact %}
|
50
|
+
```
|
51
|
+
The above example will inject a form named "Contact" into your content.
|
52
|
+
|
42
53
|
|
43
54
|
Testing
|
44
55
|
-----------------
|
@@ -46,7 +57,7 @@ Testing
|
|
46
57
|
Spud uses RSpec for testing. Get the tests running with a few short commands:
|
47
58
|
|
48
59
|
1. Create and migrate the databases:
|
49
|
-
|
60
|
+
|
50
61
|
rake db:create
|
51
62
|
rake db:migrate
|
52
63
|
|
@@ -3,32 +3,31 @@ class ContactsController < ApplicationController
|
|
3
3
|
caches_action :thankyou,:if => Proc.new { |c| Spud::Inquiries.enable_action_caching }
|
4
4
|
skip_before_filter :verify_authenticity_token
|
5
5
|
layout Spud::Inquiries.base_layout
|
6
|
+
respond_to :html,:js
|
6
7
|
def show
|
7
|
-
url_name
|
8
|
+
url_name = !params[:id].blank? ? params[:id] : Spud::Inquiries.default_contact_form
|
8
9
|
@inquiry_form = SpudInquiryForm.where(:url_name => url_name).includes(:spud_inquiry_form_fields).first
|
9
10
|
|
10
|
-
|
11
11
|
if @inquiry_form.blank?
|
12
12
|
flash[:error] = "Contact Inquiry Form not found!"
|
13
|
-
redirect_to
|
13
|
+
redirect_to "/" and return
|
14
14
|
end
|
15
15
|
@inquiry = SpudInquiry.new(:spud_inquiry_form_id => @inquiry_form.id)
|
16
|
-
|
17
16
|
end
|
18
17
|
|
19
18
|
def inquire
|
20
19
|
if !params[:other_email].blank?
|
21
20
|
flash[:error] = "You must be a robot! No robots allowed here!"
|
22
|
-
redirect_to request.referer and return
|
21
|
+
redirect_to request.referer || "/" and return
|
23
22
|
end
|
24
23
|
unless params[:spud_inquiry]
|
25
24
|
flash[:error] = "Inquiry Not Found!"
|
26
|
-
redirect_to request.referer and return
|
25
|
+
redirect_to request.referer || "/" and return
|
27
26
|
end
|
28
|
-
@inquiry_form = SpudInquiryForm.
|
27
|
+
@inquiry_form = SpudInquiryForm.where(:id => params[:spud_inquiry][:spud_inquiry_form_id]).first
|
29
28
|
if @inquiry_form.blank?
|
30
29
|
flash[:error] = "Form Not Found!"
|
31
|
-
redirect_to request.referer and return
|
30
|
+
redirect_to request.referer || "/" and return
|
32
31
|
end
|
33
32
|
@inquiry = SpudInquiry.new(:spud_inquiry_form_id => params[:spud_inquiry][:spud_inquiry_form_id])
|
34
33
|
|
@@ -40,17 +39,16 @@ class ContactsController < ApplicationController
|
|
40
39
|
if field.required && val.blank?
|
41
40
|
flash[:error] = "Not all required fields were entered"
|
42
41
|
@inquiry.errors.add field.name,"is a required field"
|
43
|
-
# redirect_to request.referer and return
|
44
42
|
end
|
45
43
|
@inquiry.spud_inquiry_fields.new(:name => field.name,:value => val)
|
46
44
|
end
|
47
|
-
|
48
|
-
# if key.to_s != "email" && key.to_s != "spud_inquiry_form_id"
|
49
|
-
# @inquiry.spud_inquiry_fields.new(:name => key,:value => value)
|
50
|
-
# end
|
51
|
-
# end
|
45
|
+
|
52
46
|
if !@inquiry.errors.empty?
|
53
|
-
|
47
|
+
respond_to do |format|
|
48
|
+
format.html {render :action => "show"}
|
49
|
+
format.js { render "show.js.erb"}
|
50
|
+
end
|
51
|
+
return
|
54
52
|
end
|
55
53
|
if @inquiry.save
|
56
54
|
flash[:notice] = "Your inquiry was received!"
|
@@ -59,9 +57,17 @@ class ContactsController < ApplicationController
|
|
59
57
|
end
|
60
58
|
else
|
61
59
|
flash[:error] = "Whoops! Something went wrong. Please try again!"
|
62
|
-
|
60
|
+
respond_to do |format|
|
61
|
+
format.html {render :action => "show"}
|
62
|
+
format.js { render "show.js.erb"}
|
63
|
+
end
|
64
|
+
return
|
65
|
+
end
|
66
|
+
respond_to do |format|
|
67
|
+
format.html { redirect_to contact_thankyou_url }
|
68
|
+
format.js { render "thankyou.js.erb"}
|
63
69
|
end
|
64
|
-
|
70
|
+
|
65
71
|
end
|
66
72
|
|
67
73
|
|
@@ -3,13 +3,14 @@ class Spud::Admin::InquiriesController < Spud::Admin::ApplicationController
|
|
3
3
|
belongs_to_spud_app :inquiries
|
4
4
|
add_breadcrumb "Inquiries", :spud_admin_inquiries_path
|
5
5
|
before_filter :load_inquiries,:only => [:edit,:update,:show,:destroy]
|
6
|
+
|
6
7
|
def index
|
7
8
|
@inquiries = SpudInquiry.order("created_at DESC").includes(:spud_inquiry_form).paginate :page => params[:page]
|
8
9
|
respond_with @inquiries
|
9
10
|
end
|
10
11
|
|
11
12
|
def show
|
12
|
-
add_breadcrumb "#{@inquiry.email || "Unknown"}",
|
13
|
+
add_breadcrumb "#{@inquiry.email || "Unknown"}", ''
|
13
14
|
respond_with @inquiry
|
14
15
|
end
|
15
16
|
|
@@ -1,19 +1,19 @@
|
|
1
1
|
class Spud::Admin::InquiryFormsController < Spud::Admin::ApplicationController
|
2
2
|
layout 'spud/admin/detail'
|
3
|
-
belongs_to_spud_app :inquiries
|
3
|
+
belongs_to_spud_app :inquiries, :title => "Inquiry Forms"
|
4
4
|
cache_sweeper :inquiry_sweeper, :only => [:update,:destroy,:create]
|
5
5
|
add_breadcrumb "Inquiries", :spud_admin_inquiries_path
|
6
6
|
add_breadcrumb "Forms", :spud_admin_inquiry_forms_path
|
7
|
+
add_breadcrumb "New", '',:only => [:new, :create]
|
8
|
+
add_breadcrumb "Edit", '',:only => [:edit, :update]
|
7
9
|
before_filter :load_form,:only => [:edit,:update,:show,:destroy]
|
8
10
|
def index
|
9
11
|
|
10
|
-
@page_name = "Inquiry Forms"
|
11
12
|
@inquiry_forms = SpudInquiryForm.order(:name).paginate :page => params[:page]
|
12
13
|
respond_with @inquiry_forms
|
13
14
|
end
|
14
15
|
|
15
16
|
def new
|
16
|
-
@page_name = "New Inquiry Form"
|
17
17
|
@inquiry_form = SpudInquiryForm.new
|
18
18
|
respond_with @inquiry_form
|
19
19
|
end
|
@@ -26,12 +26,10 @@ class Spud::Admin::InquiryFormsController < Spud::Admin::ApplicationController
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def edit
|
29
|
-
@page_name = "Edit Inquiry Form"
|
30
29
|
respond_with @inquiry_form
|
31
30
|
end
|
32
31
|
|
33
32
|
def update
|
34
|
-
@page_name = "Edit Inquiry Form"
|
35
33
|
flash[:notice] = "Form saved successfully!" if @inquiry_form.update_attributes(params[:spud_inquiry_form])
|
36
34
|
if Spud::Inquiries.enable_action_caching
|
37
35
|
Rails.cache.clear
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class Spud::InquiryMailer < ActionMailer::Base
|
2
|
-
|
2
|
+
|
3
3
|
|
4
4
|
def inquiry_notification(inquiry)
|
5
5
|
@inquiry = inquiry
|
6
|
-
|
6
|
+
@url = spud_admin_inquiry_url(:id => @inquiry.id)
|
7
|
+
# @url = "/spud/admin/inquiries/#{@inquiry.id}"
|
7
8
|
mail(:from =>Spud::Inquiries.from_address,:to => @inquiry.recipients.split(","), :subject => @inquiry.subject.blank? ? "No Subject" : @inquiry.subject)
|
8
9
|
end
|
9
10
|
end
|
data/app/models/spud_inquiry.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
class SpudInquiry < ActiveRecord::Base
|
2
2
|
|
3
|
-
has_many :spud_inquiry_fields
|
3
|
+
has_many :spud_inquiry_fields, :dependent => :destroy
|
4
4
|
belongs_to :spud_inquiry_form
|
5
5
|
accepts_nested_attributes_for :spud_inquiry_fields, :reject_if => lambda { |a| a[:name].blank? }
|
6
6
|
attr_accessible :spud_inquiry_form_id,:spud_inquiry_fields
|
7
7
|
|
8
|
+
|
8
9
|
def email
|
9
10
|
email_field = self.spud_inquiry_fields.where(:name => "email").first
|
10
11
|
if !email_field.blank?
|
@@ -1,15 +1,17 @@
|
|
1
1
|
class SpudInquiryForm < ActiveRecord::Base
|
2
|
-
has_many :spud_inquiries
|
2
|
+
has_many :spud_inquiries, :dependent => :nullify
|
3
3
|
has_many :spud_inquiry_form_fields,:dependent => :destroy,:order => "field_order ASC"
|
4
4
|
|
5
|
-
|
5
|
+
accepts_nested_attributes_for :spud_inquiry_form_fields, :reject_if => lambda { |a| a[:name].blank? }, :allow_destroy => true
|
6
6
|
|
7
7
|
validates :name,:presence => true,:uniqueness => true
|
8
8
|
validates :url_name,:presence => true, :uniqueness => true
|
9
9
|
before_validation :generate_url_name
|
10
|
-
attr_accessible :name,:url_name,:recipients,:content,:subject,:spud_inquiry_form_fields_attributes
|
10
|
+
attr_accessible :name,:url_name,:recipients,:content,:subject,:spud_inquiry_form_fields_attributes, :created_at, :updated_at, :thank_you_content
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def generate_url_name
|
13
|
+
if !self.name.blank?
|
14
|
+
self.url_name = self.name.gsub(/[^a-zA-Z0-9\ ]/," ").gsub(/\ \ +/," ").gsub(/\ /,"-").downcase
|
15
|
+
end
|
16
|
+
end
|
15
17
|
end
|
@@ -2,15 +2,12 @@ class SpudInquiryFormField < ActiveRecord::Base
|
|
2
2
|
belongs_to :spud_inquiry_form
|
3
3
|
validates :name,:presence => true
|
4
4
|
validates :field_type,:presence => true
|
5
|
-
|
6
|
-
|
5
|
+
# validates :spud_inquiry_form_id, :presence => true
|
6
|
+
attr_accessible :name,:options,:default_value,:field_type,:spud_inquiry_form_id,:field_order,:required, :placeholder
|
7
7
|
|
8
8
|
def options_list
|
9
9
|
return [] if self.options.blank?
|
10
10
|
self.options.split(/\,*?(".*?")\,*?/).map{|x| x=~/^".*"$/ ? x.gsub(/\"/,"") : x.split(',')}.flatten.select{|p| !p.strip.blank?}
|
11
|
-
|
12
11
|
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
13
|
end
|
@@ -1,19 +1,21 @@
|
|
1
1
|
|
2
|
-
<%=form_for :spud_inquiry, :url =>
|
2
|
+
<%=form_for :spud_inquiry, :url => contact_inquire_path,:html => {:class => "form-horizontal", :id => "inquiry_form_#{inquiry_form.id}"}, :remote => true do |f|%>
|
3
|
+
<%#=error_messages_for(@inquiry)%>
|
4
|
+
|
3
5
|
<fieldset>
|
4
6
|
<%=f.hidden_field :spud_inquiry_form_id,:value => inquiry_form.id%>
|
5
7
|
|
6
8
|
<%inquiry_form.spud_inquiry_form_fields.each do |field|%>
|
7
|
-
<div class="control-group">
|
9
|
+
<div class="control-group type_<%=field.field_type%>">
|
8
10
|
<%=f.label field.name,:class => "control-label"%>
|
9
11
|
<div class="controls">
|
10
12
|
<%=case field.field_type
|
11
13
|
when '0'
|
12
|
-
f.text_field field.name,:value => field.default_value
|
14
|
+
f.text_field field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name], :placeholder => field.placeholder
|
13
15
|
when '1'
|
14
|
-
f.check_box field.name,:value => field.default_value
|
16
|
+
f.check_box field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name]
|
15
17
|
when '2'
|
16
|
-
f.text_area field.name,:value => field.default_value,:rows=>5,:cols => 70
|
18
|
+
f.text_area field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name],:rows=>5,:cols => 70, :placeholder => field.placeholder
|
17
19
|
when '3'
|
18
20
|
f.select field.name,field.options_list.collect {|opt| [opt,opt]},:include_blank => true
|
19
21
|
end%>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
<%=form_for :spud_inquiry, :url => "/contact/inquire",:html => {:class => "form-horizontal", :id => "inquiry_form_#{inquiry_form.id}"}, :remote => true do |f|%>
|
3
|
+
<fieldset>
|
4
|
+
<%=f.hidden_field :spud_inquiry_form_id,:value => inquiry_form.id%>
|
5
|
+
|
6
|
+
<%inquiry_form.spud_inquiry_form_fields.each do |field|%>
|
7
|
+
<div class="control-group type_<%=field.field_type%>">
|
8
|
+
<%=f.label field.name,:class => "control-label"%>
|
9
|
+
<div class="controls">
|
10
|
+
<%=case field.field_type
|
11
|
+
when '0'
|
12
|
+
f.text_field field.name,:value => field.default_value, :placeholder => field.placeholder
|
13
|
+
when '1'
|
14
|
+
f.check_box field.name,:value => field.default_value
|
15
|
+
when '2'
|
16
|
+
f.text_area field.name,:value => field.default_value,:rows=>5,:cols => 70, :placeholder => field.placeholder
|
17
|
+
when '3'
|
18
|
+
f.select field.name,field.options_list.collect {|opt| [opt,opt]},:include_blank => true
|
19
|
+
end%>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<%end%>
|
23
|
+
<div class="spud_inquiry_hide">
|
24
|
+
<label id='other_email_label' for='other_email'>Please leave blank:</label>
|
25
|
+
<input type='text' name='other_email' id='other_email'>
|
26
|
+
</div>
|
27
|
+
<div class="form-actions">
|
28
|
+
<%=f.submit "Submit Inquiry",:class => "btn btn-primary"%>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
|
32
|
+
</fieldset>
|
33
|
+
|
34
|
+
<%end%>
|
@@ -1,23 +1,23 @@
|
|
1
1
|
<h2><%=@inquiry_form.name%></h2>
|
2
2
|
<%=@inquiry_form.content.html_safe if !@inquiry_form.content.blank?%>
|
3
3
|
|
4
|
-
<%=form_for :spud_inquiry, :url =>
|
4
|
+
<%=form_for :spud_inquiry, :url => contact_inquire_url,:html => {:class => "form-horizontal"} do |f|%>
|
5
5
|
<%=error_messages_for(@inquiry)%>
|
6
6
|
<fieldset>
|
7
7
|
<%=f.hidden_field :spud_inquiry_form_id,:value => @inquiry_form.id%>
|
8
8
|
|
9
9
|
|
10
10
|
<%@inquiry_form.spud_inquiry_form_fields.each do |field|%>
|
11
|
-
<div class="control-group">
|
11
|
+
<div class="control-group type_<%=field.field_type%>">
|
12
12
|
<%=f.label field.name,:class => "control-label"%>
|
13
13
|
<div class="controls">
|
14
14
|
<%=case field.field_type
|
15
15
|
when '0'
|
16
|
-
f.text_field field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name]
|
16
|
+
f.text_field field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name], , :placeholder => field.placeholder
|
17
17
|
when '1'
|
18
18
|
f.check_box field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name]
|
19
19
|
when '2'
|
20
|
-
f.text_area field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name],:rows=>5,:cols => 70
|
20
|
+
f.text_area field.name,:value => params[:spud_inquiry].blank? || params[:spud_inquiry][field.name].blank? ? field.default_value : params[:spud_inquiry][field.name],:rows=>5,:cols => 70, :placeholder => field.placeholder
|
21
21
|
when '3'
|
22
22
|
f.select field.name,field.options_list.collect {|opt| [opt,opt]},:include_blank => true
|
23
23
|
end%>
|
@@ -0,0 +1 @@
|
|
1
|
+
$('#inquiry_form_<%=@inquiry_form.id%>').replaceWith("<%=escape_javascript(render :partial=>"show",:locals => {:inquiry_form => @inquiry_form})%>");
|
@@ -0,0 +1 @@
|
|
1
|
+
$('#inquiry_form_<%=@inquiry_form.id%>').replaceWith("<%=escape_javascript(@inquiry_form.thank_you_content ? @inquiry_form.thank_you_content.html_safe : 'Thank You')%>");
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<%=error_messages_for(f.object)%>
|
2
2
|
<fieldset>
|
3
3
|
<legend>Form Info</legend>
|
4
|
-
|
4
|
+
|
5
5
|
<div class="control-group">
|
6
|
-
|
6
|
+
|
7
7
|
<%=f.label :name, :required=>true, :class=>"control-label"%>
|
8
8
|
<div class="controls">
|
9
9
|
<%=f.text_field :name%>
|
@@ -17,17 +17,23 @@
|
|
17
17
|
</div>
|
18
18
|
<div class="control-group">
|
19
19
|
<%=f.label :subject, :required=>true, :class=>"control-label"%>
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
<div class="controls">
|
21
|
+
<%=f.text_field :subject%>
|
22
|
+
</div>
|
23
23
|
</div>
|
24
24
|
<div class="control-group">
|
25
25
|
<%=f.label :content, :required=>true, :class=>"control-label"%>
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
<div class="controls">
|
27
|
+
<%=f.text_area :content,:cols => 75,:rows => 5,:class => "wysiwym tinymce"%>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
<div class="control-group">
|
31
|
+
<%=f.label :thank_you_content,"Thank You Text", :required=>true, :class=>"control-label"%>
|
32
|
+
<div class="controls">
|
33
|
+
<%=f.text_area :thank_you_content,:cols => 75,:rows => 5,:class => "wysiwym tinymce"%>
|
34
|
+
</div>
|
29
35
|
</div>
|
30
|
-
|
36
|
+
|
31
37
|
</fieldset>
|
32
38
|
<fieldset>
|
33
39
|
<legend>Fields</legend>
|
@@ -12,7 +12,13 @@
|
|
12
12
|
<%=f.select :field_type, [["Text Field",0],["Checkbox",1],["Text Area",2],["Dropdown",3]]%>
|
13
13
|
</div>
|
14
14
|
|
15
|
-
|
15
|
+
|
16
|
+
</div>
|
17
|
+
<div class="control-group">
|
18
|
+
<%=f.label :placeholder,:class => "control-label"%>
|
19
|
+
<div class="controls">
|
20
|
+
<%=f.text_field :placeholder%>
|
21
|
+
</div>
|
16
22
|
</div>
|
17
23
|
<div class="control-group">
|
18
24
|
<%=f.label :options,:class => "control-label"%>
|
@@ -20,7 +26,7 @@
|
|
20
26
|
<%=f.text_field :options%>
|
21
27
|
</div>
|
22
28
|
</div>
|
23
|
-
<div class="control-group">
|
29
|
+
<div class="control-group">
|
24
30
|
<%=f.label :default_value,:class => "control-label"%>
|
25
31
|
<div class="controls">
|
26
32
|
<%=f.text_field :default_value%>
|
data/config/routes.rb
CHANGED
@@ -1,23 +1,17 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
2
|
+
namespace :spud do
|
3
|
+
namespace :admin do
|
4
|
+
resources :inquiries
|
5
|
+
resources :inquiry_forms
|
6
|
+
end
|
7
|
+
namespace :inquiries do
|
8
|
+
resource :sitemap,:only => [:show]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
post "/contact/inquire" => "contacts#inquire"
|
12
|
+
match "/contact/thankyou" => "contacts#thankyou"
|
13
|
+
if Spud::Inquiries.enable_routes
|
14
|
+
match "/contact" => "contacts#show", :as => :contact
|
15
|
+
match "/contact/:id" => "contacts#show", :as => :contact
|
16
|
+
end
|
22
17
|
end
|
23
|
-
|
@@ -2,6 +2,6 @@ class AddFieldOrderToSpudInquiryFormFields < ActiveRecord::Migration
|
|
2
2
|
def change
|
3
3
|
add_column :spud_inquiry_form_fields, :field_order, :integer
|
4
4
|
add_column :spud_inquiry_form_fields, :required, :boolean
|
5
|
-
add_index :spud_inquiry_form_fields,:field_order
|
5
|
+
add_index :spud_inquiry_form_fields,:field_order, :name => "form_field_order"
|
6
6
|
end
|
7
7
|
end
|
@@ -5,7 +5,7 @@ class AddSpudInquiryFormIdToSpudInquiries < ActiveRecord::Migration
|
|
5
5
|
add_column :spud_inquiries, :subject,:string
|
6
6
|
add_column :spud_inquiries, :marked_as_read,:boolean,:default => false
|
7
7
|
|
8
|
-
add_index :spud_inquiries, :marked_as_read
|
9
|
-
add_index :spud_inquiries, :spud_inquiry_form_id
|
8
|
+
add_index :spud_inquiries, :marked_as_read, :name => "idx_inquiry_read"
|
9
|
+
add_index :spud_inquiries, :spud_inquiry_form_id, :name => "idx_inquiry_form"
|
10
10
|
end
|
11
11
|
end
|
@@ -2,9 +2,10 @@ module Spud
|
|
2
2
|
module Inquiries
|
3
3
|
include ActiveSupport::Configurable
|
4
4
|
|
5
|
-
config_accessor :default_contact_form,:enable_routes,:mail_delivery_format,:base_layout,:from_address,:enable_sitemap,:enable_action_caching
|
5
|
+
config_accessor :default_contact_form,:enable_routes,:mail_delivery_format,:base_layout,:from_address,:enable_sitemap,:enable_action_caching, :automount
|
6
6
|
|
7
7
|
self.enable_routes = true
|
8
|
+
self.automount = true
|
8
9
|
self.default_contact_form = "contact"
|
9
10
|
self.base_layout = "application"
|
10
11
|
self.mail_delivery_format = :html
|
@@ -15,6 +15,10 @@ module Spud
|
|
15
15
|
end
|
16
16
|
|
17
17
|
initializer :liquid_form do
|
18
|
+
Spud::Inquiries::FormActionView.class_eval do
|
19
|
+
include Spud::Inquiries::Engine.routes.url_helpers
|
20
|
+
include Spud::Inquiries::Engine.routes.mounted_helpers
|
21
|
+
end
|
18
22
|
Liquid::Template.register_tag('inquiry', Spud::Inquiries::InquiryForm) if defined?(Liquid::Template)
|
19
23
|
end
|
20
24
|
end
|
@@ -3,6 +3,7 @@ module Spud
|
|
3
3
|
module Inquiries
|
4
4
|
class FormActionView < ActionView::Base
|
5
5
|
include ActionView::Helpers
|
6
|
+
|
6
7
|
def protect_against_forgery?
|
7
8
|
return false
|
8
9
|
end
|
@@ -29,7 +30,7 @@ module Spud
|
|
29
30
|
if !@inquiry_form.blank?
|
30
31
|
@inquiry = SpudInquiry.new(:spud_inquiry_form_id => @inquiry_form.id)
|
31
32
|
@view.render(
|
32
|
-
:partial => "/contacts/
|
33
|
+
:partial => "/contacts/show_liquid",
|
33
34
|
:locals => {:inquiry => @inquiry, :inquiry_form => @inquiry_form}
|
34
35
|
)
|
35
36
|
else
|