Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

depart bike view implemented

  • Loading branch information...
commit 675e822dc41dff4bafed9517f5b68cb83f758b17 1 parent e356587
@zflat zflat authored
View
4 app/controllers/projects_controller.rb
@@ -129,7 +129,7 @@ def close
force = params[:force]
allow_close = (force == "all")
- allow_close ||= project.pass_req?
+ allow_close ||= project.detail.pass_req?
if allow_close && project.close
flash[:success] = "Project was closed successfully."
@@ -138,7 +138,7 @@ def close
flash[:error] = bike.errors.messages[0] if bike.errors
flash[:error] = project.errors.messages[0] if project.errors
- flash[:error] = "Project does not pass requirements" if (!project.pass_req?)
+ flash[:error] = "Project could not be closed because it does not pass requirements." if (!project.detail.pass_req?)
redirect_to project and return
end
View
15 app/models/program.rb
@@ -19,7 +19,6 @@ class Program < ActiveRecord::Base
has_many :projects, :as => :prog
belongs_to :project_category
-
validates_presence_of :title
validates_uniqueness_of :title, :allow_nil=>false
@@ -27,6 +26,20 @@ class Program < ActiveRecord::Base
attr_accessible :title, :max_total, :max_open
+ def self.terminal
+ if @term.nil?
+ @term = []
+ Program.all.each do |p|
+ p_class = p.project_category.project_type.constantize
+ if p_class.terminal?
+ @term << p
+ end
+ end
+ end
+ @term
+ end
+
+
def category_must_be_accepting_new_programs
if project_category and not project_category.accepting_programs?
errors.add(:project_category_id, "must be accepting new programs.")
View
12 app/views/bikes/_departure.html.erb
@@ -1,8 +1,14 @@
<% if bike.departed? %>
Departed on <%= bike.departed_at.strftime('%d %B %y') %>
<% else %>
- <% strBtnText=(bike.project)?"Close project and send away" : "Send away" %>
- <%= form_for(bike, :url=>send_away_bike_path(bike), :method => :put) do |f| %>
- <%= f.submit strBtnText, :class=>"btn btn-primary" %>
+ <% strBtnText=(bike.project)?"Close project and depart" : "Depart" %>
+ <% if bike.project %>
+ <%= form_for(project, :url=>close_project_path(project), :method => :put) do |f| %>
+ <%= f.submit "Close project and depart", :class=>"btn btn-primary" %>
+ <% end %>
+ <% else %>
+ <%= form_for(bike, :url=>depart_bike_path(bike), :method => :get) do |f| %>
+ <%= f.submit "Depart", :class=>"btn btn-primary" %>
+ <% end %>
<% end %>
<% end %>
View
35 app/views/bikes/depart.html.erb
@@ -1,20 +1,29 @@
-<h1>Send Bike Away</h1>
+<h1>Depart Bike <%= link_to bike.number, bike %> </h1>
-<%= render :partial=>"bike_table", :layout=>"bike_table_layout" %>
+<!-- <%= render :partial=>"bike_table", :layout=>"bike_table_layout" %> -->
-<% if bike.project and bike.project.open? %>
- <h2>Finish project</h2>
- <%= link_to "Complete project first", finish_project_path(bike.project) %>
- allow uncompleted project?
+<% if !bike.departed? %>
+ <% if bike.project.nil? %>
-<% end %>
+ <h3>Action required</h3>
+ <p>Bike <%= bike.number %> does not have a project assigned. A project assignment is required for all departing bikes.</p>
-<% if bike.project.nil? %>
- <h2>Project Association</h2>
- <%= link_to "Start a new project for this bike", new_project_path %>
+ <%= form_for(project, :url => projects_path, :method => :post) do |f| %>
+ <%= hidden_field_tag(:bike_id, bike.id) %>
+ <%= label_tag(:program_id, "Depart bike as:") %>
+ <%= select_tag(:program_id, options_from_collection_for_select(Program.terminal, :id, :title)) %>
+ <%= f.submit "Assign to program", :class => "btn btn-primary" %>
+ <% end %>
- select a project that allows for being closed upon being created
+ </p>To assign this bike to a different program, go <%= link_to "to the bike information page", bike %>.</p>
- allow for no project association?
+ <% else # if bike.project.nil? %>
+
+ <h3>Action required</h3>
+ <p>The project must be finished to depart this bike.</p>
+ <p><%= link_to "Go to the project page to finish and close out the project", bike.project %></p>
+
+ <% end # bike.project.nil? %>
+
+<% end #bike.departed? %>
-<% end %>

0 comments on commit 675e822

Please sign in to comment.
Something went wrong with that request. Please try again.