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

Submitting FarMar Rails for Emily & Sarah #19

Open
wants to merge 59 commits into
base: ergsat/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8b626ea
created import_stuff.rb file to translate CSV file into SQL-readable …
trowbrsa Nov 18, 2015
4f7b992
deleted secret message
emgord Nov 18, 2015
b7a89dd
Merge branch 'ergsat/master' of github.com:emgord/FarMarRails into er…
emgord Nov 18, 2015
1bfb960
created models for market, vendor, product and sales, migrated db
emgord Nov 18, 2015
60dfccf
Seeded database with Market csv information
trowbrsa Nov 18, 2015
4d2d085
Seeded database with all CSV files
trowbrsa Nov 18, 2015
233134f
Created all controllers
trowbrsa Nov 18, 2015
a49f60c
Created index views for Market and Vendor
trowbrsa Nov 18, 2015
c1f535b
added view for home page, and partial to make a list of links
emgord Nov 18, 2015
4553315
tried to make some changes to the linklist partial, but ended up stic…
emgord Nov 18, 2015
031efa1
Created partial for Market > Vendor Show method
trowbrsa Nov 18, 2015
c1189d7
Added html styling for Market's detail page
trowbrsa Nov 18, 2015
391cf77
added edit and delete for markets
emgord Nov 18, 2015
725796c
Created a show page for Vendors and defined the show method
trowbrsa Nov 18, 2015
4a0b7bc
added edit function for markets
emgord Nov 19, 2015
0c18cb2
added update method for markets
emgord Nov 19, 2015
9f4e218
Half-completed product edit and create method
trowbrsa Nov 19, 2015
d1a5451
Merge branch 'ergsat/master' of github.com:emgord/FarMarRails into er…
trowbrsa Nov 19, 2015
4846775
experimented with nesting routes
emgord Nov 19, 2015
ea5b9f3
Created an edit method for updating vendor products
trowbrsa Nov 19, 2015
ad9fb54
Completed update method for Vendor Products
trowbrsa Nov 19, 2015
e77f334
began working on destroy method
emgord Nov 19, 2015
71d7134
Merge branch 'ergsat/master' of github.com:emgord/FarMarRails into er…
emgord Nov 19, 2015
13c6750
Made adjustments to create method for products but still not fully fu…
trowbrsa Nov 19, 2015
e6d1fff
working on create method for markets
emgord Nov 19, 2015
ca6a658
Merge branch 'ergsat/master' of github.com:emgord/FarMarRails into er…
emgord Nov 19, 2015
44c0e63
Added hidden form to New page to capture params
trowbrsa Nov 19, 2015
fde31bb
Merge branch 'ergsat/master' of github.com:emgord/FarMarRails into er…
trowbrsa Nov 19, 2015
4c8c3e8
added destroy method for products
emgord Nov 19, 2015
2e5351d
finished create method for markets
emgord Nov 19, 2015
e29bbeb
began adding css
emgord Nov 19, 2015
63dcc78
Added 'edit' method for vendors
trowbrsa Nov 19, 2015
d51531c
Added delete method for market vendors
trowbrsa Nov 20, 2015
96c6457
Added create method for vendors on market page
trowbrsa Nov 20, 2015
5f77202
CSS styling
emgord Nov 20, 2015
d7e4649
Merge branch 'ergsat/master' of github.com:emgord/FarMarRails into er…
emgord Nov 20, 2015
0f49816
Incomplete 'new' view for new vendor
trowbrsa Nov 20, 2015
3920686
added css for forms
emgord Nov 20, 2015
410d687
Added ability to add a new vendor as a market
trowbrsa Nov 20, 2015
e81cf40
added styling market detail page
emgord Nov 20, 2015
05236ad
Merge branch 'ergsat/master' of github.com:emgord/FarMarRails into er…
emgord Nov 20, 2015
a9c343d
Created a new view page for general users to view markets
trowbrsa Nov 20, 2015
95ad978
added function to add new sale to a product
emgord Nov 20, 2015
670b146
Added a method to show total sales for a vendor
trowbrsa Nov 20, 2015
4e5abfc
Added method for calculating total sales for current month
trowbrsa Nov 20, 2015
552b56f
Added headers to edit page
trowbrsa Nov 20, 2015
4a19379
added partial for show sales for vendors
emgord Nov 20, 2015
11f5bfd
Added css styling for nav bar
trowbrsa Nov 20, 2015
8c9cb82
Additional css styling
trowbrsa Nov 20, 2015
0598b3c
Merge branch 'ergsat/master' of github.com:emgord/FarMarRails into er…
trowbrsa Nov 20, 2015
672a2bb
styling for vendor page
emgord Nov 20, 2015
2e2cd95
Added nav bar to market pages
trowbrsa Nov 20, 2015
43abbc1
Merge branch 'ergsat/master' of github.com:emgord/FarMarRails into er…
emgord Nov 20, 2015
20e5f57
Added nav link to product page
trowbrsa Nov 20, 2015
3cbb302
Finished nav bars for all pages
trowbrsa Nov 20, 2015
0148e71
Moved SQL to development and added pg gem to production
trowbrsa Nov 20, 2015
b920794
Did a bundle install for gems
trowbrsa Nov 20, 2015
8deb24f
Upgrade spring gem and binstubs
trowbrsa Nov 21, 2015
2c3a31c
fixed some of the nav bars and added some that were missing
emgord Nov 22, 2015
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
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# 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 @@ -46,4 +45,9 @@ group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'pry'
gem 'sqlite3'
end

