Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B/mem+gs/master - Guinevere & Mary #54

Open
wants to merge 39 commits into
base: b/mem+gs/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
41ee7ed
Created models and migrated with relationships
guineveresaenger Oct 4, 2016
21bc111
Added relationships to model classes
guineveresaenger Oct 4, 2016
8671a8b
Created controllers for market and vendor
guineveresaenger Oct 4, 2016
1771b4d
Added view files for market and vendor
guineveresaenger Oct 4, 2016
0fde98e
Nonworking seeds file that won't run from the command line
guineveresaenger Oct 4, 2016
673d5e4
working seeds file for Markets
guineveresaenger Oct 4, 2016
5ca0b79
read in CSV files for markets, vendors, products, and sales in seed.r…
morrime Oct 4, 2016
bcdc4d7
controllers for product and sale, added nested routes for products an…
morrime Oct 4, 2016
5f1ca1c
added home controller, routes and views, linking to a list of the mar…
morrime Oct 4, 2016
9ced093
added home controller, routes and views, linking to a list of the mar…
morrime Oct 4, 2016
b4b148e
Hopefully cleaned up the file mess
guineveresaenger Oct 5, 2016
7ba24ba
Final cleanup hopefully
guineveresaenger Oct 5, 2016
62c0464
Merge branch 'b/mem+gs/master' of https://github.com/morrime/FarMarRa…
guineveresaenger Oct 5, 2016
715446d
Added user view for individual markets
guineveresaenger Oct 5, 2016
72ccb4a
Began Wave 3; added market controller actions, and views. Markets can…
guineveresaenger Oct 5, 2016
b729c8e
still working on Wave 3: Market: As a market, I can create, edit, or …
morrime Oct 5, 2016
9875832
Just put a comment in about how and where to create/edit vendors as a…
guineveresaenger Oct 6, 2016
30dd508
Added Vendor functions and views
guineveresaenger Oct 6, 2016
245192c
As a market, I can create, edit, or delete any Vendor
morrime Oct 6, 2016
5af1e95
Resolved merge conflict in vendors controller
guineveresaenger Oct 6, 2016
0ba1e00
renested routes, fixed resulting errors...
morrime Oct 6, 2016
1d0cdb5
Added create Sate functionality to vendor via product
guineveresaenger Oct 7, 2016
9a9ed6f
as vendor, can see list of all sales
morrime Oct 7, 2016
318d7f2
merged sales controller
guineveresaenger Oct 7, 2016
a15b2c9
For safekeeping
guineveresaenger Oct 7, 2016
abf98f8
Monthly and total sales amount functionality added.
guineveresaenger Oct 7, 2016
9c50aea
added monthly sales display
morrime Oct 7, 2016
748ccc7
validations in place for all models, cleaned up routes
morrime Oct 7, 2016
a4f716f
Edited the views for consistency. Added nav bar to application view.
guineveresaenger Oct 7, 2016
97130bc
Resolved merge conflicts
guineveresaenger Oct 7, 2016
d602c4c
deleted sale validation for name
morrime Oct 7, 2016
d1d8dba
Changed name validation for Sale
guineveresaenger Oct 7, 2016
0cbfb93
Merge branch 'b/mem+gs/master' of https://github.com/morrime/FarMarRa…
morrime Oct 7, 2016
351ac32
Changed application.css to have .erb extension; added picture, backgr…
guineveresaenger Oct 7, 2016
ac7dbff
modified link_to in index.html.erb
morrime Oct 7, 2016
6629970
added production to gemfile and moved sqlite3
morrime Oct 7, 2016
18040d6
bundle install --without production
morrime Oct 7, 2016
e4ce024
css fun...
morrime Oct 7, 2016
6fe2865
permissions modified for market
morrime Oct 7, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.7'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
Expand Down Expand Up @@ -40,8 +38,17 @@ end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'


# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'better_errors'
gem 'binding_of_caller'
end

