mirror of
				https://github.com/fspc/bike-database.git
				synced 2025-10-31 08:45:34 -04:00 
			
		
		
		
	Louis | Adds page which shows freecyclery bikes that are ready for pickup
This commit is contained in:
		
							parent
							
								
									090edd24e3
								
							
						
					
					
						commit
						77e7109b9e
					
				| @ -38,6 +38,10 @@ 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.' | ||||
|  | ||||
| @ -10,4 +10,17 @@ class Bike < ActiveRecord::Base | ||||
|     self.brand + ' ' + self.model | ||||
|   end | ||||
| 
 | ||||
|   def client | ||||
|     client = Client.find_by bike_id: self.id | ||||
|   end | ||||
| 
 | ||||
|   def ready_for_pickup? | ||||
|     client = self.client | ||||
|     client && self.completion_date && !client.application_voided | ||||
|   end | ||||
| 
 | ||||
|   def self.bikes_ready_for_pickup | ||||
|     Bike.all.select{|bike| bike.ready_for_pickup?} | ||||
|   end | ||||
| 
 | ||||
| end | ||||
|  | ||||
| @ -9,4 +9,8 @@ class Client < ActiveRecord::Base | ||||
|     waiting_list = incomplete_clients.sort_by!{|client| client.application_date} | ||||
|   end | ||||
| 
 | ||||
|   def name | ||||
|     self.first_name + ' ' + self.last_name | ||||
|   end | ||||
| 
 | ||||
| end | ||||
|  | ||||
							
								
								
									
										17
									
								
								app/views/bikes/freecyclery_pickup.html.haml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								app/views/bikes/freecyclery_pickup.html.haml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | ||||
| .container | ||||
|   %br | ||||
| 
 | ||||
|   %h1 Freecyclery Bikes for Pickup | ||||
|   %table.table.table-striped.table-bordered.table-hover | ||||
|     %thead | ||||
|       %tr | ||||
|         %th Brand | ||||
|         %th Model | ||||
|         %th Client | ||||
|     %tbody | ||||
|       - @bikes_for_pickup.each do |bike| | ||||
|         %tr | ||||
|           %td= bike.brand  | ||||
|           %td= bike.model | ||||
|           %td= bike.client.name | ||||
| 
 | ||||
| @ -8,3 +8,5 @@ | ||||
|   = link_to "Print Sale Bike Labels", print_select_bikes_path | ||||
|   %br | ||||
|   = link_to "Freecyclery Agencies", agencies_path | ||||
|   %br | ||||
|   = link_to "Freecyclery Bikes Ready for Pickup", freecyclery_pickup_bikes_path | ||||
|  | ||||
| @ -5,6 +5,7 @@ Bikedb::Application.routes.draw do | ||||
|   resources :bikes do | ||||
|     get 'print_select' => 'bikes#print_select', on: :collection | ||||
|     get 'print_labels' => 'bikes#print_labels', on: :collection | ||||
|     get 'freecyclery_pickup' => 'bikes#freecyclery_pickup', on: :collection | ||||
|     patch 'mark_as_sold' => 'bikes#mark_as_sold', on: :member | ||||
|   end | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user