Skip to content

Commit

Permalink
Added conditional logic for help tex.t
Browse files Browse the repository at this point in the history
  • Loading branch information
psobot committed Jan 22, 2012
1 parent 729c314 commit cc376d6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
4 changes: 4 additions & 0 deletions app/models/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class Resource < ActiveRecord::Base
end
end

def self.all_busy?
!not_in_use.present?
end

def self.find_by_email email

# Slug could be "washer", "washer1", "dryer2", etc...
Expand Down
10 changes: 10 additions & 0 deletions app/views/resources/_show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.name= resource.name
- if resource.is_available?
.available
available
- else
.not.available
will be available in
.time{:data => {:time => resource.will_be_available.to_i * 1000}}
#{distance_of_time_in_words Time.now.utc, resource.will_be_available}

24 changes: 10 additions & 14 deletions app/views/resources/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@
.message{:class => type}
= message
%p
%span.click Click
%span.tap Tap
a machine below to claim it.
- if !Resource.all_busy?
%span.click Click
%span.tap Tap
a machine below to claim it.
- Resource.all.each do |resource|
- classes = ['resource', resource.type.slug] + (resource.is_in_use? ? ['busy'] : ['available'])
= link_to resource.email_link, :class => classes do
.name= resource.name
- if resource.is_available?
.available
available
- else
.not.available
will be available in
.time{:data => {:time => resource.will_be_available.to_i * 1000}}
#{distance_of_time_in_words Time.now.utc, resource.will_be_available}

- if resource.is_available?
= link_to resource.email_link, :class => classes do
= render :partial => 'show', :locals => {:resource => resource}
- else
.resource{:class => classes}
= render :partial => 'show', :locals => {:resource => resource}

0 comments on commit cc376d6

Please sign in to comment.