Browse Source

Louis | user can mark bikes as picked up from the available freecyclery bikes page

master
Loos 10 years ago
parent
commit
157712ac67
  1. 6
      app/controllers/bikes_controller.rb
  2. 7
      app/models/bike.rb
  3. 2
      app/views/freecyclery/ready_for_pickup.html.haml
  4. 2
      config/routes.rb
  5. 14
      notes.txt

6
app/controllers/bikes_controller.rb

@ -61,6 +61,12 @@ class BikesController < ApplicationController
end end
end end
def mark_picked_up
@bike = Bike.find(params[:id])
@bike.mark_picked_up
flash[:notice] = @bike.name + ' was marked as picked up'
redirect_to action: "ready_for_pickup", controller: "freecyclery"
end
private private
def set_bike def set_bike

7
app/models/bike.rb

@ -16,7 +16,7 @@ class Bike < ActiveRecord::Base
def ready_for_pickup? def ready_for_pickup?
client = self.client client = self.client
client && self.completion_date && !client.application_voided client && self.completion_date && !client.application_voided && self.date_sold.nil?
end end
def self.bikes_ready_for_pickup def self.bikes_ready_for_pickup
@ -27,4 +27,9 @@ class Bike < ActiveRecord::Base
Bike.all.select{|bike| bike.completion_date && (bike.purpose == "Freecyclery") && !bike.client } Bike.all.select{|bike| bike.completion_date && (bike.purpose == "Freecyclery") && !bike.client }
end end
def mark_picked_up
current_date = Time.new.strftime("%Y-%m-%d")
self.update_attribute(:date_sold, current_date)
end
end end

2
app/views/freecyclery/ready_for_pickup.html.haml

@ -8,10 +8,12 @@
%th Brand %th Brand
%th Model %th Model
%th Client %th Client
%th
%tbody %tbody
- @bikes_for_pickup.each do |bike| - @bikes_for_pickup.each do |bike|
%tr %tr
%td= bike.brand %td= bike.brand
%td= bike.model %td= bike.model
%td= bike.client.name %td= bike.client.name
%td= button_to "Mark as picked up", {controller: "bikes", action: "mark_picked_up", id: bike.id}, method: :patch, class: "btn btn-default"

2
config/routes.rb

@ -7,6 +7,7 @@ Bikedb::Application.routes.draw do
get 'print_labels' => 'bikes#print_labels', on: :collection get 'print_labels' => 'bikes#print_labels', on: :collection
get 'freecyclery_pickup' => 'bikes#freecyclery_pickup', on: :collection get 'freecyclery_pickup' => 'bikes#freecyclery_pickup', on: :collection
patch 'mark_as_sold' => 'bikes#mark_as_sold', on: :member patch 'mark_as_sold' => 'bikes#mark_as_sold', on: :member
patch 'mark_picked_up' => 'bikes#mark_picked_up', on: :member
end end
resources :volunteers resources :volunteers
@ -18,6 +19,5 @@ Bikedb::Application.routes.draw do
get 'closed_applications' => 'freecyclery#closed_applications' get 'closed_applications' => 'freecyclery#closed_applications'
get 'ready_for_pickup' => 'freecyclery#ready_for_pickup' get 'ready_for_pickup' => 'freecyclery#ready_for_pickup'
get 'available_bikes' => 'freecyclery#available_bikes' get 'available_bikes' => 'freecyclery#available_bikes'
get 'bikes_sold_per_year' => 'reports#bikes_sold_per_year' get 'bikes_sold_per_year' => 'reports#bikes_sold_per_year'
end end

14
notes.txt

@ -1,16 +1,18 @@
Freecyclery Receipts Freecyclery Receipts
Reports Reports
Number of bikes sold by year or month. (Bar graph for extra points!) General Reports
Number of bikes donated by year or month. (With bar graph!?) bikes donated per year
Number of bikes donated according to agency. (Graph?) Yearly Reports
Average bike price for year. bikes sold by month. (Bar graph for extra points!)
bikes donated by year or month. (With bar graph!?)
bikes donated according to agency. (Graph?)
Add some way to navigate to client receipts Add some way to navigate to client receipts
style client receipts style client receipts
assign a bike from the available freecyclery bikes page assign a bike from the available freecyclery bikes page
mark as picked up from the ready for pickup page
validations around parameters that break site if incomplete validations around parameters that break site if incomplete
mark as sold should be disabled after bike is sold mark as sold should be disabled after bike is sold
there should be nice feedback indicating that the bike was sold there should be nice feedback indicating that the bike was sold

Loading…
Cancel
Save