Skip to content
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
fa7b1f6
Set up db tables for each model.
brookseakate Oct 4, 2016
00ae28b
Added relationships to models.
brookseakate Oct 4, 2016
2d92713
fixed sale_id to product_id in sales table
wordkarin Oct 4, 2016
1ce1751
set up basic /markets #index action and view
wordkarin Oct 4, 2016
2584628
created markets#show action and view
wordkarin Oct 4, 2016
5d5e487
Added link between markets#index & markets#show
brookseakate Oct 4, 2016
3843ea6
added seed for generating market from csv
wordkarin Oct 5, 2016
76d4069
to do note for seeding markets
wordkarin Oct 5, 2016
f0d22ba
added seed for vendors from csv
wordkarin Oct 5, 2016
b48c66e
added seeds for products and sales
wordkarin Oct 5, 2016
076bc65
nested vendor and market routes
wordkarin Oct 5, 2016
790643a
Updated routes to include Sale, & Product routes.
brookseakate Oct 5, 2016
2b64f77
added vendor controller and view
wordkarin Oct 5, 2016
4a218b6
added button to add new product from vendor
wordkarin Oct 5, 2016
7da2700
Added controller actions and form (partial), new, & edit views
brookseakate Oct 5, 2016
46c73ad
Created form partial, edit, & new
brookseakate Oct 5, 2016
4d290ea
Merge branch 'master' of https://github.com/wordkarin/FarMarRails
wordkarin Oct 5, 2016
cbfb9f7
Added link to Vendor page from Market page
brookseakate Oct 5, 2016
59537ee
Built form & vendor actions to add new vendor from a market page.
brookseakate Oct 6, 2016
5416c99
Added edit/update form and action for Vendor from Market page
brookseakate Oct 6, 2016
ab4a6b0
Added button links to forms: on Market page, 'Add New Market'. On Ven…
brookseakate Oct 6, 2016
82327b0
Updated file path of vendor form, minor updates to views.
brookseakate Oct 6, 2016
a1be0af
Added vendor#destroy action & button on Vendor show page
brookseakate Oct 6, 2016
18ce0f9
added a site controller and an index view for the root path
wordkarin Oct 6, 2016
3444e14
Merge branch 'master' of https://github.com/wordkarin/FarMarRails
brookseakate Oct 6, 2016
d9d6761
Generated products controller.
brookseakate Oct 6, 2016
8f63c07
added market and vendor portal pages (static)
wordkarin Oct 6, 2016
398849f
updated options for vendor portal
wordkarin Oct 6, 2016
82f455c
vendor portal update
wordkarin Oct 6, 2016
cea48f7
Restricted product show route.
brookseakate Oct 6, 2016
711f6f2
Merge branch 'kate-change-products'
brookseakate Oct 6, 2016
f5ee77c
Updated 'Add New Product' button to specify get method.
brookseakate Oct 6, 2016
cb5c582
Built new/create functionality & form partial.
brookseakate Oct 6, 2016
a9ac8a3
set up sales#index page with table displaying sales for that vendor
wordkarin Oct 6, 2016
1c0107c
Built edit/update functionality & view.
brookseakate Oct 6, 2016
1430bed
Built destroy functionality. Updated Vendor show page to list product…
brookseakate Oct 6, 2016
08822a9
Merge branch 'kate-change-products'
brookseakate Oct 6, 2016
8cf9eaa
added a helper method for sale to calculate total sales
wordkarin Oct 6, 2016
1ab32f5
Added list of vendors to vendor_portal page
brookseakate Oct 6, 2016
74371e1
Merge branch 'kate-vendor-portal-list'
brookseakate Oct 6, 2016
3ac118d
Added button to Vendor page: 'Add a Sale'. Re-ordered flow of page.
brookseakate Oct 6, 2016
fc9f8db
refactored total_sale to take argument, added current_sales variable
wordkarin Oct 7, 2016
ff0e698
First draft of Sale form
brookseakate Oct 7, 2016
87e3980
Merging branch 'kate-create-sale' work-in-progress -- in order to acc…
brookseakate Oct 7, 2016
7e81427
Finished building new/create functionality & view for Sale.
brookseakate Oct 7, 2016
aec22b8
First draft of global styling: google fonts, color palette. Essential…
brookseakate Oct 7, 2016
9621ebc
Merge pull request #1 from wordkarin/kate-styling
wordkarin Oct 7, 2016
e0236a6
updated layout to add header and footer, centered everything
wordkarin Oct 7, 2016
5199cf9
updated headers and selections from index
wordkarin Oct 7, 2016
8a5d42b
updated product form to follow same format as other forms with <li>
wordkarin Oct 7, 2016
cd07a18
added link to vendor from sales page
wordkarin Oct 7, 2016
26c3981
added button to edit to market, updated display of address information
wordkarin Oct 7, 2016
71fc56d
button/form field styling, plus added a heading on Markets list page
brookseakate Oct 7, 2016
1d17ded
Merge pull request #2 from wordkarin/kate-styling
wordkarin Oct 7, 2016
ac146fa
removed #sale_product_id from application.scss
wordkarin Oct 7, 2016
067bfd2
removed routes we're not using
wordkarin Oct 7, 2016
da3b62c
moved styles from markets to application so that vendor can use, adde…
wordkarin Oct 7, 2016
a4d1134
redirect_to after updating vendor goes to vendor page now
wordkarin Oct 7, 2016
bb48f6e
added logic to sales tables to display a message if no sales, created…
wordkarin 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
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'graphviz'

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

Expand All @@ -43,5 +45,6 @@ group :development do

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

