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. 3
      app/views/clients/_fields.html.haml
  4. 2
      app/views/clients/edit.html.haml
  5. 8
      app/views/clients/index.html.haml
  6. 7
      app/views/clients/show.html.haml
  7. 4
      app/views/freecyclery/closed_applications.html.haml
  8. 12
      notes.txt

19
app/controllers/clients_controller.rb

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

4
app/models/bike.rb

@ -39,7 +39,9 @@ class Bike < ActiveRecord::Base
end end
def self.available_for_freecyclery 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 end
def mark_picked_up def mark_picked_up

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

@ -63,6 +63,9 @@
.form-group .form-group
= f.label "Bike:", class: "col-sm-2 control-label" = f.label "Bike:", class: "col-sm-2 control-label"
.col-sm-10 .col-sm-10
- 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 = 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 .form-group

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

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

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

@ -13,8 +13,6 @@
%th Application Date %th Application Date
%th Agency %th Agency
%th %th
%th
%th
%tbody %tbody
- @waiting_list.each_with_index do |client, index| - @waiting_list.each_with_index do |client, index|
%tr %tr
@ -23,9 +21,7 @@
%td= client.last_name %td= client.last_name
%td= client.application_date %td= client.application_date
%td= client.agency.agency_name if client.agency %td= client.agency.agency_name if client.agency
%td= link_to 'Show', client
%td= link_to 'Edit', edit_client_path(client) %td= link_to 'Edit', edit_client_path(client)
%td= link_to 'Destroy', client, method: :delete, data: { confirm: 'Are you sure?' }
%br %br
.row .row
@ -38,16 +34,12 @@
%th Last Name %th Last Name
%th Agency %th Agency
%th %th
%th
%th
%tbody %tbody
- @clients.each do |client| - @clients.each do |client|
%tr %tr
%td= client.first_name %td= client.first_name
%td= client.last_name %td= client.last_name
%td= client.agency.agency_name if client.agency %td= client.agency.agency_name if client.agency
%td= link_to 'Show', client
%td= link_to 'Edit', edit_client_path(client) %td= link_to 'Edit', edit_client_path(client)
%td= link_to 'Destroy', client, method: :delete, data: { confirm: 'Are you sure?' }
%br %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

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

@ -8,12 +8,12 @@
%th Name %th Name
%th Voided %th Voided
%th Completed %th Completed
%th Show %th Edit
%tbody %tbody
- @closed_applications.each do |client| - @closed_applications.each do |client|
%tr %tr
%td= client.name %td= client.name
%td= client.application_voided %td= client.application_voided
%td= client.completion_date %td= client.completion_date
%td= link_to 'Show', client %td= link_to 'Edit', edit_client_path(client)
%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 when visiting user page check if they have a bike and add it to
the list the list
available freecyclery bikes list should have all the infos - size,
make, model, color, etc
make sure you can mark bike completion dates 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 clients should not be on waiting list after they get assigned a bike
Freecyclery Receipts
print sales labels should not show freecyclery bikes print sales labels should not show freecyclery bikes
search for bike based on log # convert to bootstrap-less
convert to bootstrap-less or something
integrate with autocomplete to get manufacturers & models integrate with autocomplete to get manufacturers & models
enable posting to bike index when a bike is created enable posting to bike index when a bike is created
Freecyclery Receipts
Reports Reports
General Reports General Reports

Loading…
Cancel
Save