Browse Source

lk | removes show action for clients

master
Louis Knapp 9 years ago
parent
commit
9f9cf5e6ba
  1. 19
      app/controllers/clients_controller.rb
  2. 4
      app/models/bike.rb
  3. 5
      app/views/clients/_fields.html.haml
  4. 4
      app/views/clients/edit.html.haml
  5. 24
      app/views/clients/index.html.haml
  6. 7
      app/views/clients/show.html.haml
  7. 8
      app/views/freecyclery/closed_applications.html.haml
  8. 12
      app/views/freecyclery/receipt.html.haml
  9. 12
      notes.txt

19
app/controllers/clients_controller.rb

@ -1,5 +1,5 @@
class ClientsController < ApplicationController
before_action :set_client, only: [:show, :edit, :update, :destroy]
before_action :set_client, only: [:edit, :update]
before_action :authenticate_user!
def index
@ -7,20 +7,16 @@ class ClientsController < ApplicationController
@clients = Client.all
end
def show
end
def new
@client = Client.new
end
def edit
end
def edit; end
def create
@client = Client.new(client_params)
if @client.save
redirect_to @client, notice: 'Client was successfully created.'
redirect_to edit_client_url(@client), notice: 'Client was successfully created.'
else
render action: 'new'
end
@ -28,19 +24,12 @@ class ClientsController < ApplicationController
def update
if @client.update(client_params)
redirect_to @client, notice: 'Client was successfully updated.'
redirect_to edit_client_url(@client), notice: 'Client was successfully updated.'
else
render action: 'edit'
end
end
def destroy
@client.destroy
respond_to do |format|
format.html { redirect_to clients_url }
end
end
private
def set_client
@client = Client.find(params[:id])

4
app/models/bike.rb

@ -39,7 +39,9 @@ class Bike < ActiveRecord::Base
end
def self.available_for_freecyclery
Bike.order(log_number: :desc).select{|bike| bike.completion_date && (bike.purpose == "Freecyclery")}
assigned_bikes = Client.all.select{|c| !c.bike_id.nil?}.map(&:bike)
all_freecyclery_bikes = Bike.order(log_number: :desc).select{|bike| bike.completion_date && (bike.purpose == "Freecyclery")}
all_freecyclery_bikes - assigned_bikes
end
def mark_picked_up

5
app/views/clients/_fields.html.haml

@ -63,7 +63,10 @@
.form-group
= f.label "Bike:", class: "col-sm-2 control-label"
.col-sm-10
= f.select :bike_id, options_for_select( Bike.available_for_freecyclery.collect{|b| [ b.name, b.id ]}, @client.bike_id ), {include_blank: 'None'}, class: "selectpicker", disabled: disabled
- if @client.bike_id
= f.select :bike_id, options_for_select( Bike.available_for_freecyclery.collect{|b| [ b.name, b.id ]} + [[@client.bike.name, @client.bike_id]], @client.bike_id ), {include_blank: 'None'}, class: "selectpicker", disabled: disabled
- else
= f.select :bike_id, options_for_select( Bike.available_for_freecyclery.collect{|b| [ b.name, b.id ]}, @client.bike_id ), {include_blank: 'None'}, class: "selectpicker", disabled: disabled
.form-group
= f.label "Agency:", class: "col-sm-2 control-label"

4
app/views/clients/edit.html.haml

@ -1,6 +1,4 @@
.container
%h1 Edit client
= render 'form'
= link_to 'Show', @client
|
= render 'form'
= link_to 'Back', clients_path

24
app/views/clients/index.html.haml

@ -8,25 +8,21 @@
%thead
%tr
%th Number
%th First Name
%th First Name
%th Last Name
%th Application Date
%th Agency
%th
%th
%th
%tbody
- @waiting_list.each_with_index do |client, index|
%tr
%td= index + 1
%td= client.first_name
%td= client.last_name
%td= client.first_name
%td= client.last_name
%td= client.application_date
%td= client.agency.agency_name if client.agency
%td= link_to 'Show', client
%td= link_to 'Edit', edit_client_path(client)
%td= link_to 'Destroy', client, method: :delete, data: { confirm: 'Are you sure?' }
%br
.row
%h1 All Clients
@ -34,20 +30,16 @@
%table.table.table-striped.table-bordered.table-hover
%thead
%tr
%th First Name
%th First Name
%th Last Name
%th Agency
%th
%th
%th
%tbody
- @clients.each do |client|
%tr
%td= client.first_name
%td= client.last_name
%td= client.first_name
%td= client.last_name
%td= client.agency.agency_name if client.agency
%td= link_to 'Show', client
%td= link_to 'Edit', edit_client_path(client)
%td= link_to 'Destroy', client, method: :delete, data: { confirm: 'Are you sure?' }
%br

7
app/views/clients/show.html.haml

@ -1,7 +0,0 @@
.container
%p#notice= notice
= form_for(@client) do |f|
= render 'fields', f: f, disabled: true
= link_to 'Edit', edit_client_path(@client)
|
= link_to 'Back', clients_path

8
app/views/freecyclery/closed_applications.html.haml

@ -5,15 +5,15 @@
%table.table.table-striped.table-bordered.table-hover
%thead
%tr
%th Name
%th Name
%th Voided
%th Completed
%th Show
%th Edit
%tbody
- @closed_applications.each do |client|
%tr
%td= client.name
%td= client.name
%td= client.application_voided
%td= client.completion_date
%td= link_to 'Show', client
%td= link_to 'Edit', edit_client_path(client)
%br

12
app/views/freecyclery/receipt.html.haml

@ -3,7 +3,7 @@
.receipt
%h2
%strong= @client.bike.name
%br
%br
= 'Log Number: ' + @client.bike.log_number.to_s
%br
.horizontal-line
@ -13,7 +13,7 @@
= @client.agency.agency_name
.horizontal-line
%br
= 'Paid $25 for lock and helmet' if @client.will_pay
= 'Paid $25 for lock and helmet' if @client.will_pay
%br
Includes:
%br
@ -30,7 +30,7 @@
%br
________________
%br
Recyclery Volunteer Initials
Recyclery Volunteer Initials
%br
___
%br
@ -40,7 +40,7 @@
.receipt
%h2
%strong= @client.bike.name
%br
%br
= 'Log Number: ' + @client.bike.log_number.to_s
%br
.horizontal-line
@ -50,7 +50,7 @@
= @client.agency.agency_name
.horizontal-line
%br
= 'Paid $25 for lock and helmet' if @client.will_pay
= 'Paid $25 for lock and helmet' if @client.will_pay
%br
Includes:
%br
@ -67,7 +67,7 @@
%br
________________
%br
Recyclery Volunteer Initials
Recyclery Volunteer Initials
%br
___
%br

12
notes.txt

@ -2,24 +2,16 @@ when bike gets picked up, remove it from freecyclery bike list
when visiting user page check if they have a bike and add it to
the list
available freecyclery bikes list should have all the infos - size,
make, model, color, etc
make sure you can mark bike completion dates
bikes ready for pickup should also include color & log number
clients should not be on waiting list after they get assigned a bike
Freecyclery Receipts
print sales labels should not show freecyclery bikes
search for bike based on log #
convert to bootstrap-less or something
convert to bootstrap-less
integrate with autocomplete to get manufacturers & models
enable posting to bike index when a bike is created
Freecyclery Receipts
Reports
General Reports

Loading…
Cancel
Save