group :production do
gem 'pg'
gem 'rails_12factor'
end
15 changes: 15 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ GEM
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (9.0.6)
coderay (1.1.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
Expand Down Expand Up @@ -76,6 +81,7 @@ GEM
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
pg (0.19.0)
pkg-config (1.1.7)
rack (1.6.4)
rack-test (0.6.3)
Expand All @@ -99,6 +105,11 @@ GEM
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (4.2.7)
actionpack (= 4.2.7)
activesupport (= 4.2.7)
Expand Down Expand Up @@ -147,11 +158,15 @@ PLATFORMS
ruby

DEPENDENCIES
better_errors
binding_of_caller
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
pg
rails (= 4.2.7)
rails_12factor
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
Expand Down
Binary file added app/assets/images/fruitsandveggies.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/javascripts/homes.coffee
Original file line number Diff line number Diff line change
@@ -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://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/markets.coffee
Original file line number Diff line number Diff line change
@@ -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://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/products.coffee
Original file line number Diff line number Diff line change
@@ -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://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/sales.coffee
Original file line number Diff line number Diff line change
@@ -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://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/vendors.coffee
Original file line number Diff line number Diff line change
@@ -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://coffeescript.org/
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
Expand All @@ -13,3 +15,37 @@
*= require_tree .
*= require_self
*/

header {
background-image: url(<%= asset_path "fruitsandveggies.jpg" %>);
color: white;
text-align: center;
padding-top: 15px;
font-size: 2em;
margin-bottom: 30px;
}

footer {
background-image: url(<%= asset_path "fruitsandveggies.jpg" %>);
color: white;
text-align: center;
padding-top: 1px;
padding-bottom: 3px;
font-weight: bold;
margin-top: 30px;
}

nav a{
color: white;
text-decoration: none;
margin-left: 25px;
margin-right: 25px;
font-weight: bold;
}
nav {
padding-bottom: 25px;
}

h3 {
text-align: left;
}
19 changes: 19 additions & 0 deletions app/assets/stylesheets/homes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Place all the styles related to the homes controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/


div {
padding: 40px;
text-align: center;
}

div a {
font-size: 1.75em;
font-family: "Trebuchet MS", Helvetica, sans-serif;
text-decoration: none;
}

#centered {
text-align: center;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/markets.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the markets 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/products.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the products 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/sales.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the sales 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/vendors.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the vendors controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
11 changes: 11 additions & 0 deletions app/controllers/homes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class HomesController < ApplicationController

def show_markets
@markets = Market.all
end

def show
@market = Market.find(params[:id])
@vendors = Vendor.where(market_id: params[:id])
end
end
55 changes: 55 additions & 0 deletions app/controllers/markets_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class MarketsController < ApplicationController
def index
@markets = Market.all
end

def show
@market = Market.find(params[:id])
@vendors = Vendor.where(market_id: params[:id])
end

def new
@market = Market.new
end

def create
@market = Market.new(market_params)
if @market.save
redirect_to markets_path
else
render :new
end

end

def edit
@market = Market.find(params[:id])
end

def update
@market = Market.find(params[:id])

if @market.update(market_params)
redirect_to markets_path
else
render :edit
end

end

def destroy
@vendor = Vendor.find(params[:id])
@vendor.destroy
redirect_to market_path(@vendor.market)
end


# make a link to each vendor (that is vendor#show in vendors_controller) and that is literally all we need. you cannot get to that vendor display as a vendor. Then put delete and edit buttions on that, again run through the vendors controller.

private

def market_params
params.require(:market).permit(:name, :address, :city, :state, :zip)
end

end
53 changes: 53 additions & 0 deletions app/controllers/products_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
class ProductsController < ApplicationController

def index
@products = Product.all
end

def show
@product = Product.find(params[:id])
@vendor= Vendor.find(@product.vendor_id)

end

def new
@vendor = Vendor.find(params[:vendor_id])
@product = @vendor.products.new
end

def create
@vendor = Vendor.find(params[:vendor_id])
@product = @vendor.products.new(product_params)
if @product.save
redirect_to vendor_path(@product.vendor)
else
render :new
end
end

def edit
@product = Product.find(params[:id])
end

def update
@product = Product.find(params[:id])
if @product.update(product_params)
redirect_to vendor_path(@product.vendor)
else
render :edit
end
end

def destroy
@product = Product.find(params[:id])
@product.destroy
redirect_to vendor_path(@product.vendor)
end

private

def product_params
params.require(:product).permit(:name, :market_id, :num_employees)
end

end
38 changes: 38 additions & 0 deletions app/controllers/sales_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
class SalesController < ApplicationController

def index
@sales = Sale.all
end

def show
@sale = Sale.find(params[:id])
@vendor= Vendor.find(@sale.vendor_id)
end

def new
@vendor = Vendor.find(params[:vendor_id])
@product = @vendor.products.find(params[:product_id])
@sale = @product.sales.new
end

def create
@vendor = Vendor.find(params[:vendor_id])
@product = @vendor.products.find(params[:product_id])
@sale = @product.sales.new(sale_params)
@sale.vendor_id = params[:vendor_id]

if @sale.save
redirect_to vendor_path(@sale.vendor_id)
else
render :new
end
end

private

def sale_params
params.require(:sale).permit(:name, :product_id, :vendor_id, :purchase_time, :amount)
end


end
56 changes: 56 additions & 0 deletions app/controllers/vendors_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
class VendorsController < ApplicationController

def index
@vendors = Vendor.all
end

def show
@vendor = Vendor.find(params[:id])
@market = Market.find(@vendor.market_id)
@products = Product.where(vendor_id: params[:id])
@sales = Sale.where(vendor_id: params[:id])


end

def new
@market = Market.find(params[:market_id])
@vendor = @market.vendors.new
end

def create
@market = Market.find(params[:market_id])
@vendor = @market.vendors.new(vendor_params)
if @vendor.save
redirect_to market_path(@vendor.market)
else
render :new
end
end

def edit
@vendor = Vendor.find(params[:id])
end

def update
@vendor = Vendor.find(params[:id])
if @vendor.update(vendor_params)
redirect_to markets_path(@vendor.market)
else
render :edit
end
end

def destroy
Vendor.find(params[:id]).destroy
redirect_to market_vendors_path
end

private

def vendor_params
params.require(:vendor).permit(:name, :vendor_id, :num_employees)
end


end
2 changes: 2 additions & 0 deletions app/helpers/homes_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module HomesHelper
end
Loading