From b717cba355f76735649ad742a28934d1cd4285ac Mon Sep 17 00:00:00 2001 From: Loos Date: Tue, 7 Oct 2014 21:17:44 -0400 Subject: [PATCH] Louis | Abstracts freecyclery functionality and adds closed applications page --- app/controllers/bikes_controller.rb | 4 ---- app/controllers/freecyclery_controller.rb | 13 +++++++++++++ app/models/client.rb | 4 ++++ .../freecyclery/closed_applications.html.haml | 19 +++++++++++++++++++ .../ready_for_pickup.html.haml} | 0 app/views/static_pages/home.html.haml | 4 +++- config/routes.rb | 4 ++++ 7 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 app/controllers/freecyclery_controller.rb create mode 100644 app/views/freecyclery/closed_applications.html.haml rename app/views/{bikes/freecyclery_pickup.html.haml => freecyclery/ready_for_pickup.html.haml} (100%) diff --git a/app/controllers/bikes_controller.rb b/app/controllers/bikes_controller.rb index 7d8d1fb..c55ca4c 100644 --- a/app/controllers/bikes_controller.rb +++ b/app/controllers/bikes_controller.rb @@ -38,10 +38,6 @@ class BikesController < ApplicationController end end - def freecyclery_pickup - @bikes_for_pickup = Bike.bikes_ready_for_pickup - end - def update if @bike.update(bike_params) redirect_to @bike, notice: 'Bike was successfully updated.' diff --git a/app/controllers/freecyclery_controller.rb b/app/controllers/freecyclery_controller.rb new file mode 100644 index 0000000..294cd84 --- /dev/null +++ b/app/controllers/freecyclery_controller.rb @@ -0,0 +1,13 @@ +class FreecycleryController < ApplicationController + before_action :authenticate_user! + + def closed_applications + @closed_applications = Client.closed_applications + end + + def ready_for_pickup + @bikes_for_pickup = Bike.bikes_ready_for_pickup + end + + +end diff --git a/app/models/client.rb b/app/models/client.rb index 8854e5b..09b8195 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -13,4 +13,8 @@ class Client < ActiveRecord::Base self.first_name + ' ' + self.last_name end + def self.closed_applications + Client.all.select{|client| client.application_voided || client.completion_date} + end + end diff --git a/app/views/freecyclery/closed_applications.html.haml b/app/views/freecyclery/closed_applications.html.haml new file mode 100644 index 0000000..9ff90d3 --- /dev/null +++ b/app/views/freecyclery/closed_applications.html.haml @@ -0,0 +1,19 @@ +.container + .row + %h1 Closed Applications + + %table.table.table-striped.table-bordered.table-hover + %thead + %tr + %th Name + %th Voided + %th Completed + %th Show + %tbody + - @closed_applications.each do |client| + %tr + %td= client.name + %td= client.application_voided + %td= client.completion_date + %td= link_to 'Show', client + %br diff --git a/app/views/bikes/freecyclery_pickup.html.haml b/app/views/freecyclery/ready_for_pickup.html.haml similarity index 100% rename from app/views/bikes/freecyclery_pickup.html.haml rename to app/views/freecyclery/ready_for_pickup.html.haml diff --git a/app/views/static_pages/home.html.haml b/app/views/static_pages/home.html.haml index c8f8a33..590a7b6 100644 --- a/app/views/static_pages/home.html.haml +++ b/app/views/static_pages/home.html.haml @@ -9,4 +9,6 @@ %br = link_to "Freecyclery Agencies", agencies_path %br - = link_to "Freecyclery Bikes Ready for Pickup", freecyclery_pickup_bikes_path + = link_to "Freecyclery Bikes Ready for Pickup", ready_for_pickup_path + %br + = link_to "Freecyclery Closed Applications", closed_applications_path diff --git a/config/routes.rb b/config/routes.rb index d8a8d7d..6ed96a2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,4 +12,8 @@ Bikedb::Application.routes.draw do resources :volunteers resources :agencies resources :clients + + get 'closed_applications' => 'freecyclery#closed_applications' + get 'ready_for_pickup' => 'freecyclery#ready_for_pickup' + end