refinerycms-products 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/admin/product_inquiries_controller.rb +41 -0
- data/app/controllers/product_inquiries_controller.rb +37 -0
- data/app/mailers/product_inquiry_mailer.rb +12 -0
- data/app/models/product_inquiry.rb +26 -0
- data/app/views/admin/product_inquiries/_inquiry.html.erb +24 -0
- data/app/views/admin/product_inquiries/_submenu.html.erb +17 -0
- data/app/views/admin/product_inquiries/index.html.erb +30 -0
- data/app/views/admin/product_inquiries/show.html.erb +82 -0
- data/app/views/product_inquiries/new.html.erb +39 -0
- data/app/views/product_inquiries/thank_you.html.erb +1 -0
- data/app/views/product_inquiry_mailer/notification.html.erb +19 -0
- data/app/views/products/show.html.erb +10 -6
- data/config/initializers/settings.rb +5 -0
- data/config/locales/en.yml +48 -0
- data/config/routes.rb +11 -0
- data/db/migrate/15_create_product_inquiry.rb +27 -0
- data/db/seeds/product_inquiries.rb +42 -0
- data/lib/refinerycms-product_inquiries.rb +30 -0
- data/lib/refinerycms-products.rb +2 -1
- metadata +16 -1
@@ -0,0 +1,41 @@
|
|
1
|
+
class Admin::ProductInquiriesController < Admin::BaseController
|
2
|
+
|
3
|
+
crudify :product_inquiry, :title_attribute => "name", :order => "created_at DESC"
|
4
|
+
helper_method :group_by_date
|
5
|
+
|
6
|
+
before_filter :find_all_ham, :only => [:index]
|
7
|
+
before_filter :find_all_spam, :only => [:spam]
|
8
|
+
before_filter :get_spam_count, :only => [:index, :spam]
|
9
|
+
|
10
|
+
def index
|
11
|
+
@inquiries = @inquiries.with_query(params[:search]) if searching?
|
12
|
+
@inquiries = @inquiries.paginate({:page => params[:page]})
|
13
|
+
end
|
14
|
+
|
15
|
+
def spam
|
16
|
+
self.index
|
17
|
+
render :action => 'index'
|
18
|
+
end
|
19
|
+
|
20
|
+
def toggle_spam
|
21
|
+
find_inquiry
|
22
|
+
@inquiry.toggle!(:spam)
|
23
|
+
|
24
|
+
redirect_to :back
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def find_all_ham
|
30
|
+
@inquiries = ProductInquiry.ham
|
31
|
+
end
|
32
|
+
|
33
|
+
def find_all_spam
|
34
|
+
@inquiries = ProductInquiry.spam
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_spam_count
|
38
|
+
@spam_count = ProductInquiry.count(:conditions => {:spam => true})
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class ProductInquiriesController < ApplicationController
|
2
|
+
|
3
|
+
before_filter :find_page, :only => [:create, :new]
|
4
|
+
|
5
|
+
def thank_you
|
6
|
+
@page = Page.find_by_link_url("/product_inquiry_thank_you", :include => [:parts, :slugs])
|
7
|
+
end
|
8
|
+
|
9
|
+
def new
|
10
|
+
@product_inquiry = ProductInquiry.new(params[:product_inquiry])
|
11
|
+
@product_inquiry.product_id = params[:product_id] if params[:product_id].present?
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
@product_inquiry = ProductInquiry.new(params[:product_inquiry])
|
16
|
+
|
17
|
+
if @product_inquiry.save
|
18
|
+
if @product_inquiry.ham?
|
19
|
+
begin
|
20
|
+
ProductInquiryMailer.notification(@product_inquiry, request).deliver
|
21
|
+
rescue
|
22
|
+
logger.warn "There was an error delivering an inquiry notification.\n#{$!}\n"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
redirect_to product_inquiry_thank_you_path
|
27
|
+
else
|
28
|
+
render :action => 'new'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
protected
|
32
|
+
|
33
|
+
def find_page
|
34
|
+
@page = Page.where(:link_url => "/product_inquiry").first
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ProductInquiryMailer < ActionMailer::Base
|
2
|
+
|
3
|
+
def notification(inquiry, request)
|
4
|
+
subject "New Product Inquiry"
|
5
|
+
recipients RefinerySetting.find_or_set(:product_inquiry_recipients, User.first.email)
|
6
|
+
from "\"#{RefinerySetting[:site_name]}\" <no-reply@#{request.domain(RefinerySetting.find_or_set(:tld_length, 1))}>"
|
7
|
+
reply_to inquiry.email
|
8
|
+
sent_on Time.now
|
9
|
+
@inquiry = inquiry
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class ProductInquiry < ActiveRecord::Base
|
2
|
+
|
3
|
+
filters_spam :message_field => :message,
|
4
|
+
:email_field => :email,
|
5
|
+
:author_field => :name,
|
6
|
+
:other_fields => [:phone],
|
7
|
+
:extra_spam_words => %w()
|
8
|
+
|
9
|
+
belongs_to :product
|
10
|
+
|
11
|
+
validates :product, :presence => true
|
12
|
+
validates :name, :presence => true
|
13
|
+
validates :message, :presence => true
|
14
|
+
validates :email, :format=> { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
|
15
|
+
|
16
|
+
acts_as_indexed :fields => [:name, :email, :message, :phone]
|
17
|
+
|
18
|
+
default_scope :order => 'created_at DESC' # previously scope :newest
|
19
|
+
|
20
|
+
attr_accessible :name, :phone, :message, :email, :product_id
|
21
|
+
|
22
|
+
def self.latest(number = 7, include_spam = false)
|
23
|
+
include_spam ? limit(number) : ham.limit(number)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<li class='clearfix record <%= cycle("on", "on-hover") %>'>
|
2
|
+
<span class='title'>
|
3
|
+
<%= link_to inquiry.name, admin_product_inquiry_url(inquiry) %> <%= t('.said') %>
|
4
|
+
<span class="preview"><%= truncate(strip_tags(inquiry.message), :length => 60) -%></span>
|
5
|
+
</span>
|
6
|
+
<span class='actions'>
|
7
|
+
<%= link_to refinery_icon_tag('delete.png'), admin_product_inquiry_url(inquiry),
|
8
|
+
{ :method => :delete,
|
9
|
+
:confirm => t('shared.admin.delete.message', :title => inquiry.name) },
|
10
|
+
:class => "cancel confirm-delete",
|
11
|
+
:title => t('admin.inquiries.delete') -%>
|
12
|
+
|
13
|
+
<%= link_to refinery_icon_tag('zoom.png'), admin_product_inquiry_url(inquiry),
|
14
|
+
:title => t('.read_inquiry') -%>
|
15
|
+
|
16
|
+
<% if inquiry.spam? %>
|
17
|
+
<%= link_to refinery_icon_tag('email.png'), toggle_spam_admin_product_inquiry_url(inquiry),
|
18
|
+
:title => t('.mark_as_ham') -%>
|
19
|
+
<% else %>
|
20
|
+
<%= link_to refinery_icon_tag('bin_closed.png'), toggle_spam_admin_product_inquiry_url(inquiry),
|
21
|
+
:title => t('.mark_as_spam') -%>
|
22
|
+
<% end %>
|
23
|
+
</span>
|
24
|
+
</li>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div id='actions'>
|
2
|
+
<ul>
|
3
|
+
<li>
|
4
|
+
<%= render :partial => "/shared/admin/search", :locals => {:url => request.path} %>
|
5
|
+
</li>
|
6
|
+
<li <%= "class='selected'" if params[:action] == "index" %>>
|
7
|
+
<%= link_to t('.inbox'), admin_product_inquiries_url, :class => "email_icon" %>
|
8
|
+
</li>
|
9
|
+
<li <%= "class='selected'" if params[:action] == "spam" %>>
|
10
|
+
<% if @spam_count > 0 %>
|
11
|
+
<%= link_to "#{t('.spam')} (#{@spam_count})", spam_admin_product_inquiries_url, :class => "spam_icon" %>
|
12
|
+
<% else %>
|
13
|
+
<%= link_to t('.spam'), spam_admin_product_inquiries_url, :class => "spam_empty_icon" %>
|
14
|
+
<% end %>
|
15
|
+
</li>
|
16
|
+
</ul>
|
17
|
+
</div>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%= render :partial => "submenu" %>
|
2
|
+
<div id='records'>
|
3
|
+
<% if searching? %>
|
4
|
+
<h2><%= t('shared.admin.search.results_for', :query => params[:search]) %></h2>
|
5
|
+
<% if @inquiries.any? %>
|
6
|
+
<%= will_paginate @inquiries %>
|
7
|
+
<ul>
|
8
|
+
<%= render :partial => "inquiry", :collection => @inquiries %>
|
9
|
+
</ul>
|
10
|
+
<%= will_paginate @inquiries %>
|
11
|
+
<% else %>
|
12
|
+
<p><%= t('shared.admin.search.no_results') %></p>
|
13
|
+
<% end %>
|
14
|
+
<% else %>
|
15
|
+
<% if @inquiries.any? -%>
|
16
|
+
<%= will_paginate @inquiries %>
|
17
|
+
<% group_by_date(@inquiries).each do |container| %>
|
18
|
+
<h3><%= l((inquiry_group = container.last).first.created_at, :format => :short) %></h3>
|
19
|
+
<ul>
|
20
|
+
<%= render :partial => 'inquiry', :collection => inquiry_group %>
|
21
|
+
</ul>
|
22
|
+
<% end %>
|
23
|
+
<%= will_paginate @inquiries %>
|
24
|
+
<% else -%>
|
25
|
+
<p>
|
26
|
+
<strong><%= t(".no_#{action_name == 'index' ? 'inquiries' : 'spam'}") %></strong>
|
27
|
+
</p>
|
28
|
+
<% end -%>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
@@ -0,0 +1,82 @@
|
|
1
|
+
<div id='actions'>
|
2
|
+
<h2><%= t('.details')%></h2>
|
3
|
+
<p>
|
4
|
+
<strong><%= t('.age') %>:</strong> <%= time_ago_in_words(@inquiry.created_at) %>
|
5
|
+
</p>
|
6
|
+
<% if @inquiry.spam? %>
|
7
|
+
<p>
|
8
|
+
<strong><%= t('.spam') %>:</strong> <%= t('.spam_yes') %>
|
9
|
+
</p>
|
10
|
+
<% end %>
|
11
|
+
<h2><%= t('.actions') %></h2>
|
12
|
+
<ul>
|
13
|
+
<li>
|
14
|
+
<%= link_to t('.back_to_all_inquiries'), {:action => 'index'}, :class => "back_icon" %>
|
15
|
+
</li>
|
16
|
+
<li>
|
17
|
+
<%= link_to t('admin.inquiries.delete'),
|
18
|
+
admin_product_inquiry_url(@inquiry),
|
19
|
+
:class => 'delete_icon no-tooltip confirm-delete',
|
20
|
+
:title => t('admin.inquiries.delete'),
|
21
|
+
:confirm => t('shared.admin.delete.message', :title => @inquiry.name),
|
22
|
+
:method => :delete %>
|
23
|
+
</li>
|
24
|
+
</ul>
|
25
|
+
</div>
|
26
|
+
<div id='records'>
|
27
|
+
<h2><%= t('.inquiry') %></h2>
|
28
|
+
<table id='inquiry'>
|
29
|
+
<tr>
|
30
|
+
<td>
|
31
|
+
<strong><%= t('.to') %></strong>
|
32
|
+
</td>
|
33
|
+
<td>
|
34
|
+
<%= RefinerySetting[:site_name] %>
|
35
|
+
</td>
|
36
|
+
</tr>
|
37
|
+
<tr>
|
38
|
+
<td>
|
39
|
+
<strong><%= t('.from') %></strong>
|
40
|
+
</td>
|
41
|
+
<td>
|
42
|
+
<%= @inquiry.name %> [<%= mail_to @inquiry.email, @inquiry.email, {:title => t('.click_to_email')} %>]
|
43
|
+
</td>
|
44
|
+
</tr>
|
45
|
+
<% if @inquiry.product.present? %>
|
46
|
+
<tr>
|
47
|
+
<td>
|
48
|
+
<strong>Product</strong>
|
49
|
+
</td>
|
50
|
+
<td>
|
51
|
+
<%= @inquiry.product.name %>
|
52
|
+
</td>
|
53
|
+
</tr>
|
54
|
+
<% end %>
|
55
|
+
<% unless @inquiry.phone.blank? %>
|
56
|
+
<tr>
|
57
|
+
<td>
|
58
|
+
<strong><%= t('.phone') %></strong>
|
59
|
+
</td>
|
60
|
+
<td>
|
61
|
+
<%= @inquiry.phone %>
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
<% end %>
|
65
|
+
<tr>
|
66
|
+
<td>
|
67
|
+
<strong><%= t('.date') %></strong>
|
68
|
+
</td>
|
69
|
+
<td>
|
70
|
+
<%= l(Date.parse(@inquiry.created_at.to_s), :format => :long) %>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
<tr>
|
74
|
+
<td valign='top'>
|
75
|
+
<strong><%= t('.message') %></strong>
|
76
|
+
</td>
|
77
|
+
<td>
|
78
|
+
<%= simple_format @inquiry.message, :style => 'margin-top: 0' %>
|
79
|
+
</td>
|
80
|
+
</tr>
|
81
|
+
</table>
|
82
|
+
</div>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<% content_for :body_content_left do %>
|
2
|
+
<div class="inquiries">
|
3
|
+
<%=raw @page.content_for(Page.default_parts.first.to_sym) %>
|
4
|
+
|
5
|
+
<%= form_for @product_inquiry do |f| %>
|
6
|
+
<%= render :partial => '/shared/admin/error_messages',
|
7
|
+
:locals => {
|
8
|
+
:object => @product_inquiry,
|
9
|
+
:include_object_name => true
|
10
|
+
} %>
|
11
|
+
|
12
|
+
<%= f.hidden_field :product_id %>
|
13
|
+
<div class="field">
|
14
|
+
<label>Product</label>
|
15
|
+
<%= text_field_tag(:product_name, @product_inquiry.product.name, :disabled => 'disabled') if @product_inquiry.product.present? %>
|
16
|
+
</div>
|
17
|
+
<div class="field">
|
18
|
+
<%= f.required_label :name, :class => 'placeholder-fallback' %>
|
19
|
+
<%= f.text_field :name, :class => 'text', :required => 'required', :placeholder => t('name', :scope => 'activerecord.attributes.inquiry') %>
|
20
|
+
</div>
|
21
|
+
<div class="field">
|
22
|
+
<%= f.required_label :email, :class => 'placeholder-fallback' %>
|
23
|
+
<%= f.email_field :email, :class => 'text email', :required => 'required', :placeholder => t('email', :scope => 'activerecord.attributes.inquiry') %>
|
24
|
+
</div>
|
25
|
+
<div class="field">
|
26
|
+
<%= f.label :phone, :class => 'placeholder-fallback' %>
|
27
|
+
<%= f.text_field :phone, :class => 'text phone', :placeholder => t('phone', :scope => 'activerecord.attributes.inquiry') %>
|
28
|
+
</div>
|
29
|
+
<div class='field message_field'>
|
30
|
+
<%= f.required_label :message, :class => 'placeholder-fallback' %>
|
31
|
+
<%= f.text_area :message, :rows => 8, :required => 'required', :placeholder => t('message', :scope => 'activerecord.attributes.inquiry') %>
|
32
|
+
</div>
|
33
|
+
<div class="actions">
|
34
|
+
<%= f.submit t('.send') %>
|
35
|
+
</div>
|
36
|
+
<% end %>
|
37
|
+
</div>
|
38
|
+
<% end %>
|
39
|
+
<%= render :partial => '/shared/content_page' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => "/shared/content_page" %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Hi,
|
2
|
+
|
3
|
+
You have received a new product inquiry:
|
4
|
+
|
5
|
+
--- inquiry starts ---
|
6
|
+
|
7
|
+
Product: <%= @inquiry.product.name if @inquiry.product.present? %>
|
8
|
+
From: <%= @inquiry.name %>
|
9
|
+
Email: <%= @inquiry.email %>
|
10
|
+
Phone: <%= @inquiry.phone %>
|
11
|
+
Message:
|
12
|
+
<%=simple_format strip_tags(@inquiry.message) %>
|
13
|
+
|
14
|
+
--- inquiry ends ---
|
15
|
+
|
16
|
+
Kind regards,
|
17
|
+
Your friendly robot at <%=raw RefinerySetting[:site_name] %>
|
18
|
+
|
19
|
+
P.S. All your comments are stored in the 'Product Inquiries' section of Refinery.
|
@@ -11,12 +11,16 @@
|
|
11
11
|
<p><i><%= raw @product.summary %></i></p>
|
12
12
|
<div class="price">Price: <%= raw rands(@product.price) %></div>
|
13
13
|
<div class="add_to_cart">
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
<% if RefinerySetting.find_or_set(:use_product_inquiry, false) %>
|
15
|
+
<p><%= link_to("Find Out More", product_inquiry_path(:product_id => @product.id)) %></p>
|
16
|
+
<% else %>
|
17
|
+
<%= form_tag(add_to_cart_path(@product)) do |f| %>
|
18
|
+
<% if defined?(Variant) && @product.variants.present? %>
|
19
|
+
<%= collection_select(:variant, :id, @product.variants.order(:name), :id, :name, {}, {:class => "variant"}) -%>
|
20
|
+
<% end %>
|
21
|
+
<p><%= image_submit_tag("/images/cart.png") %></p>
|
22
|
+
<% end %>
|
23
|
+
<% end %>
|
20
24
|
</div>
|
21
25
|
</div>
|
22
26
|
|
data/config/locales/en.yml
CHANGED
@@ -14,7 +14,55 @@ en:
|
|
14
14
|
title: Products
|
15
15
|
categories:
|
16
16
|
title: Categories
|
17
|
+
product_inquiries:
|
18
|
+
title: Product Inquiries
|
19
|
+
description: Provides a product inquiry form and stores product inquiries
|
20
|
+
product_inquiries:
|
21
|
+
new:
|
22
|
+
send: Send message
|
23
|
+
privacy_policy: We value your privacy
|
17
24
|
admin:
|
25
|
+
product_inquiries:
|
26
|
+
delete: Remove this product inquiry forever
|
27
|
+
inquiry:
|
28
|
+
read_inquiry: Read the product inquiry
|
29
|
+
said: said
|
30
|
+
mark_as_spam: Mark as spam
|
31
|
+
mark_as_ham: Move to inbox
|
32
|
+
submenu:
|
33
|
+
inbox: Inbox
|
34
|
+
spam: Spam
|
35
|
+
update_notified: Update who gets notified
|
36
|
+
edit_confirmation_email: Edit confirmation email
|
37
|
+
index:
|
38
|
+
no_inquiries: You have not received any product inquiries yet.
|
39
|
+
no_spam: Hooray! You don't have any spam.
|
40
|
+
show:
|
41
|
+
details: Details
|
42
|
+
age: Age
|
43
|
+
actions: Actions
|
44
|
+
back_to_all_inquiries: Back to all Product Inquiries
|
45
|
+
spam: Spam
|
46
|
+
spam_yes: 'yes'
|
47
|
+
inquiry: Product Inquiry
|
48
|
+
to: To
|
49
|
+
from: From
|
50
|
+
click_to_email: Click to email this address
|
51
|
+
phone: Phone
|
52
|
+
date: Date
|
53
|
+
message: Message
|
54
|
+
actions:
|
55
|
+
reorder: Reorder Product Inquiries
|
56
|
+
create_new: Add New Product Inquiry
|
57
|
+
reorder_done: Done Reordering Product Inquiries
|
58
|
+
records:
|
59
|
+
no_items_yet: There are no product inquiries yet. Click "Add New Product Inquiriy" to add your first product inquiry.
|
60
|
+
title: Product Inquiries
|
61
|
+
sorry_no_results: Sorry! There are no results found.
|
62
|
+
line_item:
|
63
|
+
edit: Edit this product inquiry
|
64
|
+
delete: Remove this product inquiry forever
|
65
|
+
view_live_html: View this product inquiry live <br/><em>(opens in a new window)</em>
|
18
66
|
line_items:
|
19
67
|
actions:
|
20
68
|
reorder: Reorder Line Items
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
::Refinery::Application.routes.draw do
|
2
2
|
devise_for :customers
|
3
|
+
get '/product_inquiry', :to => 'product_inquiries#new', :as => 'product_inquiry'
|
4
|
+
get '/product_inquiry_thank_you', :to => 'product_inquiries#thank_you', :as => 'product_inquiry_thank_you'
|
3
5
|
|
6
|
+
resources :product_inquiries, :only => [:new, :create]
|
4
7
|
resources :products, :only => [:index, :show]
|
5
8
|
|
6
9
|
resources :categories, :only => [:index, :show] do
|
@@ -54,5 +57,13 @@
|
|
54
57
|
post :update_positions
|
55
58
|
end
|
56
59
|
end
|
60
|
+
resources :product_inquiries, :only => [:index, :show, :destroy] do
|
61
|
+
collection do
|
62
|
+
get :spam
|
63
|
+
end
|
64
|
+
member do
|
65
|
+
get :toggle_spam
|
66
|
+
end
|
67
|
+
end
|
57
68
|
end
|
58
69
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class CreateProductInquiry < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
create_table :product_inquiries do |t|
|
5
|
+
t.references :product
|
6
|
+
t.string "name"
|
7
|
+
t.string "email"
|
8
|
+
t.string "phone"
|
9
|
+
t.text "message"
|
10
|
+
t.boolean "spam", :default => false
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :product_inquiries, :product_id
|
15
|
+
|
16
|
+
load(Rails.root.join('db', 'seeds', 'product_inquiries.rb'))
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.down
|
20
|
+
if defined?(UserPlugin)
|
21
|
+
UserPlugin.destroy_all({:name => "product_inquiries"})
|
22
|
+
end
|
23
|
+
|
24
|
+
drop_table :product_inquiries
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
if defined?(User)
|
2
|
+
User.all.each do |user|
|
3
|
+
if user.plugins.where(:name => 'product_inquiries').blank?
|
4
|
+
user.plugins.create(:name => 'product_inquiries',
|
5
|
+
:position => (user.plugins.maximum(:position) || -1) +1)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined?(::Page)
|
11
|
+
page_position = (::Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)
|
12
|
+
|
13
|
+
contact_us_page = ::Page.create({
|
14
|
+
:title => "Product Inquiry",
|
15
|
+
:link_url => "/product_inquiry",
|
16
|
+
:menu_match => "^/product_inquiry.*$",
|
17
|
+
:show_in_menu => false,
|
18
|
+
:deletable => false,
|
19
|
+
:position => (page_position += 1)
|
20
|
+
})
|
21
|
+
contact_us_page.parts.create({
|
22
|
+
:title => "Body",
|
23
|
+
:body => "<p>Get in touch with us. Just use the form below and we'll get back to you as soon as we can.</p>",
|
24
|
+
:position => 0
|
25
|
+
})
|
26
|
+
|
27
|
+
contact_us_page_position = -1
|
28
|
+
|
29
|
+
thank_you_page = contact_us_page.children.create({
|
30
|
+
:title => "Thank You",
|
31
|
+
:link_url => "/product_inquiry_thank_you",
|
32
|
+
:menu_match => "^/product_inquiry_thank_you$",
|
33
|
+
:show_in_menu => false,
|
34
|
+
:deletable => false,
|
35
|
+
:position => (contact_us_page_position += 1)
|
36
|
+
})
|
37
|
+
thank_you_page.parts.create({
|
38
|
+
:title => "Body",
|
39
|
+
:body => "<p>We've received your inquiry and will get back to you with a response shortly.</p><p><a href='/'>Return to the home page</a></p>",
|
40
|
+
:position => 0
|
41
|
+
})
|
42
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'refinerycms-base'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module ProductInquiries
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :root
|
8
|
+
def root
|
9
|
+
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Engine < Rails::Engine
|
14
|
+
initializer "static assets" do |app|
|
15
|
+
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
16
|
+
end
|
17
|
+
|
18
|
+
config.after_initialize do
|
19
|
+
Refinery::Plugin.register do |plugin|
|
20
|
+
plugin.name = "product_inquiries"
|
21
|
+
plugin.pathname = root
|
22
|
+
plugin.activity = {
|
23
|
+
:class => ProductInquiry,
|
24
|
+
:title => 'name'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/refinerycms-products.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'refinerycms-base'
|
2
|
+
require 'refinery'
|
2
3
|
require 'refinerycms-categories'
|
3
4
|
require 'refinerycms-customers'
|
4
5
|
require 'refinerycms-carts'
|
5
6
|
require 'refinerycms-line_items'
|
6
|
-
require '
|
7
|
+
require 'refinerycms-product_inquiries'
|
7
8
|
|
8
9
|
module Refinery
|
9
10
|
module Products
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-products
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -40,7 +40,9 @@ files:
|
|
40
40
|
- lib/refinerycms-customers.rb
|
41
41
|
- lib/refinerycms-line_items.rb
|
42
42
|
- lib/refinerycms-products.rb
|
43
|
+
- lib/refinerycms-product_inquiries.rb
|
43
44
|
- lib/tasks/products.rake
|
45
|
+
- config/initializers/settings.rb
|
44
46
|
- config/locales/en.yml
|
45
47
|
- config/locales/fr.yml
|
46
48
|
- config/locales/lolcat.yml
|
@@ -53,20 +55,24 @@ files:
|
|
53
55
|
- app/controllers/admin/customers_controller.rb
|
54
56
|
- app/controllers/admin/line_items_controller.rb
|
55
57
|
- app/controllers/admin/products_controller.rb
|
58
|
+
- app/controllers/admin/product_inquiries_controller.rb
|
56
59
|
- app/controllers/carts_controller.rb
|
57
60
|
- app/controllers/categories_controller.rb
|
58
61
|
- app/controllers/customers_controller.rb
|
59
62
|
- app/controllers/line_items_controller.rb
|
60
63
|
- app/controllers/products_controller.rb
|
64
|
+
- app/controllers/product_inquiries_controller.rb
|
61
65
|
- app/controllers/profiles_controller.rb
|
62
66
|
- app/helpers/address_helper.rb
|
63
67
|
- app/helpers/products_helper.rb
|
68
|
+
- app/mailers/product_inquiry_mailer.rb
|
64
69
|
- app/models/address.rb
|
65
70
|
- app/models/cart.rb
|
66
71
|
- app/models/category.rb
|
67
72
|
- app/models/customer.rb
|
68
73
|
- app/models/line_item.rb
|
69
74
|
- app/models/product.rb
|
75
|
+
- app/models/product_inquiry.rb
|
70
76
|
- app/views/addresses/edit.html.erb
|
71
77
|
- app/views/admin/carts/edit.html.erb
|
72
78
|
- app/views/admin/carts/index.html.erb
|
@@ -114,6 +120,10 @@ files:
|
|
114
120
|
- app/views/admin/products/_products.html.erb
|
115
121
|
- app/views/admin/products/_records.html.erb
|
116
122
|
- app/views/admin/products/_sortable_list.html.erb
|
123
|
+
- app/views/admin/product_inquiries/index.html.erb
|
124
|
+
- app/views/admin/product_inquiries/show.html.erb
|
125
|
+
- app/views/admin/product_inquiries/_inquiry.html.erb
|
126
|
+
- app/views/admin/product_inquiries/_submenu.html.erb
|
117
127
|
- app/views/carts/show.html.erb
|
118
128
|
- app/views/categories/index.html.erb
|
119
129
|
- app/views/categories/show.html.erb
|
@@ -123,6 +133,9 @@ files:
|
|
123
133
|
- app/views/line_items/show.html.erb
|
124
134
|
- app/views/products/index.html.erb
|
125
135
|
- app/views/products/show.html.erb
|
136
|
+
- app/views/product_inquiries/new.html.erb
|
137
|
+
- app/views/product_inquiries/thank_you.html.erb
|
138
|
+
- app/views/product_inquiry_mailer/notification.html.erb
|
126
139
|
- app/views/profiles/account_details.html.erb
|
127
140
|
- app/views/profiles/address_details.html.erb
|
128
141
|
- app/views/profiles/index.html.erb
|
@@ -135,6 +148,7 @@ files:
|
|
135
148
|
- db/migrate/12_create_carts.rb
|
136
149
|
- db/migrate/13_create_line_items.rb
|
137
150
|
- db/migrate/14_fields_added_to_line_items.rb
|
151
|
+
- db/migrate/15_create_product_inquiry.rb
|
138
152
|
- db/migrate/1_create_categories.rb
|
139
153
|
- db/migrate/2_description_added_to_category.rb
|
140
154
|
- db/migrate/3_fields_added_to_category.rb
|
@@ -149,6 +163,7 @@ files:
|
|
149
163
|
- db/seeds/customers.rb
|
150
164
|
- db/seeds/line_items.rb
|
151
165
|
- db/seeds/products.rb
|
166
|
+
- db/seeds/product_inquiries.rb
|
152
167
|
- public/images/cart.png
|
153
168
|
- public/images/corner.png
|
154
169
|
- public/images/minus.png
|