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

completed requirements plus some extras #12

Open
wants to merge 101 commits into
base: jbkd/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
090634d
Added relationship between models and required fields
kdefliese Nov 18, 2015
1563530
add market to seed.rb
jbuechs Nov 18, 2015
5be829e
Seeded vendors table
kdefliese Nov 18, 2015
e87afb8
create product model and controller
jbuechs Nov 18, 2015
30a4e47
Create Sale model and controller, added relationships to Sale model
kdefliese Nov 18, 2015
efdd637
Merge branch 'jbkd/master' of github.com:jbuechs/FarMarRails into jbk…
kdefliese Nov 18, 2015
7f95f5c
Added relationships to Product model
kdefliese Nov 18, 2015
4c76560
add has_many products to vendor
jbuechs Nov 18, 2015
fdbca95
create seed for vendor
jbuechs Nov 18, 2015
15a9b8e
Seeded Sale and added has_many sales to Vendor
kdefliese Nov 18, 2015
5d53381
create routes and method stubs for all controllers
jbuechs Nov 18, 2015
3978b6e
Merge branch 'jbkd/master' of github.com:jbuechs/FarMarRails into jbk…
jbuechs Nov 18, 2015
f8f679a
add static page homepage
jbuechs Nov 18, 2015
f2d54a0
Created CRUD controller methods for Markets
kdefliese Nov 18, 2015
99ba33f
integrate bootstrap
jbuechs Nov 18, 2015
144fc89
create blank index.html pages for markets and products
jbuechs Nov 18, 2015
a734d26
Created index erbs for vendor and sale
kdefliese Nov 18, 2015
041812a
Merge branch 'jbkd/master' of github.com:jbuechs/FarMarRails into jbk…
kdefliese Nov 18, 2015
b8d8e4d
Added basic skeleton for market pages
kdefliese Nov 18, 2015
6412d59
Verified all market controller actions
kdefliese Nov 18, 2015
d21271c
Added market details to show page
kdefliese Nov 18, 2015
e86b601
Added vendor controller methods
kdefliese Nov 18, 2015
17a6be6
Added basic skeleton for vendor pages, verified vendor controller met…
kdefliese Nov 18, 2015
cc898cd
Updated routes to remove vendor redundancies
kdefliese Nov 18, 2015
de245b3
style homepage - still needs work
jbuechs Nov 18, 2015
0a1b276
add header for vendors and markets
jbuechs Nov 18, 2015
cbac173
create links for logging in on homepage
jbuechs Nov 18, 2015
728654b
update market and vendor headers
jbuechs Nov 18, 2015
25ac4c9
create login page for vendor
jbuechs Nov 18, 2015
2da03ed
Added basic skeleton for products and verified controller methods
kdefliese Nov 19, 2015
b59bc1e
Merge branch 'jbkd/master' of github.com:jbuechs/FarMarRails into jbk…
kdefliese Nov 19, 2015
c46b678
create session for logging in as vendor
jbuechs Nov 19, 2015
26e8bc8
bugfix links on the vendor header
jbuechs Nov 19, 2015
83a04a8
fix styling for navbar
jbuechs Nov 19, 2015
935d2c1
add jumbotron
jbuechs Nov 19, 2015
99f8d47
format form for vendor login
jbuechs Nov 19, 2015
375a1dd
add jumbotron and broken parallax scrolling
jbuechs Nov 19, 2015
66d0517
merge with sessions-test branch
jbuechs Nov 19, 2015
cbe1ab0
auto login when a vendor is already logged in
jbuechs Nov 19, 2015
c2e8444
bugfix of jumbotron parallax scrolling
jbuechs Nov 19, 2015
7d79755
add error page for vendor accessing another vendor
jbuechs Nov 19, 2015
6aab5b1
bugfix render market header for vendor create and view
jbuechs Nov 19, 2015
0e1be50
change vendor header
jbuechs Nov 19, 2015
1a36bba
edit new product form for vendor
jbuechs Nov 19, 2015
58082a5
Created sales list and total sales per vendor
kdefliese Nov 19, 2015
fedd7f4
format table for showing all markets
jbuechs Nov 19, 2015
84a5bac
change sale seed to have random dates
jbuechs Nov 19, 2015
407b085
Merge branch 'jbkd/master' of github.com:jbuechs/FarMarRails into jbk…
kdefliese Nov 19, 2015
1cee12b
format view vendor products table
jbuechs Nov 19, 2015
0a2dfdb
change home link on vendor header
jbuechs Nov 19, 2015
6404e6c
format show all vendors page
jbuechs Nov 19, 2015
3ac48df
create form for creating new sale
jbuechs Nov 19, 2015
97d0c9e
Sale by month not working yet
kdefliese Nov 19, 2015
a6a6936
Merged, changed sales controller
kdefliese Nov 19, 2015
52b40bf
reformat new sale form
jbuechs Nov 19, 2015
0b49409
format show all vendor sales page
jbuechs Nov 19, 2015
e4c2560
add date and time to sales output
jbuechs Nov 19, 2015
e31c114
fix adding sale as a vendor
jbuechs Nov 19, 2015
f784776
change vendor header to include months
jbuechs Nov 19, 2015
2193929
Added month id to sales/month route
kdefliese Nov 19, 2015
fd804ee
Merge branch 'jbkd/master' of github.com:jbuechs/FarMarRails into jbk…
kdefliese Nov 19, 2015
645a5ff
fix rounding error in vendor sales list
jbuechs Nov 19, 2015
cd17a7c
add all months to the sales dropdown menu
jbuechs Nov 19, 2015
b203708
Sales by month now works
kdefliese Nov 19, 2015
48db4d9
Merge branch 'jbkd/master' of github.com:jbuechs/FarMarRails into jbk…
kdefliese Nov 19, 2015
28eda78
reformat new sale form to take dollars and cents
jbuechs Nov 19, 2015
994b468
Merge branch 'jbkd/master' of github.com:jbuechs/FarMarRails into jbk…
jbuechs Nov 19, 2015
5d938c0
Changed create vendor form to use a dropdown of markets instead of ID
kdefliese Nov 19, 2015
494e8e1
Fixed merge conflict, git is picky
kdefliese Nov 19, 2015
126ff93
edit vendor form dropdown
jbuechs Nov 20, 2015
36a32ab
Added destroy route for sales
kdefliese Nov 20, 2015
1abddb0
format color and font of h1
jbuechs Nov 20, 2015
18feb22
change body font
jbuechs Nov 20, 2015
968a80c
Added ability to delete sales
kdefliese Nov 20, 2015
8fbb4a9
Merge branch 'jbkd/master' of github.com:jbuechs/FarMarRails into jbk…
kdefliese Nov 20, 2015
d63d246
validate inputs for forms
jbuechs Nov 20, 2015
46a0bd9
Updated spring version in Gemfile
kdefliese Nov 20, 2015
aab2d6f
Ran bundle install
kdefliese Nov 20, 2015
302a07a
Added ruby version
kdefliese Nov 20, 2015
f0c40c3
update bin files
jbuechs Nov 20, 2015
3d8f3e7
resize header file for performance optimization
jbuechs Nov 20, 2015
cdb0b16
Added search for market by name
kdefliese Nov 20, 2015
84111c4
refactor logging in as market and rendering headers
jbuechs Nov 20, 2015
d6ffbfc
merge
jbuechs Nov 20, 2015
8d352b6
refactor layout and fix homepage search bar
jbuechs Nov 20, 2015
ad0e66a
Added error message for market search when there are no results
kdefliese Nov 20, 2015
f17db49
merge
kdefliese Nov 20, 2015
d4ddca2
fix parallax but need to tweak
jbuechs Nov 20, 2015
4fba312
Changed sales header to reflect month
kdefliese Nov 20, 2015
ef03c91
fixed parallax jank
jbuechs Nov 20, 2015
0ed6531
merge parallax branch
jbuechs Nov 20, 2015
b7ede7a
add charles code to seeds file
jbuechs Nov 20, 2015
054c0b5
refactor markets controller to have before action
jbuechs Nov 24, 2015
7990bb4
refactor market search to be a market model method
jbuechs Nov 24, 2015
ed6d9da
remove unneccessary instance variables from products index method
jbuechs Nov 24, 2015
0b1ac8e
change product create redirect to named path
jbuechs Nov 24, 2015
348c3bd
refactor products controller and delete all sales when product is del…
jbuechs Nov 24, 2015
a0ae3c4
make month_hash constant
jbuechs Nov 24, 2015
4e571ef
add edit button to vendors header
jbuechs Nov 24, 2015
517f594
refactor vendors controller to use before action
jbuechs Nov 24, 2015
7d1c46c
add mac files to gitignore
jbuechs Nov 24, 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
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'