gem 'rails-erd'
end
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ GEM
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (9.0.6)
choice (0.2.0)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
Expand All @@ -54,6 +55,7 @@ GEM
execjs (2.7.0)
globalid (0.3.7)
activesupport (>= 4.1.0)
graphviz (0.3.0)
i18n (0.7.0)
jbuilder (2.6.0)
activesupport (>= 3.0.0, < 5.1)
Expand Down Expand Up @@ -95,6 +97,11 @@ GEM
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-erd (1.5.0)
activerecord (>= 3.2)
activesupport (>= 3.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.7)
Expand All @@ -105,6 +112,7 @@ GEM
rake (11.3.0)
rdoc (4.2.2)
json (~> 1.4)
ruby-graphviz (1.2.2)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
Expand Down Expand Up @@ -147,9 +155,11 @@ PLATFORMS
DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
graphviz
jbuilder (~> 2.0)
jquery-rails
rails (= 4.2.7)
rails-erd
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
Expand Down
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/site.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/
105 changes: 105 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,108 @@
*= require_tree .
*= require_self
*/
html {
background-color: #5DA399;
font-family: 'Lato', sans-serif;
color: #FFFFFF;
}

header {
display: inline-block;
width: 100%;
/*background-color: teal;*/
background-color: #114B5F;
}

h1, h2, h3, h4, th {
text-align: center;
padding: 10px;
background-color: #114B5F;
color: #FFFFFF;
font-family: 'Acme', sans-serif;
}

nav h1 {
/*padding: 40px 0px 0px 60px;*/
font-size: 3em;
font-weight: lighter;
margin-bottom: 0px;
text-align: center
}

nav h2 {
margin-top: 0px;
font-size: 2em;
font-weight: lighter;
}

ul, .button_to {
text-align: center;
list-style: none;
padding: 0px;
}

/*centering the forms on the pages*/
form {
width: 60%;
margin-right: 20%;
margin-left: 20%;
}

/*line up the text boxes by text-aligning right*/
form ul li {
text-align: right;
width: 60%;
margin-right: 40%;
}

nav ul li {
font-weight: lighter;
font-family: 'Acme', sans-serif;
display: inline-block;
padding: 20px;
}

/*Nav links need to be a different color because the background is darker*/
nav a, h3 a, h2 a {
color: #0099ad;
}

a {
text-decoration: none;
color: #016572;
}

/*The link hover color works well for both the main page background and the nav backgroung*/
a:hover {
color: #BACEB7;
}

input {
background-color: #016572;
color: #FFFFFF;
border: 0px transparent;
border-radius: 5px;
padding: 5px;
margin: 2px;
}

.main-display {
background-color: #114B5F;
text-align: center;
color: white;
}

.main-display h5{
padding-bottom: 10px;
margin-top: 0px;
margin-bottom: 0px;
}

.main-display h2 {
margin-bottom: 0px;
}

.main-display form {
padding-bottom: 10px;
}
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 Market 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/
17 changes: 17 additions & 0 deletions app/assets/stylesheets/sales.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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/

// table {
// border: white thin solid;
// }

table {
width:60%;
margin-left:20%;
margin-right:20%;
}

td {
text-align: center;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/site.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the site 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/
49 changes: 49 additions & 0 deletions app/controllers/markets_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class MarketsController < ApplicationController
def index
@markets = Market.all.order(:name)
end #index

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

def new
@market = Market.new
end #new

def create
@market = Market.new(market_params)

if @market.save
redirect_to market_path(@market)
else
render :new
end
end #create

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

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

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

def destroy
@market = Market.find(params[:id])
@market.destroy
redirect_to markets_path
end

private

def market_params
params.require(:market).permit(:name, :street_address, :city, :county, :state, :zip_code)
end
end
46 changes: 46 additions & 0 deletions app/controllers/products_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class ProductsController < ApplicationController
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(product_params)
redirect_to market_vendor_path(market_id: @vendor.market_id, id: @vendor.id)
else
render :edit
end
end

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

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

if @product.update(product_params)
redirect_to market_vendor_path(market_id: @vendor.market_id, id: @vendor.id)
else
render :edit
end
end

def destroy
@vendor = Vendor.find(params[:vendor_id])
@product = @vendor.products.find(params[:id])
@product.destroy
redirect_to market_vendor_path(market_id: @vendor.market_id, id: @vendor.id)
end

private

def product_params
params.require(:product).permit(:name)
end
end
41 changes: 41 additions & 0 deletions app/controllers/sales_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class SalesController < ApplicationController
def index
@vendor = Vendor.find(params[:vendor_id])
@sales = @vendor.sales

@current_sales = @sales.where(purchase_time: (1.month.ago)...DateTime.now)
# current sales is supposed to be "this month", and what it's currently doing is the sales from a month ago up to now (so not restricted on THIS month)
end

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

@sale.purchase_time = DateTime.now

# @todo - refactor opportunity; move this logic into Sale model?
@products_selection_array = []
@vendor.products.each do |product|
@products_selection_array << [product.name, product.id]
end
end # new

def create
@vendor = Vendor.find(params[:vendor_id])
@sale = Sale.new(sale_params)

@sale.vendor_id = @vendor.id

if @sale.save
redirect_to market_vendor_sales_path(market_id: @vendor.market_id, vendor_id: @vendor.id)
else
render :new
end
end # create

private

def sale_params
params.require(:sale).permit(:product_id, :amount, :purchase_time)
end
end
11 changes: 11 additions & 0 deletions app/controllers/site_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class SiteController < ApplicationController
def index
end

def market_portal
end

def vendor_portal
@vendors = Vendor.all.order(:name)
end
end
Loading