diff --git a/tracks/app/controllers/application.rb b/tracks/app/controllers/application.rb index 36f938fe..38ac8fc4 100644 --- a/tracks/app/controllers/application.rb +++ b/tracks/app/controllers/application.rb @@ -64,7 +64,8 @@ class ApplicationController < ActionController::Base private def get_current_user - @user = User.find(session['user_id']) if session['user_id'] + @user = User.find(session['user_id']) if session['user_id'] + @prefs = @user.preferences unless @user.nil? end def get_admin_user diff --git a/tracks/app/controllers/user_controller.rb b/tracks/app/controllers/user_controller.rb index 11ce5719..23137e9a 100644 --- a/tracks/app/controllers/user_controller.rb +++ b/tracks/app/controllers/user_controller.rb @@ -28,7 +28,8 @@ class UserController < ApplicationController "no_completed" => "#{params['prefs']['no_completed']}", "staleness_starts" => "#{params['prefs']['staleness_starts']}", "due_style" => "#{params['prefs']['due_style']}", - "admin_email" => "#{params['prefs']['admin_email']}" + "admin_email" => "#{params['prefs']['admin_email']}", + "refresh" => "#{params['prefs']['refresh']}" } if @user.save redirect_to :action => 'preferences' diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index 1fc2901a..9071de91 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -2,6 +2,7 @@ + ;url=<%= request.request_uri %>"> <%= stylesheet_link_tag "standard" %> <%= stylesheet_link_tag "print", :media => "print" %> <%= javascript_include_tag "toggle_notes" %> diff --git a/tracks/app/views/user/preference_edit_form.rhtml b/tracks/app/views/user/preference_edit_form.rhtml index b6f59135..32422e79 100644 --- a/tracks/app/views/user/preference_edit_form.rhtml +++ b/tracks/app/views/user/preference_edit_form.rhtml @@ -10,6 +10,7 @@ <% end %>
  • week_starts: day of the week shown as the start of the week on the popup calendar.
  • due_style: style in which due dates are shown, e.g. "Due in 3 days", "Due on Wednesday"
  • +
  • refresh: automatic refresh interval for each of the pages (in minutes)
  • diff --git a/tracks/app/views/user/preferences.rhtml b/tracks/app/views/user/preferences.rhtml index 26068288..3ed2ac1e 100644 --- a/tracks/app/views/user/preferences.rhtml +++ b/tracks/app/views/user/preferences.rhtml @@ -41,6 +41,7 @@ <% if @user.is_admin? %>
  • Admin email: <%= @prefs["admin_email"] %>
  • <% end %> +
  • Refresh interval (in minutes): <%= @prefs["refresh"] %>
  • <%= link_to "Edit preferences", :controller => 'user', :action => 'edit_preferences' %> | <%= link_to 'Change password', :controller => 'user', :action => 'change_password' %> diff --git a/tracks/db/migrate/009_add_user_pref_refresh.rb b/tracks/db/migrate/009_add_user_pref_refresh.rb new file mode 100644 index 00000000..235f5673 --- /dev/null +++ b/tracks/db/migrate/009_add_user_pref_refresh.rb @@ -0,0 +1,12 @@ +class AddUserPrefRefresh < ActiveRecord::Migration + def self.up + @users = User.find(:all) + @users.each do |user| + user.preferences.merge!({"refresh" => "0"}) + user.save + end + end + + def self.down + end +end diff --git a/tracks/db/schema.rb b/tracks/db/schema.rb index bbadce91..f830859a 100644 --- a/tracks/db/schema.rb +++ b/tracks/db/schema.rb @@ -2,7 +2,7 @@ # migrations feature of ActiveRecord to incrementally modify your database, and # then regenerate this schema definition. -ActiveRecord::Schema.define(:version => 8) do +ActiveRecord::Schema.define(:version => 9) do create_table "contexts", :force => true do |t| t.column "name", :string, :default => "", :null => false diff --git a/tracks/test/fixtures/notes.yml b/tracks/test/fixtures/notes.yml index 84052a6b..ad914f3f 100644 --- a/tracks/test/fixtures/notes.yml +++ b/tracks/test/fixtures/notes.yml @@ -1,13 +1,15 @@ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html <% def today -Time.now.to_s(:db) -end + Time.now.to_s(:db) +end + def next_week -1.week.from_now.to_s(:db) -end + 1.week.from_now.to_s(:db) +end + def last_week -1.week.ago.to_s(:db) + 1.week.ago.to_s(:db) end %> diff --git a/tracks/test/fixtures/todos.yml b/tracks/test/fixtures/todos.yml index f4f0ea62..79c5656f 100644 --- a/tracks/test/fixtures/todos.yml +++ b/tracks/test/fixtures/todos.yml @@ -1,5 +1,6 @@ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html <% + def today Time.now.to_s(:db) end @@ -16,10 +17,6 @@ def two_weeks_hence 2.week.from_now.to_s(:db) end -# This writes the fixture boolean columns appropriately -# depending on the database adapter -# - %> 1: @@ -138,7 +135,7 @@ end notes: ~ done: 1 created_at: <%= today %> - due: 2005-01-05 + due: <%= two_weeks_hence %> completed: <%= today %> user_id: 1 @@ -150,7 +147,7 @@ end notes: ~ done: false created_at: <%= today %> - due: 2005-02-01 + due: <%= next_week %> completed: ~ user_id: 1 diff --git a/tracks/test/fixtures/users.yml b/tracks/test/fixtures/users.yml index 0cb8e0dc..32403a2e 100644 --- a/tracks/test/fixtures/users.yml +++ b/tracks/test/fixtures/users.yml @@ -5,7 +5,14 @@ admin_user: password: <%= Digest::SHA1.hexdigest("#{SALT}--abracadabra--") %> word: <%= Digest::SHA1.hexdigest("adminSat Feb 25 17:14:00 GMT 20060.236961325863376") %> is_admin: true - preferences: "---\nstaleness_starts: \"7\"\ndate_format: \"%d/%m/%Y\"\nno_completed: \"5\"\nadmin_email: butshesagirl@rousette.org.uk\nweek_starts: \"1\"\ndue_style: \"0\"" + preferences: + staleness_starts: "7" + date_format: "%d/%m/%Y" + no_completed: "5" + admin_email: butshesagirl@rousette.org.uk + weeks_starts: "1" + due_style: "0" + refresh: "0" other_user: id: 2 @@ -13,4 +20,11 @@ other_user: password: <%= Digest::SHA1.hexdigest("#{SALT}--sesame--") %> word: <%= Digest::SHA1.hexdigest("janeSun Feb 19 14:42:45 GMT 20060.408173979260027") %> is_admin: false - preferences: "---\nstaleness_starts: \"7\"\ndate_format: \"%d/%m/%Y\"\nno_completed: \"5\"\nadmin_email: butshesagirl@rousette.org.uk\nweek_starts: \"1\"\ndue_style: \"0\"" + preferences: + staleness_starts: "7" + date_format: "%d/%m/%Y" + no_completed: "5" + admin_email: butshesagirl@rousette.org.uk + weeks_starts: "1" + due_style: "0" + refresh: "0" diff --git a/tracks/test/functional/user_controller_test.rb b/tracks/test/functional/user_controller_test.rb index 06d65ccc..07c67b63 100644 --- a/tracks/test/functional/user_controller_test.rb +++ b/tracks/test/functional/user_controller_test.rb @@ -44,7 +44,7 @@ class UserControllerTest < Test::Unit::TestCase assert_success assert_equal assigns['page_title'], "TRACKS::Preferences" assert_not_nil assigns['prefs'] - assert_equal assigns['prefs'].length, 6 + assert_equal assigns['prefs'].length, 7 end def test_edit_preferences @@ -55,7 +55,7 @@ class UserControllerTest < Test::Unit::TestCase assert_success assert_equal assigns['page_title'], "TRACKS::Edit Preferences" assert_not_nil assigns['prefs'] - assert_equal assigns['prefs'].length, 6 + assert_equal assigns['prefs'].length, 7 assert_template 'user/preference_edit_form' end