ruby "2.2.3"

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
Expand All @@ -22,6 +22,9 @@ gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Include Bootstrap
gem 'bootstrap-sass', '~> 3.3.5'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

Expand Down
9 changes: 8 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ GEM
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
autoprefixer-rails (6.1.0.1)
execjs
json
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)
bootstrap-sass (3.3.5.1)
autoprefixer-rails (>= 5.0.0.1)
sass (>= 3.3.0)
builder (3.2.2)
byebug (8.2.0)
coderay (1.1.0)
Expand Down Expand Up @@ -117,7 +123,7 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
spring (1.4.3)
spring (1.3.6)
sprockets (3.4.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
Expand Down Expand Up @@ -147,6 +153,7 @@ PLATFORMS
DEPENDENCIES
better_errors
binding_of_caller
bootstrap-sass (~> 3.3.5)
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
Expand Down
Binary file added app/assets/images/.DS_Store
Binary file not shown.
Binary file added app/assets/images/market.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/market2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// about supported directives.
//
//= require jquery
//= require bootstrap-sprockets
//= require jquery_ujs
//= require turbolinks
//= require_tree .
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/sessions.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/static_pages.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/
15 changes: 0 additions & 15 deletions app/assets/stylesheets/application.css

This file was deleted.

136 changes: 136 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*/

// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";
@import url(https://fonts.googleapis.com/css?family=Bitter:700);
@import url(https://fonts.googleapis.com/css?family=Lato);

$purple: rgb(80, 48, 90);
$yellow: rgb(227, 230, 61);
$orange: rgb(231, 110, 38);

$jumbo-height: 350px;
$title-font: 'Bitter', serif;
$body-font: 'Lato', sans-serif;

.navbar-inverse {
background-color: $purple;
}
.navbar-inverse .navbar-nav > li > a,
.btn,
.btn-primary
{
background-color: $purple;
font-size: 1.2em;
color: $yellow;
font-weight: bold;
transition: all 0.5s ease-out;
&:hover,
&:active {
background-color: $yellow;
color: $purple;
transition: all 0.2s ease-out;
}
}

.navbar-inverse .navbar-nav > .open > a,
.navbar-inverse .navbar-nav > .open > a:hover,
.navbar-inverse .navbar-nav > .open > a:focus {
background-color: $yellow;
color: $purple;
transition: all 0.2s ease-out;
}


#logo {
float: left;
margin-right: 10px;
font-size: 1.7em;
color: $yellow;
letter-spacing: -1px;
padding-top: 9px;
font-weight: bold;
&:hover {
color: $yellow;
text-decoration: none;
}
}

.jumbotron {
height: $jumbo-height;
color: $yellow;
text-shadow: #444 1px 2px 1px;
background:transparent;
padding-top: 70px;
h1{
color: $yellow;
font-size: 5em;
}
}

h1 {
font-family: $title-font;
}

.centered-block {
margin: auto;
}

.centered-button {
margin-top: 20vh;
}

thead {
font-size: 1.3em;
font-weight: bold;
}

.table-color {
border-collapse:collapse;
border:2px solid $purple;
thead {
background: $yellow;
}
}

body {
font-family: $body-font;
}

// Parallax code from http://www.cssscript.com/simple-parallax-scrolling-effect-pure-css3/
// Parallax necessary CSS
.parallax {
height: 100vh;
overflow-x: hidden;
overflow-y: auto;
perspective: 1px;
-webkit-perspective: 1px;
}
.parallax_layer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.parallax_layer_base {
transform: translateZ(0);
-webkit-transform: translateZ(0);
}
.parallax_layer_back {
-webkit-transform: translateZ(-1px);
transform: translateZ(-0.5px) scale(2);
}
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/sessions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Sessions 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/static_pages.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the static_pages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
include SessionsHelper
end
56 changes: 56 additions & 0 deletions app/controllers/markets_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
class MarketsController < ApplicationController

def index
@markets = Market.all
end

def new
@market = Market.new
end

def create
Market.create(market_params[:market])
redirect_to "/markets"
end

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

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

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

Choose a reason for hiding this comment

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

It would be great to see some refactoring of the id and @market variables to use a before_action

@market.update(
name: market_params[:market][:name],
address: market_params[:market][:address],
city: market_params[:market][:city],
county: market_params[:market][:county],
state: market_params[:market][:state],
zip: market_params[:market][:zip]
)
redirect_to "/markets"
end

def destroy
id = params[:id]
Market.destroy(id)
redirect_to "/markets"
end

def search
@markets = Market.where("name LIKE ?" , params[:search_term])

Choose a reason for hiding this comment

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

It seems like it may be better to have this LIKE logic in a model method rather than a controller method

render :index
end

private

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

end
56 changes: 56 additions & 0 deletions app/controllers/products_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
class ProductsController < ApplicationController
def index
@vendor_id = params[:vendor_id]

Choose a reason for hiding this comment

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

Do @vendor_id and @id need to be instance variables? It seems like the view is only using @products so these two variables should be local variables

@id = params[:id]
@products = Vendor.find(@vendor_id).products
end

def new
@product = Product.new
@url_path = vendor_products_path
end

def create
vendor_id = params[:vendor_id]
Product.create(
name: product_params[:product][:name],
vendor_id: session[:vendor_id])
redirect_to "/vendors/#{vendor_id}/products"

Choose a reason for hiding this comment

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

It is better to use a named path rather than the URL itself. Is there a named path for this route that you could use instead?

end

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

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

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

Choose a reason for hiding this comment

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

I'm wondering if this update works because the vendor_id is not in the product_params

)
redirect_to "/vendors/#{vendor_id}/products/#{id}"
end

def destroy
@id = params[:id]
@vendor_id = params[:vendor_id]

Choose a reason for hiding this comment

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

Same question re: instance variables vs local variables

Product.destroy(@id)
redirect_to "/vendors/#{@vendor_id}/products"
end

private

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

end
Loading