spree_product_enquiry 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +23 -0
- data/README.md +65 -0
- data/app/controllers/admin/product_enquiries_controller.rb +5 -0
- data/app/controllers/product_enquiries_controller.rb +18 -0
- data/app/helpers/admin/product_enquiries_helper.rb +7 -0
- data/app/helpers/products_helper_decorator.rb +7 -0
- data/app/mailer/product_enquiry_mailer.rb +11 -0
- data/app/models/product_enquiry.rb +8 -0
- data/app/views/admin/product_enquiries/index.html.erb +36 -0
- data/app/views/admin/product_enquiries/show.html.erb +41 -0
- data/app/views/admin/shared/_product_enquiry_tabs.html.erb +12 -0
- data/app/views/product_enquiry_mailer/message_email.text.erb +11 -0
- data/app/views/shared/_product_enquiry_form.html.erb +14 -0
- data/config/locales/en.yml +19 -0
- data/config/routes.rb +8 -0
- data/db/migrate/20110203113626_create_product_enquiry_table.rb +17 -0
- data/lib/spree_product_enquiry.rb +17 -0
- data/lib/spree_product_enquiry_hooks.rb +12 -0
- data/lib/tasks/install.rake +25 -0
- data/lib/tasks/spree_product_enquiry.rake +1 -0
- data/public/images/admin/icons/view.png +0 -0
- metadata +80 -0
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Redistribution and use in source and binary forms, with or without modification,
|
2
|
+
are permitted provided that the following conditions are met:
|
3
|
+
|
4
|
+
* Redistributions of source code must retain the above copyright notice,
|
5
|
+
this list of conditions and the following disclaimer.
|
6
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
7
|
+
this list of conditions and the following disclaimer in the documentation
|
8
|
+
and/or other materials provided with the distribution.
|
9
|
+
* Neither the name of the Rails Dog LLC nor the names of its
|
10
|
+
contributors may be used to endorse or promote products derived from this
|
11
|
+
software without specific prior written permission.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
14
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
15
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
16
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
17
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
18
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
19
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
20
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
21
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
22
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
23
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
SpreeProductEnquiry
|
2
|
+
==================
|
3
|
+
|
4
|
+
Basically the easiest way to implement a product enquiry form.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
============
|
8
|
+
|
9
|
+
Put the following line in your gemfile:
|
10
|
+
|
11
|
+
gem 'spree_product_enquiry'
|
12
|
+
|
13
|
+
Install it.
|
14
|
+
|
15
|
+
bundle install
|
16
|
+
|
17
|
+
Add the migrations.
|
18
|
+
|
19
|
+
rake spree_product_enquiry:install
|
20
|
+
|
21
|
+
Run the migration.
|
22
|
+
|
23
|
+
rake db:migrate
|
24
|
+
|
25
|
+
Include the form (most likely in your products/show view).
|
26
|
+
|
27
|
+
<%= product_enquiry_form(@product) %>
|
28
|
+
|
29
|
+
Done SRLY!
|
30
|
+
|
31
|
+
It will save the enquiries in the database so they will also be
|
32
|
+
available in the admin interface (/admin/product_enquires).
|
33
|
+
|
34
|
+
Set properly the mail method in the admin area (/admin/mail_methods)
|
35
|
+
|
36
|
+
## Note on Patches/Pull Requests:
|
37
|
+
|
38
|
+
* Fork the project.
|
39
|
+
* Make your feature addition or bug fix.
|
40
|
+
* Send me a pull request. Bonus points for topic branches.
|
41
|
+
|
42
|
+
## Copyright:
|
43
|
+
|
44
|
+
(The MIT License)
|
45
|
+
|
46
|
+
Copyright 2011 Jose Pablo Barrantes. MIT Licence, so go for it.
|
47
|
+
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
49
|
+
copy of this software and associated documentation files (the
|
50
|
+
'Software'), to deal in the Software without restriction, including
|
51
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
52
|
+
distribute, sublicense, an d/or sell copies of the Software, and to
|
53
|
+
permit persons to whom the Software is furnished to do so, subject to
|
54
|
+
the following conditions:
|
55
|
+
|
56
|
+
The above copyright notice and this permission notice shall be included
|
57
|
+
in all copies or substantial portions of the Software.
|
58
|
+
|
59
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
60
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
61
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
62
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
63
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
64
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
65
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ProductEnquiriesController < Spree::BaseController
|
2
|
+
|
3
|
+
def create
|
4
|
+
@enquiry = ProductEnquiry.new(params[:product_enquiry])
|
5
|
+
|
6
|
+
respond_to do |format|
|
7
|
+
if @enquiry.valid? && @enquiry.save
|
8
|
+
ProductEnquiryMailer.message_email(@enquiry).deliver
|
9
|
+
format.html { redirect_to(:back) }
|
10
|
+
flash[:notice] = t('product_enquiries.message_notice')
|
11
|
+
else
|
12
|
+
format.html { redirect_to(:back) }
|
13
|
+
flash[:error] = t('product_enquiries.message_error')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<h1><%= t("product_enquiries.product_enquiries")%></h1>
|
2
|
+
|
3
|
+
<table class="index">
|
4
|
+
<tr>
|
5
|
+
<%= hook :admin_product_enquiry_index_headers do %>
|
6
|
+
<th><%= t("product_enquiries.name") %></th>
|
7
|
+
<th><%= t("product_enquiries.email") %></th>
|
8
|
+
<th><%= t("product_enquiries.phone") %></th>
|
9
|
+
<th><%= t("product_enquiries.subject") %></th>
|
10
|
+
<th><%= t("product_enquiries.product") %></th>
|
11
|
+
<% end %>
|
12
|
+
<th>
|
13
|
+
<%= hook :admin_product_enquiry_index_header_actions %>
|
14
|
+
</th>
|
15
|
+
</tr>
|
16
|
+
<% @product_enquiries.each do |product_enquiry| %>
|
17
|
+
<tr id="<%= dom_id product_enquiry %>">
|
18
|
+
<%- locals = {:product_enquiry => product_enquiry} %>
|
19
|
+
<%= hook :admin_product_enquiry_index_rows, locals do %>
|
20
|
+
<td><%= product_enquiry.name %></td>
|
21
|
+
<td><%= product_enquiry.email %></td>
|
22
|
+
<td><%= product_enquiry.phone %></td>
|
23
|
+
<td><%= product_enquiry.subject %></td>
|
24
|
+
<td><%= product_enquiry.product.name %></td>
|
25
|
+
<td><%= product_enquiry.created_at %></td>
|
26
|
+
<% end %>
|
27
|
+
<td class="actions">
|
28
|
+
<%= hook :admin_product_enquiry_index_row_actions, locals do %>
|
29
|
+
<%= link_to_view product_enquiry %>
|
30
|
+
|
31
|
+
<%= link_to_delete product_enquiry %>
|
32
|
+
<% end %>
|
33
|
+
</td>
|
34
|
+
</tr>
|
35
|
+
<% end %>
|
36
|
+
</table>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<h1><%= "#{t('product_enquiries.product_enquiries')} #{t('product_enquiries.from')} #{@product_enquiry.name}" %></h1>
|
2
|
+
|
3
|
+
<%= render :partial => 'admin/shared/product_enquiry_tabs', :locals => {:current => "ProductEnquiry Details"} %>
|
4
|
+
|
5
|
+
<%= hook :admin_product_enquiry_show do %>
|
6
|
+
<div class="adr">
|
7
|
+
<h4><%= t("product_enquiries.name") %></h4>
|
8
|
+
<p>
|
9
|
+
<%= @product_enquiry.name %><br />
|
10
|
+
</p>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="adr">
|
14
|
+
<h4><%= t("product_enquiries.email") %></h4>
|
15
|
+
<p>
|
16
|
+
<%= @product_enquiry.email %><br />
|
17
|
+
</p>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<div class="adr">
|
21
|
+
<h4><%= t("product_enquiries.phone") %></h4>
|
22
|
+
<p>
|
23
|
+
<%= @product_enquiry.phone %><br />
|
24
|
+
</p>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div class="adr">
|
28
|
+
<h4><%= t("product_enquiries.subject") %></h4>
|
29
|
+
<p>
|
30
|
+
<%= @product_enquiry.subject %><br />
|
31
|
+
</p>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div class="adr">
|
35
|
+
<h4><%= t("product_enquiries.message") %></h4>
|
36
|
+
<p>
|
37
|
+
<%= @product_enquiry.message %>
|
38
|
+
</p>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<% content_for :sidebar do %>
|
2
|
+
<ul class="sidebar">
|
3
|
+
<%= hook :admin_product_enquiry_tabs do %>
|
4
|
+
<li<%== ' class="active"' if current == 'Product Enquiry List' %>>
|
5
|
+
<%= link_to t("product_enquiries.product_enquiry_list"), collection_url() %>
|
6
|
+
</li>
|
7
|
+
<li<%== ' class="active"' if current == 'Product Enquiry Details' %>>
|
8
|
+
<%= link_to t("product_enquiries.product_enquiry_details"), object_url(@product_enquiry) %>
|
9
|
+
</li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= t('product_enquiries.greeting') %>
|
2
|
+
|
3
|
+
<%= t('product_enquiries.name') %>: <%= @message.name %>
|
4
|
+
<%= t('product_enquiries.email') %>: <%= @message.email %>
|
5
|
+
<%= t('product_enquiries.phone') %>: <%= @message.phone %>
|
6
|
+
<%= t('product_enquiries.subject') %>: <%= @message.subject %>
|
7
|
+
|
8
|
+
<%= @message.message %>
|
9
|
+
|
10
|
+
<%= t('product_enquiries.footer') %>
|
11
|
+
<%= Spree::Config[:site_name] %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= form_for(ProductEnquiry.new) do |f| %>
|
2
|
+
<%= f.hidden_field :product_id, { :value => product.id } %>
|
3
|
+
<%= f.label :name, t("product_enquiries.name")+"*" %>
|
4
|
+
<%= f.text_field :name %>
|
5
|
+
<%= f.label :email, t("product_enquiries.email")+"*" %>
|
6
|
+
<%= f.text_field :email %>
|
7
|
+
<%= f.label :phone, t("product_enquiries.phone") %>
|
8
|
+
<%= f.text_field :phone %>
|
9
|
+
<%= f.label :subject, t("product_enquiries.subject") %>
|
10
|
+
<%= f.text_field :subject %>
|
11
|
+
<%= f.label :message, t("product_enquiries.message") %>
|
12
|
+
<%= f.text_area :message %>
|
13
|
+
<%= f.submit t("product_enquiries.send_message"), :class => "button primary" %>
|
14
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
en:
|
2
|
+
product_enquiries:
|
3
|
+
product_enquiries: Products Enquiries
|
4
|
+
product_enquiry: Product Enquiry
|
5
|
+
name: Name
|
6
|
+
email: Email
|
7
|
+
sent: Sent
|
8
|
+
view: View
|
9
|
+
message: Message
|
10
|
+
optionnal: optional
|
11
|
+
phone: Phone
|
12
|
+
subject: Message from
|
13
|
+
product_enquiry_details: Product Enquiry details
|
14
|
+
product_enquiry_list: Product Enquiry list
|
15
|
+
send_message: Send message
|
16
|
+
message_notice: Thank You - Your email has been sent!
|
17
|
+
message_error: There was an error. Please try again.
|
18
|
+
greeting: Thank you for your enquiry. Our staff will get back to you shortly. Please see your submission below.
|
19
|
+
footer: Regards,
|
data/config/routes.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateProductEnquiryTable < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :product_enquiries do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :email
|
6
|
+
t.string :subject
|
7
|
+
t.string :phone
|
8
|
+
t.text :message
|
9
|
+
t.references :product
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
drop_table :product_enquiries
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spree_core'
|
2
|
+
require 'spree_product_enquiry_hooks'
|
3
|
+
|
4
|
+
module SpreeProductEnquiry
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
|
7
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
8
|
+
|
9
|
+
def self.activate
|
10
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
|
11
|
+
Rails.env.production? ? require(c) : load(c)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
config.to_prepare &method(:activate).to_proc
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class SpreeProductEnquiryHooks < Spree::ThemeSupport::HookListener
|
2
|
+
|
3
|
+
# Don't know why this does not work. It results on the following:
|
4
|
+
# undefined method `gsub' for #<Hash:0x00000005e272a0>
|
5
|
+
# Extracted source (around line #1):
|
6
|
+
# 1: <%= tab(:product_enquiries) %>
|
7
|
+
|
8
|
+
# insert_after :admin_tabs do
|
9
|
+
# %(<%= tab(:product_enquiries) %>)
|
10
|
+
# end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :spree_product_enquiry do
|
2
|
+
desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
|
3
|
+
task :install do
|
4
|
+
Rake::Task['spree_product_enquiry:install:migrations'].invoke
|
5
|
+
Rake::Task['spree_product_enquiry:install:assets'].invoke
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :install do
|
9
|
+
desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
|
10
|
+
task :migrations do
|
11
|
+
source = File.join(File.dirname(__FILE__), '..', '..', 'db')
|
12
|
+
destination = File.join(Rails.root, 'db')
|
13
|
+
Spree::FileUtilz.mirror_files(source, destination)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
|
17
|
+
task :assets do
|
18
|
+
source = File.join(File.dirname(__FILE__), '..', '..', 'public')
|
19
|
+
destination = File.join(Rails.root, 'public')
|
20
|
+
puts "INFO: Mirroring assets from #{source} to #{destination}"
|
21
|
+
Spree::FileUtilz.mirror_files(source, destination)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# add custom rake tasks here
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_product_enquiry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jose Pablo Barrantes
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-06 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: spree_core
|
16
|
+
requirement: &13234380 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.60'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *13234380
|
25
|
+
description: ! ' Basically the easiest way to implement a product enquiry form.
|
26
|
+
|
27
|
+
'
|
28
|
+
email: xjpablobrx@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.md
|
33
|
+
files:
|
34
|
+
- README.md
|
35
|
+
- LICENSE
|
36
|
+
- lib/spree_product_enquiry_hooks.rb
|
37
|
+
- lib/tasks/spree_product_enquiry.rake
|
38
|
+
- lib/tasks/install.rake
|
39
|
+
- lib/spree_product_enquiry.rb
|
40
|
+
- app/views/admin/product_enquiries/show.html.erb
|
41
|
+
- app/views/admin/product_enquiries/index.html.erb
|
42
|
+
- app/views/admin/shared/_product_enquiry_tabs.html.erb
|
43
|
+
- app/views/product_enquiry_mailer/message_email.text.erb
|
44
|
+
- app/views/shared/_product_enquiry_form.html.erb
|
45
|
+
- app/controllers/admin/product_enquiries_controller.rb
|
46
|
+
- app/controllers/product_enquiries_controller.rb
|
47
|
+
- app/models/product_enquiry.rb
|
48
|
+
- app/mailer/product_enquiry_mailer.rb
|
49
|
+
- app/helpers/products_helper_decorator.rb
|
50
|
+
- app/helpers/admin/product_enquiries_helper.rb
|
51
|
+
- public/images/admin/icons/view.png
|
52
|
+
- db/migrate/20110203113626_create_product_enquiry_table.rb
|
53
|
+
- config/routes.rb
|
54
|
+
- config/locales/en.yml
|
55
|
+
homepage: https://github.com/jpablobr/spree_product_enquiry
|
56
|
+
licenses: []
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.8.7
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.8.10
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Basically the easiest way to implement a product enquiry form.
|
79
|
+
test_files: []
|
80
|
+
has_rdoc: true
|