Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nisargshah100 committed Apr 19, 2012
2 parents 8f5d4f4 + 1122f4c commit 687662d
Show file tree
Hide file tree
Showing 33 changed files with 21 additions and 76 deletions.
4 changes: 2 additions & 2 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def new

def show
@category = Category.find(params[:id])
@products = @category.products.where(:active => 1)
.paginate(:page => params[:page])
@products =
@category.products.where(:active => 1).paginate(:page => params[:page])
@categories = Category.all
end

Expand Down
24 changes: 5 additions & 19 deletions app/controllers/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def index
else
@orders = Order.where(:status_id => status.id)
end

@statuses = Status.all
@order_count = Order.all.count
end
Expand Down Expand Up @@ -60,19 +59,7 @@ def charge

def status
order = Order.find(params[:id])

if order
if order.status.pending?
order.cancel
elsif order.status.shipped?
order.return
elsif order.status.paid?
order.ship
end

order.save
end

order.next_status
redirect_to order_path(order), :notice => 'Status has been updated'
end

Expand All @@ -88,11 +75,10 @@ def track
def my_orders
st = params[:mq]
if st
orders = current_user
.orders.joins(:products)
.where('products.name LIKE ? or products.description LIKE ?',
"%#{st}%", "%#{st}%")
.uniq
orders = current_user.orders.
joins(:products).where('products.name LIKE ? or
products.description LIKE ?',"%#{st}%",
"%#{st}%").uniq
else
orders = current_user.orders
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create
remember_me = false)
if user.nil?
@user = User.new(params[:user])
flash[:notice] = "You have entered an incorrect username or password"
flash[:error] = "You have entered an incorrect username or password"
render 'new'
else
redirect_back_or_to(root_path, :notice => 'Login successful.')
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/notification.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sends out an email
class Notification < ActionMailer::Base
default from: "noreply@ehipster.herokuapp.com"
default :from => "noreply@ehipster.herokuapp.com"

def order_email(user, order)
@user = user
Expand Down
12 changes: 12 additions & 0 deletions app/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ def generate_unique_url
self.unique_url = (0...32).map{65.+(rand(25)).chr}.join
end

def next_status
next_status = {
"pending" => :cancel,
"shipped" => :return,
"paid" => :ship
}
if next_status["#{self.status.name}"]
send(next_status["#{self.status.name}"])
end
self.save
end

def cancel
self.status = Status.find_or_create_by_name('cancelled')
self.cancelled_at = DateTime.now
Expand Down
1 change: 0 additions & 1 deletion app/models/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ def shipped?
def paid?
name == 'paid'
end

end

This file was deleted.

Binary file not shown.
19 changes: 0 additions & 19 deletions public/assets/application-a99dbb8a105721a005333e5007c28fca.js

This file was deleted.

Binary file not shown.
1 change: 0 additions & 1 deletion public/assets/application.css

This file was deleted.

Binary file removed public/assets/application.css.gz
Binary file not shown.
19 changes: 0 additions & 19 deletions public/assets/application.js

This file was deleted.

Binary file removed public/assets/application.js.gz
Binary file not shown.
Binary file not shown.
Binary file removed public/assets/baller-logo-big.png
Binary file not shown.
Binary file not shown.
Binary file removed public/assets/bg.png
Binary file not shown.
Binary file not shown.
Binary file removed public/assets/delete.gif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed public/assets/glyphicons-halflings-white.png
Binary file not shown.
Binary file removed public/assets/glyphicons-halflings.png
Binary file not shown.
Binary file not shown.
Binary file removed public/assets/logo.png
Binary file not shown.
12 changes: 0 additions & 12 deletions public/assets/manifest.yml

This file was deleted.

Binary file not shown.
Binary file removed public/assets/nav-hover.png
Binary file not shown.
Binary file removed public/assets/star-fa951ca0ce92f92de972a10dccf4def2.gif
Binary file not shown.
Binary file not shown.
Binary file removed public/assets/star-on.png
Binary file not shown.
Binary file removed public/assets/star.gif
Binary file not shown.

0 comments on commit 687662d

Please sign in to comment.