-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic store access. Associations between stores and taxonomies, produ…
…cts.
- Loading branch information
Showing
10 changed files
with
125 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
%h1 | ||
= @store.name | ||
admin panel | ||
%p Welcome to the Overview Page. This is a placeholder for some real content. Eventually we envision a bunch of "widgets" summarizing recent activity and other elements of interest. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
%h1= @store.name | ||
|
||
#product-listing | ||
= breadcrumbs(@taxon) | ||
%br | ||
= render :partial => "shared/products.html.erb", :locals => {:products => @products } | ||
|
||
- content_for :sidebar do | ||
|
||
%td{ :id => "shop-by-col", :valign => "top"} | ||
= render :partial => "shared/taxonomies" | ||
= render :partial => 'shared/paginate', :locals => {:collection => @products, :options => {}} unless @products.empty? |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class AddStoreToTaxonomies < ActiveRecord::Migration | ||
def self.up | ||
add_column :taxonomies, :store_id, :integer | ||
end | ||
|
||
def self.down | ||
remove_column :taxonomies, :store_id | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,38 @@ | ||
module StoreSystem | ||
module MultiStore | ||
module StoreSystem | ||
|
||
def current_store | ||
@current_store ||= Store.find_by_host(request.host) or raise Store::UndefinedError | ||
@current_store ||= (get_store_from_request || get_store_from_session || false) | ||
end | ||
|
||
end | ||
|
||
def current_store=(new_store) | ||
session[:store_id] = new_store.nil? ? nil : new_store.id | ||
@current_store = new_store || :false | ||
end | ||
|
||
def get_store_from_session | ||
self.current_store = Store.find(session[:store_id]) if session[:store_id] | ||
end | ||
|
||
def get_store_from_request | ||
self.current_store = Store.find_by_param(params[:store_name]) | ||
end | ||
|
||
def get_store_and_products | ||
yield | ||
# raise Store::UndefinedError unless @store = current_store | ||
@store = current_store | ||
@taxonomies = @store.taxonomies.find(:all, :include => {:root => :children}) | ||
@products = @store.products.find(:all) | ||
end | ||
|
||
def get_store_for_owner | ||
@store = current_user.store if current_user.has_role?("admin") | ||
self.current_store = @store | ||
end | ||
|
||
def get_store_products | ||
@products = @store.products | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters