Permalink
Browse files

final formatting before release

  • Loading branch information...
1 parent 0658df9 commit 4007070e9c36f0990e1259a6d2addcfe8dcad1dc Sasha committed Nov 12, 2011
View
35 Gemfile
@@ -1,40 +1,15 @@
source 'http://rubygems.org'
gem 'rails', '3.0.9'
-# Bundle edge Rails instead:
-# gem 'rails', :git => 'git://github.com/rails/rails.git'
-
gem 'sqlite3'
-
-# Use unicorn as the web server
-# gem 'unicorn'
-
-# Deploy with Capistrano
-# gem 'capistrano'
-
-# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
-# gem 'ruby-debug'
-# gem 'ruby-debug19', :require => 'ruby-debug'
-
-# Bundle the extra gems:
-# gem 'bj'
-# gem 'nokogiri'
-# gem 'sqlite3-ruby', :require => 'sqlite3'
-# gem 'aws-s3', :require => 'aws/s3'
gem 'will_paginate', '>= 3.0.pre'
-# Bundle gems for the local environment. Make sure to
-# put test-only gems in this group so their generators
-# and rake tasks are available in development mode:
-
group :development, :test do
- # gem 'webrat'
- gem "awesome_print"
- gem "wirble"
- gem "looksee"
# gem "rspec-rails"
end
-# group :development, :test do
-# gem 'webrat'
-# end
+group :development do
+ gem "awesome_print"
+ gem "wirble"
+ gem "looksee"
+end
View
@@ -1,5 +1,3 @@
-# Учебный проект
+# Just for educational purpose
-**Это первое приложение для тренировки.**
-
-Типа инет-магазин.
+** The Depot project.**
@@ -2,7 +2,4 @@ class AdminController < ApplicationController
def index
@total_orders = Order.count
end
-
-
-
end
@@ -1,33 +1,31 @@
class ApplicationController < ActionController::Base
- before_filter :set_i18n_locale_from_params
- # ...
- before_filter :authorize
- protect_from_forgery
+ before_filter :set_i18n_locale_from_params
+ # ...
+ before_filter :authorize
+ protect_from_forgery
private
-
- def current_cart
+ def current_cart
Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound
cart = Cart.create
session[:cart_id] = cart.id
cart
end
-
+
protected
-
- def authorize
- unless User.count.zero? || User.find_by_id(session[:user_id])
- redirect_to login_url, :notice=>"Please log in"
- end
- end
-
- def set_i18n_locale_from_params
+ def authorize
+ unless User.count.zero? || User.find_by_id(session[:user_id])
+ redirect_to login_url, :notice=>"Please log in"
+ end
+ end
+
+ def set_i18n_locale_from_params
if params[:locale]
if I18n.available_locales.include?(params[:locale].to_sym)
I18n.locale = params[:locale]
else
- flash.now[:notice] =
+ flash.now[:notice] =
"#{params[:locale]} translation not available"
logger.error flash.now[:notice]
end
@@ -37,5 +35,4 @@ def set_i18n_locale_from_params
def default_url_options
{ :locale => I18n.locale }
end
-
end
@@ -14,17 +14,17 @@ def index
# GET /carts/1
# GET /carts/1.xml
def show
- begin
- @cart = Cart.find(params[:id])
- rescue ActiveRecord::RecordNotFound
- logger.error "Attempt to access invalid cart #{params[:id]}"
- redirect_to store_url, :notice=>'Invalid cart'
- else
- respond_to do |format|
- format.html # show.html.erb
- format.xml { render :xml => @cart }
- end
- end
+ begin
+ @cart = Cart.find(params[:id])
+ rescue ActiveRecord::RecordNotFound
+ logger.error "Attempt to access invalid cart #{params[:id]}"
+ redirect_to store_url, :notice=>'Invalid cart'
+ else
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @cart }
+ end
+ end
end
# GET /carts/new
@@ -37,7 +37,7 @@ def new
format.xml { render :xml => @cart }
end
end
-
+
# GET /carts/1/edit
def edit
@cart = Cart.find(params[:id])
@@ -78,10 +78,10 @@ def update
# DELETE /carts/1
# DELETE /carts/1.xml
def destroy
- @cart = current_cart
- @cart.destroy
- session[:cart_id] = nil
-
+ @cart = current_cart
+ @cart.destroy
+ session[:cart_id] = nil
+
respond_to do |format|
format.html { redirect_to(store_url) }
format.js
@@ -41,14 +41,14 @@ def edit
# POST /line_items
# POST /line_items.xml
def create
- @cart = current_cart
- product = Product.find(params[:product_id])
+ @cart = current_cart
+ product = Product.find(params[:product_id])
@line_item = @cart.add_product(product.id)
-
+
if !session[:access_counter].nil?
- session[:access_counter] = 0
+ session[:access_counter] = 0
end
-
+
respond_to do |format|
if @line_item.save
format.html { redirect_to(store_url) } #@line_item.cart) }
@@ -82,8 +82,8 @@ def update
def destroy
@line_item = LineItem.find(params[:id])
@line_item.destroy
- @cart = current_cart
-
+ @cart = current_cart
+
respond_to do |format|
format.html { redirect_to(store_url)} #current_cart) }
format.js
@@ -3,10 +3,12 @@ class MissmethController < ApplicationController
if ::Rails.env == "development"
def method_missing(name, *args)
- render(:inline => %{
+ render(:inline =>
+ %{
<h2>Unknown action: #{name}</h2>
Here are the request parameters:<br/>
- <%= debug(params) %> })
+ <%= debug(params) %>
+ })
end
end
end
@@ -26,12 +26,12 @@ def show
# GET /orders/new
# GET /orders/new.xml
def new
- @cart = current_cart
- if @cart.line_items.empty?
- redirect_to store_url, :notice=>"Your cart is empty"
- return
- end
-
+ @cart = current_cart
+ if @cart.line_items.empty?
+ redirect_to store_url, :notice=>"Your cart is empty"
+ return
+ end
+
@order = Order.new
respond_to do |format|
@@ -53,9 +53,9 @@ def create
respond_to do |format|
if @order.save
- Cart.destroy(session[:cart_id])
- session[:cart_id] = nil
- Notifier.order_received(@order).deliver
+ Cart.destroy(session[:cart_id])
+ session[:cart_id] = nil
+ Notifier.order_received(@order).deliver
format.html { redirect_to(store_url, :notice => I18n.t('.thanks')) }
format.xml { render :xml => @order, :status => :created, :location => @order }
else
@@ -80,13 +80,13 @@ def destroy
format.xml { head :ok }
end
end
-
+
def who_bought
- @product = Product.find(params[:id])
- respond_to do |format|
- format.atom
- format.xml { render :xml=>@product }
- end
+ @product = Product.find(params[:id])
+ respond_to do |format|
+ format.atom
+ format.xml { render :xml=>@product }
+ end
end
end
@@ -1,21 +1,21 @@
class SessionsController < ApplicationController
skip_before_filter :authorize
-
+
def new
end
def create
- if user = User.authenticate(params[:name], params[:password])
- session[:user_id] = user.id
- redirect_to admin_url
- else
- redirect_to login_url, :alert=>"Invalid user/password combination"
- end
+ if user = User.authenticate(params[:name], params[:password])
+ session[:user_id] = user.id
+ redirect_to admin_url
+ else
+ redirect_to login_url, :alert=>"Invalid user/password combination"
+ end
end
def destroy
- session[:user_id]=nil
- redirect_to store_url, :notice=>"Logged out"
+ session[:user_id]=nil
+ redirect_to store_url, :notice=>"Logged out"
end
end
@@ -1,19 +1,19 @@
class StoreController < ApplicationController
skip_before_filter :authorize
-
+
def index
- if params[:set_locale]
- redirect_to store_path(:locale=>params[:set_locale])
- else
- @products = Product.all
- @cart = current_cart
-
- if session[:access_counter].nil?
- session[:access_counter] = 1
- else
- session[:access_counter]+=1
- end
- @access_counter = session[:access_counter]
- end
+ if params[:set_locale]
+ redirect_to store_path(:locale=>params[:set_locale])
+ else
+ @products = Product.all
+ @cart = current_cart
+
+ if session[:access_counter].nil?
+ session[:access_counter] = 1
+ else
+ session[:access_counter]+=1
+ end
+ @access_counter = session[:access_counter]
+ end
end
end
@@ -74,12 +74,12 @@ def update
def destroy
@user = User.find(params[:id])
begin
- @user.destroy
- flash[:notice] = "User #{@user.name} deleted"
+ @user.destroy
+ flash[:notice] = "User #{@user.name} deleted"
rescue Exception => e
- flash[:notice] = e.message
+ flash[:notice] = e.message
end
-
+
respond_to do |format|
format.html { redirect_to(users_url) }
format.xml { head :ok }
@@ -1,8 +1,8 @@
-#encoding: utf-8
-I18n.default_locale = :en
-
-LANGUAGES = [
- ['English', 'en'],
- ["Espa&ntilde;ol".html_safe, 'es'],
- ["Русский", 'ru']
-]
+#encoding: utf-8
+I18n.default_locale = :en
+
+LANGUAGES = [
+ ['English', 'en'],
+ ["Espa&ntilde;ol".html_safe, 'es'],
+ ["Русский", 'ru']
+]
Oops, something went wrong.

0 comments on commit 4007070

Please sign in to comment.