mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-03 06:21:49 +01:00
Added a META HTTP-EQUIV=REFRESH value to the standard layout template. The refresh value is taken from user preferences, and defaults to zero so that the page doesn't refresh automatically.
If you're using the trunk, you'll need to run rake db:migrate to update your user preferences. Fixes #295 git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@290 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
d1b74bc2bf
commit
803a9db6ae
11 changed files with 48 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv="Refresh" content="<%= @prefs["refresh"].to_i*60 %>;url=<%= request.request_uri %>">
|
||||
<%= stylesheet_link_tag "standard" %>
|
||||
<%= stylesheet_link_tag "print", :media => "print" %>
|
||||
<%= javascript_include_tag "toggle_notes" %>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
<% end %>
|
||||
<li><strong>week_starts:</strong> day of the week shown as the start of the week on the popup calendar.</li>
|
||||
<li><strong>due_style:</strong> style in which due dates are shown, e.g. "Due in 3 days", "Due on Wednesday"</li>
|
||||
<li><strong>refresh:</strong> automatic refresh interval for each of the pages (in minutes)</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
<% if @user.is_admin? %>
|
||||
<li>Admin email: <span class="highlight"><%= @prefs["admin_email"] %></span></li>
|
||||
<% end %>
|
||||
<li>Refresh interval (in minutes): <span class="highlight"><%= @prefs["refresh"] %></span></li>
|
||||
</ul>
|
||||
<%= link_to "Edit preferences", :controller => 'user', :action => 'edit_preferences' %> |
|
||||
<%= link_to 'Change password', :controller => 'user', :action => 'change_password' %>
|
||||
|
|
|
|||
12
tracks/db/migrate/009_add_user_pref_refresh.rb
Normal file
12
tracks/db/migrate/009_add_user_pref_refresh.rb
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
12
tracks/test/fixtures/notes.yml
vendored
12
tracks/test/fixtures/notes.yml
vendored
|
|
@ -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
|
||||
%>
|
||||
|
||||
|
|
|
|||
9
tracks/test/fixtures/todos.yml
vendored
9
tracks/test/fixtures/todos.yml
vendored
|
|
@ -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
|
||||
|
||||
|
|
|
|||
18
tracks/test/fixtures/users.yml
vendored
18
tracks/test/fixtures/users.yml
vendored
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue