Skip to content

Commit

Permalink
daniel made me do it
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleli committed Jan 28, 2012
1 parent 3a89240 commit 144d2e4
Show file tree
Hide file tree
Showing 47 changed files with 1,120 additions and 11 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/price.js.coffee
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/javascripts/price_histories.js.coffee
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/javascripts/units.js.coffee
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/price.css.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the price controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/price_histories.css.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the PriceHistories controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/units.css.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the units controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
83 changes: 83 additions & 0 deletions app/controllers/price_histories_controller.rb
@@ -0,0 +1,83 @@
class PriceHistoriesController < ApplicationController
# GET /price_histories
# GET /price_histories.json
def index
@price_histories = PriceHistory.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @price_histories }
end
end

# GET /price_histories/1
# GET /price_histories/1.json
def show
@price_history = PriceHistory.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @price_history }
end
end

# GET /price_histories/new
# GET /price_histories/new.json
def new
@price_history = PriceHistory.new

respond_to do |format|
format.html # new.html.erb
format.json { render json: @price_history }
end
end

# GET /price_histories/1/edit
def edit
@price_history = PriceHistory.find(params[:id])
end

# POST /price_histories
# POST /price_histories.json
def create
@price_history = PriceHistory.new(params[:price_history])

respond_to do |format|
if @price_history.save
format.html { redirect_to @price_history, notice: 'Price history was successfully created.' }
format.json { render json: @price_history, status: :created, location: @price_history }
else
format.html { render action: "new" }
format.json { render json: @price_history.errors, status: :unprocessable_entity }
end
end
end

# PUT /price_histories/1
# PUT /price_histories/1.json
def update
@price_history = PriceHistory.find(params[:id])

respond_to do |format|
if @price_history.update_attributes(params[:price_history])
format.html { redirect_to @price_history, notice: 'Price history was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @price_history.errors, status: :unprocessable_entity }
end
end
end

# DELETE /price_histories/1
# DELETE /price_histories/1.json
def destroy
@price_history = PriceHistory.find(params[:id])
@price_history.destroy

respond_to do |format|
format.html { redirect_to price_histories_url }
format.json { head :ok }
end
end
end
83 changes: 83 additions & 0 deletions app/controllers/units_controller.rb
@@ -0,0 +1,83 @@
class UnitsController < ApplicationController
# GET /units
# GET /units.json
def index
@units = Unit.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @units }
end
end

# GET /units/1
# GET /units/1.json
def show
@unit = Unit.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @unit }
end
end

# GET /units/new
# GET /units/new.json
def new
@unit = Unit.new

respond_to do |format|
format.html # new.html.erb
format.json { render json: @unit }
end
end

# GET /units/1/edit
def edit
@unit = Unit.find(params[:id])
end

# POST /units
# POST /units.json
def create
@unit = Unit.new(params[:unit])

respond_to do |format|
if @unit.save
format.html { redirect_to @unit, notice: 'Unit was successfully created.' }
format.json { render json: @unit, status: :created, location: @unit }
else
format.html { render action: "new" }
format.json { render json: @unit.errors, status: :unprocessable_entity }
end
end
end

# PUT /units/1
# PUT /units/1.json
def update
@unit = Unit.find(params[:id])

respond_to do |format|
if @unit.update_attributes(params[:unit])
format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @unit.errors, status: :unprocessable_entity }
end
end
end

# DELETE /units/1
# DELETE /units/1.json
def destroy
@unit = Unit.find(params[:id])
@unit.destroy

respond_to do |format|
format.html { redirect_to units_url }
format.json { head :ok }
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/price_helper.rb
@@ -0,0 +1,2 @@
module PriceHelper
end
2 changes: 2 additions & 0 deletions app/helpers/price_histories_helper.rb
@@ -0,0 +1,2 @@
module PriceHistoriesHelper
end
2 changes: 2 additions & 0 deletions app/helpers/units_helper.rb
@@ -0,0 +1,2 @@
module UnitsHelper
end
4 changes: 4 additions & 0 deletions app/models/commodity.rb
@@ -1,2 +1,6 @@
class Commodity < ActiveRecord::Base
# has_one retail_unit, :class_name => 'unit'
# has_one wholesale_unit, :class_name => 'unit'
# has_one farm_gate_unit, :class_name => 'unit'
# has_one delivered_unit, :class_name => 'unit'
end
2 changes: 2 additions & 0 deletions app/models/price_history.rb
@@ -0,0 +1,2 @@
class PriceHistory < ActiveRecord::Base
end
10 changes: 5 additions & 5 deletions app/views/layouts/application.html.erb
Expand Up @@ -12,15 +12,15 @@
<div class="container">
<h3><a href="#">Kariokee - The db you were waiting for!</a></h3>
<ul class="nav">
<li class="active"><a href="#">Prices</a></li>
<li><%= link_to 'Prices', price_histories_path %></li>
<li><%= link_to 'Locations', locations_path %></li>
<li><%= link_to 'Commodities', commodities_path %></li>
<li><%= link_to 'Units', units_path %></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle">Admin</a>
<ul class="dropdown-menu">
<li><a href="#">Enter Prices</a></li>
<li class="divider"></li>
<li><a href="#">Commodities</a></li>
<li><a href="#">Units</a></li>
<li><a href="#">Markets</a></li>
<li class="divider"></li>
</ul>
</li>
</ul>
Expand Down
49 changes: 49 additions & 0 deletions app/views/price_histories/_form.html.erb
@@ -0,0 +1,49 @@
<%= form_for(@price_history) do |f| %>
<% if @price_history.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@price_history.errors.count, "error") %> prohibited this price_history from being saved:</h2>