group :production do
gem 'pg'
end
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ GEM
multi_json (1.11.2)
nokogiri (1.6.6.3)
mini_portile (~> 0.6.0)
pg (0.18.4)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand Down Expand Up @@ -122,7 +123,7 @@ GEM
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
slop (3.6.0)
spring (1.4.3)
spring (1.4.4)
sprockets (3.4.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
Expand Down Expand Up @@ -156,6 +157,7 @@ DEPENDENCIES
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
pg
pry
rails (= 4.2.5)
sass-rails (~> 5.0)
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#Secret Message for Sarah

# FarMar Rails
Build a database backend application to view, create, and manage farmers markets as well as their vendors, products, and sales.
In this implementation we'll be seeding with static data, and also building a tool to allow markets and/or vendors to sign up and add their own data.
Expand Down
Binary file added app/assets/.DS_Store
Binary file not shown.
Binary file added app/assets/images/p-patch.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/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/
142 changes: 142 additions & 0 deletions app/assets/stylesheets/markets.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// 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/

@import url('https://fonts.googleapis.com/css?family=Amatic+SC|Open+Sans');

body {
font-family: 'Open Sans', sans-serif;
background-image: image-url("p-patch.jpg");
background-size: cover;
color: #004d00;
}

a:hover {text-decoration: underline;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch your whitespace and formatting here

}

a {
text-decoration:none;
color: #004d00;
}

nav {
text-align: center;
font-size: 16px;
background-color: #004d00;
border-radius: 5px;
padding: 5px;
}

.nav_link {
color: white;
font-family: 'Open Sans';
}

h1 {
font-family: 'Amatic SC', sans-serif;
text-align: center;
font-size: 3em;
}

div.fade {
width: 700px;
background-color: rgba(255, 255, 255, .75);
margin: 50px auto;
padding: 15px 50px;
border-radius: 10px;
text-align: left;
}

div.button {
display:inline-block;
padding: 40px;
border-radius: 10px;
border-width: medium;
margin: 10px;
margin-bottom: 20px;
text-align: center;

}

div.button > a {
text-decoration: none;
font-family: 'Amatic SC', sans-serif;
color: #ffffff;
font-weight: bold;
font-size: 2em;
}

div.button > a:hover {
font-size: 250%;
}

div.center{
text-align: center;
}

div.show_sales {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For CSS styles that are multiple words, standards state that we should separate with the - rather than the _

display:inline-block;
padding: 20px;
border-width: medium;
border-radius: 10px;
margin: 10px;
text-align: center;
background-color: rgba(184, 184, 148, .75)
}

li {
line-height: 150%;
}



.market_button {
background-color: rgba(41, 41, 163, .75);
}

.vendor_button{
background-color: rgba(0, 102, 34, .75);

}

.edit {
color: #392613;
}

.delete {
color: #cc3300;
}

form {
margin: auto;
padding: 0px 50px 0px 50px;
line-height: 200%;
}

fieldset {
padding-bottom: 20px;
border: 0;
}

legend {
padding: 10px;
}

label {
margin-left: 10px;
}

input {
border: none;
border-glow: none;
background-color: rgba(0, 102, 34, .4);
outline: none;
padding: 5px;
font-size: 1.05em;
border-radius: 5px;
margin: 10px;
}

.submit_button {
font-family: 'Open Sans'
}
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/
57 changes: 57 additions & 0 deletions app/controllers/markets_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
class MarketsController < ApplicationController

def home
@markets = Market.all
end

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

def index
@is_a_market = true
@markets = Market.all
end

def edit
id = params[:id]
@market= Market.find(id)
@title = "Edit Market"
@action = :update
end

def update
Market.update(params[:id], market_params[:market] )
redirect_to market_path(params[:id])
end

def new
id = params[:id]
@market= Market.new
@title = "Create a Market"
@action = :create
end

def view

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why this method is a duplicate for show?

show
end

def create
a = Market.create( market_params[:market] )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend updating to use a more meaningful variable name rather than a

redirect_to market_path(a.id)
end

def destroy
Market.destroy(params[:id])
redirect_to markets_path

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of the named routes in this controller!

end

private

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

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

def new
@product = Product.new
end

def edit
id = params[:id]
@product = Product.find(id)
@title = "Edit Product"
@action = :update
end

def update
id = params[:id]
product = Product.find(id)
vendor_id = product.vendor_id
Product.update(params[:id], product_params[:product])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a local variable for the id that should be used instead of params[:id]

redirect_to vendor_path(vendor_id)
end

def create
Product.create(product_params[:product])
redirect_to vendor_path(params[:vendor_id])
end

def destroy
Product.destroy(params[:id])
redirect_to vendor_path(params[:vendor_id])
end

def show
@product = Product.find(params[:id])
@sales = @product.sales

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can access the sales from the Product so it seems like you don't need this additional instance variable

end

private

def product_params
params.permit(product:[:id, :name, :vendor_id])
end


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

def new
@sale = Sale.new
end

def create
a = Sale.create(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment re: variable naming with a meaningful name

:amount => ((sale_params[:sale][:amount]).to_i * 100),
:purchase_time => sale_params[:sale][:purchase_time],
:vendor_id => sale_params[:sale][:vendor_id],
:product_id => sale_params[:sale][:product_id],

)
redirect_to vendor_product_path(a.vendor_id, a.product_id)
end

private

def sale_params
params.permit(sale:[:amount, :purchase_time, :vendor_id, :product_id])
end


end
Loading