Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Watch out for null accounts

  • Loading branch information...
commit 92f19cfad0e2db7dd794e19522eacf88ace33bff 1 parent 391f173
@sachac authored
View
2  Rakefile
@@ -3,5 +3,5 @@
require File.expand_path('../config/application', __FILE__)
require 'rake'
-
+include Rake::DSL
Home::Application.load_tasks
View
10 app/models/library_item.rb
@@ -2,10 +2,12 @@ class LibraryItem < ActiveRecord::Base
belongs_to :user
acts_as_taggable_on :tags
def self.current_items(account, public_only = false)
- query = LibraryItem.where("user_id = ? AND (status = 'due' OR status IS NULL OR status = 'read')", account.id).order(:due, :status)
- if public_only
- query = query.where('public=1')
+ if account
+ query = LibraryItem.where("user_id = ? AND (status = 'due' OR status IS NULL OR status = 'read')", account.id).order(:due, :status)
+ if public_only
+ query = query.where('public=1')
+ end
+ query
end
- query
end
end
View
54 app/views/home/index.html.haml
@@ -18,30 +18,30 @@
%h3 Toronto weather
%a{:href => "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=zmw:00000.1.71265&bannertypeclick=wu_clean2day"}
%img{:src => "http://weathersticker.wunderground.com/weathersticker/cgi-bin/banner/ban/wxBanner?bannertype=wu_clean2day_metric_cond&airportcode=CYTZ&ForcedCity=Toronto&ForcedState=ON&wmo=71265&language=EN", :alt => "Click for Toronto, Ontario Forecast", :height => "100", :width => "300"}
- .summary
- .clothing.category
- = render :partial => 'clothing_logs/by_date', :locals => { :dates => @dates, :by_date => @by_date, :size => :tiny }
- .library.category
- = link_to "#{LibraryItem.current_items(current_account).where('status!="read"').count} of #{pluralize(LibraryItem.current_items(current_account).count, "library item")} to read,", current_library_items_path
- = "#{pluralize TorontoLibrary.pickup_count(current_account), "item"} to pick up"
- - due = LibraryItem.current_items(current_account).minimum('due')
- - if due
- = " - first due: #{due.strftime('%a %b %e')}"
- - if can? :refresh_library, current_account
- = link_to "(refresh)", library_refresh_path
- .food.category
- - remaining = (current_account.csa_foods.where('disposition = ""').sum(:quantity) / 1000.0)
- - days = current_account.csa_foods.next_delivery - Date.today
- = link_to "#{'%0.1f' % remaining}kg of CSA food to go,", csa_foods_path
- = "#{pluralize days, "day"} until next delivery = "
- = "#{'%0.1f' % (remaining * 1.0 / days)}kg per day"
- .stuff.category
- - if current_account.stuff.out_of_place.count > 0
- = link_to "#{pluralize current_account.stuff.out_of_place.count, "item"} out of place", stuff_index_path
- .list
- = current_account.stuff.out_of_place.map{ |stuff| return_stuff_info stuff }.join(', ').html_safe
- - else
- .green= link_to "A place for everything, and everything in its place", stuff_index_path
- .clear-both
-
-
+ - if current_account
+ .summary
+ .clothing.category
+ = render :partial => 'clothing_logs/by_date', :locals => { :dates => @dates, :by_date => @by_date, :size => :tiny }
+ .library.category
+ = link_to "#{LibraryItem.current_items(current_account).where('status!="read"').count} of #{pluralize(LibraryItem.current_items(current_account).count, "library item")} to read,", current_library_items_path
+ = "#{pluralize TorontoLibrary.pickup_count(current_account), "item"} to pick up"
+ - due = LibraryItem.current_items(current_account).minimum('due')
+ - if due
+ = " - first due: #{due.strftime('%a %b %e')}"
+ - if can? :refresh_library, current_account
+ = link_to "(refresh)", library_refresh_path
+ .food.category
+ - remaining = (current_account.csa_foods.where('disposition = ""').sum(:quantity) / 1000.0)
+ - days = current_account.csa_foods.next_delivery - Date.today
+ = link_to "#{'%0.1f' % remaining}kg of CSA food to go,", csa_foods_path
+ = "#{pluralize days, "day"} until next delivery = "
+ = "#{'%0.1f' % (remaining * 1.0 / days)}kg per day"
+ .stuff.category
+ - if current_account.stuff.out_of_place.count > 0
+ = link_to "#{pluralize current_account.stuff.out_of_place.count, "item"} out of place", stuff_index_path
+ .list
+ = current_account.stuff.out_of_place.map{ |stuff| return_stuff_info stuff }.join(', ').html_safe
+ - else
+ .green= link_to "A place for everything, and everything in its place", stuff_index_path
+ .clear-both
+
View
7 app/views/layouts/application.html.haml
@@ -3,7 +3,7 @@
%head
%title Quantified Awesome
= stylesheet_link_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/themes/ui-lightness/jquery-ui.css"
- = stylesheet_link_tag "web-app-theme/base", "web-app-theme/themes/warehouse/style", "formtastic", "web-app-theme/override", "application", :cache => true
+ = stylesheet_link_tag "web-app-theme/base", "web-app-theme/themes/warehouse/style", "formtastic", "web-app-theme/override", "application"
= javascript_include_tag :defaults, :cache => true
= csrf_meta_tag
= javascript_include_tag "autocomplete-rails.js"
@@ -12,6 +12,11 @@
:javascript
$(function() { $('.sparkline-bar').sparkline('html', {type: 'bar', barColor: '#85acaa', chartRangeMin: 0}); });
%body.full
+ - unless Rails.env.production?
+ .dev
+ This is the development site. Check out
+ = link_to 'the main site', 'http://quantifiedawesome.com'
+ for current data!
#container{:class => @skip_sidebar ? 'no-sidebar' : 'has-sidebar'}
#header
%h1
View
BIN  db/development.sqlite3
Binary file not shown
View
4 public/stylesheets/application.css
@@ -97,3 +97,7 @@ ul, ol, dl {
body #sidebar ul.navigation li a:link, body #sidebar ul.navigation li a:visited {
padding-left: 0px; }
+
+.dev {
+ background: #ffc0c0;
+ padding: 5px; }
View
5 public/stylesheets/application.sass
@@ -77,4 +77,7 @@ ul, ol, dl
font-size: small
body #sidebar ul.navigation li a:link, body #sidebar ul.navigation li a:visited
- padding-left: 0px
+ padding-left: 0px
+.dev
+ background: #FFC0C0
+ padding: 5px
View
1  script/rails
@@ -3,4 +3,5 @@
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
+module Commands; end
require 'rails/commands'
Please sign in to comment.
Something went wrong with that request. Please try again.