From dc06b18f9bf0bc8d182ce47672a398a5faf68ff0 Mon Sep 17 00:00:00 2001 From: Fay AlQassar Date: Tue, 28 Nov 2017 20:46:41 +0000 Subject: [PATCH 01/13] Made /dishes dishes link to each dish --- app/views/dishes/index.html.erb | 9 ++++++++- whitelist.yml | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/views/dishes/index.html.erb b/app/views/dishes/index.html.erb index bc51992..1fd5fcd 100644 --- a/app/views/dishes/index.html.erb +++ b/app/views/dishes/index.html.erb @@ -94,7 +94,14 @@ <% @dishes.each do |dish| %> - <%= dish.name %> + + + <% if dish.name.present? %> + + <%= dish.name %> + + <% end %> + <% if dish.cuisine.present? %> diff --git a/whitelist.yml b/whitelist.yml index ab11e34..5cc6b9f 100644 --- a/whitelist.yml +++ b/whitelist.yml @@ -2,3 +2,4 @@ - 127.0.0.1 - 10.240.0.0/16 - "::1" +- 192.157.77.90 From b910ad6518a973318c6ad048a2a8bd5c82064362 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 2 Dec 2017 20:21:45 +0000 Subject: [PATCH 02/13] Homepage load fix Homepage loads the /dishes page --- config/routes.rb | 3 ++- grades.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 6f92ce5..b756f1b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ Rails.application.routes.draw do - root :to => "venues#index" + # Routes for Homepage link to /dishes: + root "dishes#index" # Routes for the Bookmark resource: # CREATE diff --git a/grades.yml b/grades.yml index 2f40b8d..3b67b4f 100644 --- a/grades.yml +++ b/grades.yml @@ -1,4 +1,4 @@ --- submission_url: https://grades.firstdraft.com project_token: '' -personal_access_token: +personal_access_token: YMhoFUZydkV3ShNpanUydTYz From 7f6e32d1a536684c459fd2ce2f13aa483d8b1a28 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 3 Dec 2017 20:32:54 +0000 Subject: [PATCH 03/13] /dishes displays venue for each dish Homepage and /dishes displays venue for each dish --- app/controllers/dishes_controller.rb | 1 - app/models/dish.rb | 2 ++ app/views/dishes/index.html.erb | 14 ++++++++++++-- config/routes.rb | 2 +- whitelist.yml | 2 ++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/controllers/dishes_controller.rb b/app/controllers/dishes_controller.rb index 84facab..56eb35f 100644 --- a/app/controllers/dishes_controller.rb +++ b/app/controllers/dishes_controller.rb @@ -2,7 +2,6 @@ class DishesController < ApplicationController def index @q = Dish.ransack(params[:q]) @dishes = @q.result(:distinct => true).includes(:cuisine, :bookmarks, :fans, :specialists).page(params[:page]).per(10) - render("dishes/index.html.erb") end diff --git a/app/models/dish.rb b/app/models/dish.rb index c435ea1..f7d5926 100644 --- a/app/models/dish.rb +++ b/app/models/dish.rb @@ -9,6 +9,7 @@ class Dish < ApplicationRecord # Indirect associations + has_many :specialists, :through => :bookmarks, :source => :venue @@ -17,6 +18,7 @@ class Dish < ApplicationRecord :through => :bookmarks, :source => :user + # Validations validates :name, :uniqueness => { :case_sensitive => false } diff --git a/app/views/dishes/index.html.erb b/app/views/dishes/index.html.erb index 1fd5fcd..5e0d1bf 100644 --- a/app/views/dishes/index.html.erb +++ b/app/views/dishes/index.html.erb @@ -89,12 +89,12 @@ Name Cuisine + Venue Actions <% @dishes.each do |dish| %> - <% if dish.name.present? %> @@ -109,6 +109,16 @@ <% end %> + + <% if dish.specialists.present? %> + <% dish.specialists.each do |venue| %> + + <%= venue.name %> + + <% end %> + <% end %> + + Show Edit @@ -119,4 +129,4 @@ <%= paginate @dishes, theme: 'twitter-bootstrap-4' %> - + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index b756f1b..f2ef964 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do - # Routes for Homepage link to /dishes: + # Routes for Homepage link to /dishes page: root "dishes#index" # Routes for the Bookmark resource: diff --git a/whitelist.yml b/whitelist.yml index 5cc6b9f..85b60ff 100644 --- a/whitelist.yml +++ b/whitelist.yml @@ -3,3 +3,5 @@ - 10.240.0.0/16 - "::1" - 192.157.77.90 +- 128.135.98.68 +- 141.117.117.96 From 1fda898344e4812a8993402f6e41b774fa048106 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 3 Dec 2017 22:23:12 +0000 Subject: [PATCH 04/13] User Story 7 - /venues filters venue by dish User Story 7 - /venues filters venue by dish --- app/views/venues/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/venues/index.html.erb b/app/views/venues/index.html.erb index 169f95b..f7f53d9 100644 --- a/app/views/venues/index.html.erb +++ b/app/views/venues/index.html.erb @@ -54,7 +54,7 @@
- <%= f.label :bookmarks_notes_cont, "Bookmark notes contains" %> + <%= f.label :bookmarks_notes_cont, "Bookmarked notes contains" %> <%= f.text_field :bookmarks_notes_cont, :class => "form-control", :placeholder => "Bookmark notes contains" %>
@@ -69,7 +69,7 @@
- <%= f.label :specialties_name_cont, "Dish name contains" %> + <%= f.label :specialties_name_cont, "Bookmarked dish name contains" %> <%= f.text_field :specialties_name_cont, :class => "form-control", :placeholder => "Dish name contains" %>
From d5450836847a4fe543d83574fd636b9bbda54596 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 5 Dec 2017 03:38:56 +0000 Subject: [PATCH 05/13] New Venue Button --- app/views/dishes/index.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/dishes/index.html.erb b/app/views/dishes/index.html.erb index 5e0d1bf..744578f 100644 --- a/app/views/dishes/index.html.erb +++ b/app/views/dishes/index.html.erb @@ -127,6 +127,7 @@ <% end %> + New Venue <%= paginate @dishes, theme: 'twitter-bootstrap-4' %> \ No newline at end of file From ee4c0e16ae50b9510bfcaa84484316ec555d7ad7 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 5 Dec 2017 04:00:14 +0000 Subject: [PATCH 06/13] Cuisine checkbox update --- app/views/dishes/index.html.erb | 14 ++++++++++---- whitelist.yml | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/views/dishes/index.html.erb b/app/views/dishes/index.html.erb index 744578f..795d821 100644 --- a/app/views/dishes/index.html.erb +++ b/app/views/dishes/index.html.erb @@ -53,10 +53,16 @@ }); -
- <%= f.label :cuisine_name_cont, "Cuisine name contains" %> - <%= f.text_field :cuisine_name_cont, :class => "form-control", :placeholder => "Cuisine name contains" %> -
+ +
+ <%= "Cuisines" %> + <% Cuisine.all.each do |cuisine| %> + + <% end %> +
<%= f.label :bookmarks_notes_cont, "Bookmark notes contains" %> diff --git a/whitelist.yml b/whitelist.yml index 85b60ff..baa1f97 100644 --- a/whitelist.yml +++ b/whitelist.yml @@ -5,3 +5,4 @@ - 192.157.77.90 - 128.135.98.68 - 141.117.117.96 +- 104.234.44.158 From 3cca9f722ae76b0e8c490d9db983219c1f7762c2 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 5 Dec 2017 05:46:15 +0000 Subject: [PATCH 07/13] Select tag drop down --- app/controllers/dishes_controller.rb | 3 +++ app/views/dishes/index.html.erb | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/dishes_controller.rb b/app/controllers/dishes_controller.rb index 56eb35f..3a492bd 100644 --- a/app/controllers/dishes_controller.rb +++ b/app/controllers/dishes_controller.rb @@ -3,6 +3,9 @@ def index @q = Dish.ransack(params[:q]) @dishes = @q.result(:distinct => true).includes(:cuisine, :bookmarks, :fans, :specialists).page(params[:page]).per(10) render("dishes/index.html.erb") + + + end def show diff --git a/app/views/dishes/index.html.erb b/app/views/dishes/index.html.erb index 795d821..48014ea 100644 --- a/app/views/dishes/index.html.erb +++ b/app/views/dishes/index.html.erb @@ -117,11 +117,7 @@ <% if dish.specialists.present? %> - <% dish.specialists.each do |venue| %> - - <%= venue.name %> - - <% end %> + <%= select_tag(:venue_id, options_from_collection_for_select(Venue.all, :id, :name, dish.specialists), :class => "form-control") %> <% end %> From cbb9fd6ea41bdd20c779285f4f549186c730a810 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 5 Dec 2017 18:51:56 +0000 Subject: [PATCH 08/13] /venues lists signed in user's bookmarked venues --- app/controllers/dishes_controller.rb | 26 +++++++++++++++++++++++--- app/controllers/venues_controller.rb | 3 ++- app/models/dish.rb | 2 +- app/views/dishes/index.html.erb | 5 +---- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/controllers/dishes_controller.rb b/app/controllers/dishes_controller.rb index 3a492bd..a77dd87 100644 --- a/app/controllers/dishes_controller.rb +++ b/app/controllers/dishes_controller.rb @@ -2,12 +2,32 @@ class DishesController < ApplicationController def index @q = Dish.ransack(params[:q]) @dishes = @q.result(:distinct => true).includes(:cuisine, :bookmarks, :fans, :specialists).page(params[:page]).per(10) - render("dishes/index.html.erb") - - + @bookmark = Bookmark.new + + + @bookmark.dish_id = params[:dish_id] + @bookmark.venue_id = params[:venue_id] + @bookmark.user_id = params[:user_id] + @bookmark.notes = params[:notes] + + save_status = @bookmark.save + + if save_status == true + referer = URI(request.referer).path + + case referer + when "/bookmarks/new", "/create_bookmark" + redirect_to("/bookmarks") + else + redirect_back(:fallback_location => "/", :notice => "Bookmark created successfully.") + end + end + + render("dishes/index.html.erb") end + def show @bookmark = Bookmark.new @dish = Dish.find(params[:id]) diff --git a/app/controllers/venues_controller.rb b/app/controllers/venues_controller.rb index c368d81..6071810 100644 --- a/app/controllers/venues_controller.rb +++ b/app/controllers/venues_controller.rb @@ -1,6 +1,7 @@ class VenuesController < ApplicationController def index - @q = Venue.ransack(params[:q]) + @user_venue=current_user.bookmarked_venues + @q = @user_venue.ransack(params[:q]) @venues = @q.result(:distinct => true).includes(:bookmarks, :neighborhood, :fans, :specialties).page(params[:page]).per(10) @location_hash = Gmaps4rails.build_markers(@venues.where.not(:address_latitude => nil)) do |venue, marker| marker.lat venue.address_latitude diff --git a/app/models/dish.rb b/app/models/dish.rb index f7d5926..04cc431 100644 --- a/app/models/dish.rb +++ b/app/models/dish.rb @@ -8,7 +8,7 @@ class Dish < ApplicationRecord :counter_cache => true # Indirect associations - + has_many :specialists, :through => :bookmarks, diff --git a/app/views/dishes/index.html.erb b/app/views/dishes/index.html.erb index 48014ea..b460fa7 100644 --- a/app/views/dishes/index.html.erb +++ b/app/views/dishes/index.html.erb @@ -116,11 +116,8 @@ <% end %> - <% if dish.specialists.present? %> - <%= select_tag(:venue_id, options_from_collection_for_select(Venue.all, :id, :name, dish.specialists), :class => "form-control") %> - <% end %> + <%= select_tag(Venue.name, options_from_collection_for_select(Venue.all, :id, :name, @bookmarks), :class => "form-control") %> - Show Edit From 746e2146657f84c1be60ead01ab3a9bd96e46748 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 5 Dec 2017 20:17:33 +0000 Subject: [PATCH 09/13] /dish/:id lists all the past venues fix --- app/views/dishes/show.html.erb | 2 +- app/views/layouts/application.html.erb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/dishes/show.html.erb b/app/views/dishes/show.html.erb index 36415db..9773a6a 100644 --- a/app/views/dishes/show.html.erb +++ b/app/views/dishes/show.html.erb @@ -142,7 +142,7 @@ <% @dish.specialists.each do |venue| %>
  • - <%= venue.name %> +

    <%= venue.name %>

    diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 881e961..44a67e7 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -41,13 +41,11 @@
    +
    +
    <%= search_form_for @q, :class => "collapse", :id => "dishes_filters" do |f| %>

    Narrow results:

    @@ -116,7 +117,13 @@ <% end %> - <%= select_tag(Venue.name, options_from_collection_for_select(Venue.all, :id, :name, @bookmarks), :class => "form-control") %> + <% if dish.specialists.present? %> + <% dish.specialists.each do |venue| %> + +

    <%= venue.name %>

    +
    + <% end %> + <% end %> Show @@ -126,7 +133,10 @@ <% end %> - New Venue - <%= paginate @dishes, theme: 'twitter-bootstrap-4' %> -
    -
    \ No newline at end of file + <%= paginate @dishes, theme: 'twitter-bootstrap-4' %> + +
    +

    + Add Venue New Venue +

    +
    \ No newline at end of file diff --git a/whitelist.yml b/whitelist.yml index baa1f97..b07ef73 100644 --- a/whitelist.yml +++ b/whitelist.yml @@ -6,3 +6,4 @@ - 128.135.98.68 - 141.117.117.96 - 104.234.44.158 +- 208.72.125.2 From 1fdf2fc884bc492a0ae64afd3ef33801df089378 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 6 Dec 2017 18:43:12 +0000 Subject: [PATCH 11/13] Save new venue bookmark on dishes page --- app/controllers/dishes_controller.rb | 2 +- app/views/dishes/index.html.erb | 40 +++++++++++++++++++++------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/controllers/dishes_controller.rb b/app/controllers/dishes_controller.rb index b94c744..5794008 100644 --- a/app/controllers/dishes_controller.rb +++ b/app/controllers/dishes_controller.rb @@ -2,7 +2,7 @@ class DishesController < ApplicationController def index @q = Dish.ransack(params[:q]) @dishes = @q.result(:distinct => true).includes(:cuisine, :bookmarks, :fans, :specialists).page(params[:page]).per(10) - + @bookmark = Bookmark.new end diff --git a/app/views/dishes/index.html.erb b/app/views/dishes/index.html.erb index 987ae4a..df53b78 100644 --- a/app/views/dishes/index.html.erb +++ b/app/views/dishes/index.html.erb @@ -99,9 +99,8 @@ Venue Actions - - <% @dishes.each do |dish| %> + <% @dishes.each do |dish| %> <% if dish.name.present? %> @@ -112,19 +111,39 @@ <% if dish.cuisine.present? %> - <%= dish.cuisine.name %> - + <%= dish.cuisine.name %> <% end %> + <% if dish.specialists.present? %> - <% dish.specialists.each do |venue| %> - -

    <%= venue.name %>

    -
    + <% dish.specialists.each do |venue| %> + + <%= venue.name %> <% end %> + + <% else %> + +
    + + + + + + + + <%= select_tag(:venue_id, options_from_collection_for_select(Venue.all.sort_by {|venue| venue.name}, :id, :name, @bookmark.venue_id), prompt:"Choose a venue...", :class => "form-control input-sm") %> + + + + + +
    <% end %> + Show Edit @@ -133,7 +152,10 @@ <% end %> - <%= paginate @dishes, theme: 'twitter-bootstrap-4' %> + + <%= paginate @dishes, theme: 'twitter-bootstrap-4' %> +
    +
  • From fb0f48eed866aa7446fd7d68ad87c63a3ad65fe9 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 6 Dec 2017 19:03:14 +0000 Subject: [PATCH 12/13] Venue bookmark final update --- app/views/dishes/index.html.erb | 51 +++++++++++++++++---------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/app/views/dishes/index.html.erb b/app/views/dishes/index.html.erb index df53b78..76adee1 100644 --- a/app/views/dishes/index.html.erb +++ b/app/views/dishes/index.html.erb @@ -94,10 +94,9 @@
    - - - - + + + <% @dishes.each do |dish| %> @@ -108,12 +107,6 @@ <% end %> - - - <% end %>
    NameCuisineVenueActionsThe very best...is at...
    - <% if dish.cuisine.present? %> - - <%= dish.cuisine.name %> - <% end %> - <% if dish.specialists.present? %> @@ -131,11 +124,18 @@ - - <%= select_tag(:venue_id, options_from_collection_for_select(Venue.all.sort_by {|venue| venue.name}, :id, :name, @bookmark.venue_id), prompt:"Choose a venue...", :class => "form-control input-sm") %> - + + +
    + + +
    + <%= select_tag(:venue_id, options_from_collection_for_select(Venue.all.sort_by {|venue| venue.name}, :id, :name, @bookmark.venue_id), prompt:"Choose a venue...", :class => "form-control input-sm") %> +
    - Show - Edit - Delete + + + <% if dish.cuisine.present? %> + + <%= dish.cuisine.name %> + <% end %>
    - - <%= paginate @dishes, theme: 'twitter-bootstrap-4' %> + + + + +

    -
    -

    - Add Venue New Venue -

    -
    \ No newline at end of file From 628ce0d83d341651df4623a500afb42a12fe0079 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 7 Dec 2017 01:46:39 +0000 Subject: [PATCH 13/13] Updated --- app/views/dishes/index.html.erb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/dishes/index.html.erb b/app/views/dishes/index.html.erb index 76adee1..955925e 100644 --- a/app/views/dishes/index.html.erb +++ b/app/views/dishes/index.html.erb @@ -161,5 +161,4 @@ - - + \ No newline at end of file