<ul>
<% @price_history.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :farmGateLow %><br />
<%= f.number_field :farmGateLow %>
</div>
<div class="field">
<%= f.label :farmGateHigh %><br />
<%= f.number_field :farmGateHigh %>
</div>
<div class="field">
<%= f.label :deliverHigh %><br />
<%= f.number_field :deliverHigh %>
</div>
<div class="field">
<%= f.label :deliverLow %><br />
<%= f.number_field :deliverLow %>
</div>
<div class="field">
<%= f.label :wholesaleHigh %><br />
<%= f.number_field :wholesaleHigh %>
</div>
<div class="field">
<%= f.label :wholesaleHigh %><br />
<%= f.number_field :wholesaleHigh %>
</div>
<div class="field">
<%= f.label :retailHigh %><br />
<%= f.number_field :retailHigh %>
</div>
<div class="field">
<%= f.label :retailLow %><br />
<%= f.number_field :retailLow %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions app/views/price_histories/edit.html.erb
@@ -0,0 +1,6 @@
<h1>Editing price_history</h1>

<%= render 'form' %>
<%= link_to 'Show', @price_history %> |
<%= link_to 'Back', price_histories_path %>
37 changes: 37 additions & 0 deletions app/views/price_histories/index.html.erb
@@ -0,0 +1,37 @@
<h1>Listing price_histories</h1>

<table>
<tr>
<th>Farmgatelow</th>
<th>Farmgatehigh</th>
<th>Deliverhigh</th>
<th>Deliverlow</th>
<th>Wholesalehigh</th>
<th>Wholesalehigh</th>
<th>Retailhigh</th>
<th>Retaillow</th>
<th></th>
<th></th>
<th></th>
</tr>

<% @price_histories.each do |price_history| %>
<tr>
<td><%= price_history.farmGateLow %></td>
<td><%= price_history.farmGateHigh %></td>
<td><%= price_history.deliverHigh %></td>
<td><%= price_history.deliverLow %></td>
<td><%= price_history.wholesaleHigh %></td>
<td><%= price_history.wholesaleHigh %></td>
<td><%= price_history.retailHigh %></td>
<td><%= price_history.retailLow %></td>
<td><%= link_to 'Show', price_history %></td>
<td><%= link_to 'Edit', edit_price_history_path(price_history) %></td>
<td><%= link_to 'Destroy', price_history, confirm: 'Are you sure?', method: :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Price history', new_price_history_path %>
5 changes: 5 additions & 0 deletions app/views/price_histories/new.html.erb
@@ -0,0 +1,5 @@
<h1>New price_history</h1>

<%= render 'form' %>
<%= link_to 'Back', price_histories_path %>
45 changes: 45 additions & 0 deletions app/views/price_histories/show.html.erb
@@ -0,0 +1,45 @@
<p id="notice"><%= notice %></p>

<p>
<b>Farmgatelow:</b>
<%= @price_history.farmGateLow %>
</p>

<p>
<b>Farmgatehigh:</b>
<%= @price_history.farmGateHigh %>
</p>

<p>
<b>Deliverhigh:</b>
<%= @price_history.deliverHigh %>
</p>

<p>
<b>Deliverlow:</b>
<%= @price_history.deliverLow %>
</p>

<p>
<b>Wholesalehigh:</b>
<%= @price_history.wholesaleHigh %>
</p>

<p>
<b>Wholesalehigh:</b>
<%= @price_history.wholesaleHigh %>
</p>

<p>
<b>Retailhigh:</b>
<%= @price_history.retailHigh %>
</p>

<p>
<b>Retaillow:</b>
<%= @price_history.retailLow %>
</p>


<%= link_to 'Edit', edit_price_history_path(@price_history) %> |
<%= link_to 'Back', price_histories_path %>
17 changes: 17 additions & 0 deletions app/views/units/_form.html.erb
@@ -0,0 +1,17 @@
<%= form_for(@unit) do |f| %>
<% if @unit.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@unit.errors.count, "error") %> prohibited this unit from being saved:</h2>

<ul>
<% @unit.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="actions">
<%= f.submit %>
</div>
<% end %>

0 comments on commit 144d2e4

Please sign in to comment.