mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-02 11:00:16 +01:00
Changed all instances of @response, @request, @session etc. to the new forms or response, request, session etc.
Fixes #266 git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@239 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
ca8a386dd7
commit
eefbb70660
23 changed files with 114 additions and 134 deletions
|
|
@ -32,7 +32,7 @@ class ContextController < ApplicationController
|
|||
#
|
||||
def new_context
|
||||
context = @user.contexts.build
|
||||
context.attributes = @params['context']
|
||||
context.attributes = params['context']
|
||||
context.name = deurlize(context.name)
|
||||
|
||||
if context.save
|
||||
|
|
@ -49,10 +49,10 @@ class ContextController < ApplicationController
|
|||
def add_item
|
||||
self.init
|
||||
@item = @user.todos.build
|
||||
@item.attributes = @params["todo"]
|
||||
@item.attributes = params["todo"]
|
||||
|
||||
if @item.due?
|
||||
@item.due = Date.strptime(@params["todo"]["due"], @user.preferences["date_format"])
|
||||
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
|
||||
else
|
||||
@item.due = ""
|
||||
end
|
||||
|
|
@ -140,7 +140,7 @@ class ContextController < ApplicationController
|
|||
#
|
||||
def update
|
||||
check_user_set_context
|
||||
@context.attributes = @params["context"]
|
||||
@context.attributes = params["context"]
|
||||
@context.name = deurlize(@context.name)
|
||||
if @context.save
|
||||
render_partial 'context_listing', @context
|
||||
|
|
@ -166,7 +166,7 @@ class ContextController < ApplicationController
|
|||
# Methods for changing the sort order of the contexts in the list
|
||||
#
|
||||
def order
|
||||
@params["list-contexts"].each_with_index do |id, position|
|
||||
params["list-contexts"].each_with_index do |id, position|
|
||||
if check_user_matches_context_user(id)
|
||||
Context.update(id, :position => position + 1)
|
||||
end
|
||||
|
|
@ -177,10 +177,10 @@ class ContextController < ApplicationController
|
|||
protected
|
||||
|
||||
def check_user_set_context
|
||||
if @params["name"]
|
||||
@context = Context.find_by_name_and_user_id(deurlize(@params["name"]), @user.id)
|
||||
elsif @params['id']
|
||||
@context = Context.find_by_id_and_user_id(@params["id"], @user.id)
|
||||
if params["name"]
|
||||
@context = Context.find_by_name_and_user_id(deurlize(params["name"]), @user.id)
|
||||
elsif params['id']
|
||||
@context = Context.find_by_id_and_user_id(params["id"], @user.id)
|
||||
else
|
||||
redirect_to(:controller => "context", :action => "list" )
|
||||
end
|
||||
|
|
@ -205,7 +205,7 @@ class ContextController < ApplicationController
|
|||
end
|
||||
|
||||
def check_user_return_item
|
||||
item = Todo.find( @params['id'] )
|
||||
item = Todo.find( params['id'] )
|
||||
if @user == item.user
|
||||
return item
|
||||
else
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class FeedController < ApplicationController
|
|||
# Build an RSS feed
|
||||
def rss
|
||||
prepare_for_feed
|
||||
@headers["Content-Type"] = "text/xml; charset=utf-8"
|
||||
headers["Content-Type"] = "text/xml; charset=utf-8"
|
||||
end
|
||||
|
||||
# Builds a plain text page listing uncompleted next actions,
|
||||
|
|
@ -27,12 +27,12 @@ class FeedController < ApplicationController
|
|||
#
|
||||
def text
|
||||
prepare_for_feed
|
||||
if @params.key?('context')
|
||||
@contexts = [ @user.contexts.find(@params['context']) ]
|
||||
if params.key?('context')
|
||||
@contexts = [ @user.contexts.find(params['context']) ]
|
||||
else
|
||||
@contexts = @user.contexts.find_all_by_hide(false, "position ASC")
|
||||
end
|
||||
@headers["Content-Type"] = "text/plain; charset=utf-8"
|
||||
headers["Content-Type"] = "text/plain; charset=utf-8"
|
||||
end
|
||||
|
||||
# Builds an iCal compatible export of uncompleted todos
|
||||
|
|
@ -41,32 +41,32 @@ class FeedController < ApplicationController
|
|||
#
|
||||
def ical
|
||||
prepare_for_feed
|
||||
if @params.key?('context')
|
||||
@contexts = [ @user.contexts.find(@params['context']) ]
|
||||
if params.key?('context')
|
||||
@contexts = [ @user.contexts.find(params['context']) ]
|
||||
else
|
||||
@contexts = @user.contexts.find_all_by_hide(false, "position ASC")
|
||||
end
|
||||
@headers["Content-Type"] = "text/plain; charset=utf-8"
|
||||
headers["Content-Type"] = "text/plain; charset=utf-8"
|
||||
end
|
||||
|
||||
def list_projects_only
|
||||
@projects = @user.projects
|
||||
@description = "Lists all the projects for #{@user.login}."
|
||||
render :action => 'projects_' + @params['feedtype']
|
||||
render :action => 'projects_' + params['feedtype']
|
||||
end
|
||||
|
||||
def list_contexts_only
|
||||
@contexts = @user.contexts
|
||||
@description = "Lists all the contexts for #{@user.login}."
|
||||
render :action => 'contexts_' + @params['feedtype']
|
||||
render :action => 'contexts_' + params['feedtype']
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Check whether the token in the URL matches the word in the User's table
|
||||
def check_token_against_user_word
|
||||
@user = User.find_by_login( @params['name'] )
|
||||
unless ( @params['token'] == @user.word)
|
||||
@user = User.find_by_login( params['name'] )
|
||||
unless ( params['token'] == @user.word)
|
||||
render :text => "Sorry, you don't have permission to view this page."
|
||||
return false
|
||||
end
|
||||
|
|
@ -78,15 +78,15 @@ protected
|
|||
|
||||
condition_builder.add 'todos.done = ?', false
|
||||
|
||||
if @params.key?('limit')
|
||||
options[:limit] = limit = @params['limit']
|
||||
if params.key?('limit')
|
||||
options[:limit] = limit = params['limit']
|
||||
@description = limit ? "Lists the last #{limit} uncompleted next actions" : "Lists uncompleted next actions"
|
||||
end
|
||||
@title = "Tracks - Next Actions"
|
||||
@description = "Filter: "
|
||||
|
||||
if @params.key?('due')
|
||||
due_within = @params['due'].to_i
|
||||
if params.key?('due')
|
||||
due_within = params['due'].to_i
|
||||
condition_builder.add('todos.due <= ?', due_within.days.from_now)
|
||||
due_within_date_s = due_within.days.from_now.strftime("%Y-%m-%d")
|
||||
@title << " due today" if (due_within == 0)
|
||||
|
|
@ -94,15 +94,15 @@ protected
|
|||
@description << " with a due date #{due_within_date_s} or earlier"
|
||||
end
|
||||
|
||||
if @params.key?('context')
|
||||
context = @user.contexts.find(@params['context'])
|
||||
if params.key?('context')
|
||||
context = @user.contexts.find(params['context'])
|
||||
condition_builder.add('todos.context_id = ?', context.id)
|
||||
@title << " in #{context.name}"
|
||||
@description << " in context '#{context.name}'"
|
||||
end
|
||||
|
||||
if @params.key?('project')
|
||||
project = @user.projects.find(@params['project'])
|
||||
if params.key?('project')
|
||||
project = @user.projects.find(params['project'])
|
||||
condition_builder.add('todos.project_id = ?', project.id)
|
||||
@title << " for #{project.name}"
|
||||
@description << " for project '#{project.name}'"
|
||||
|
|
@ -119,16 +119,16 @@ protected
|
|||
|
||||
def initialize
|
||||
@queries = Array.new
|
||||
@params = Array.new
|
||||
params = Array.new
|
||||
end
|
||||
|
||||
def add(query, param)
|
||||
@queries << query
|
||||
@params << param
|
||||
params << param
|
||||
end
|
||||
|
||||
def to_conditions
|
||||
[@queries.join(' AND ')] + @params
|
||||
[@queries.join(' AND ')] + params
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ class LoginController < ApplicationController
|
|||
|
||||
def login
|
||||
@page_title = "TRACKS::Login"
|
||||
case @request.method
|
||||
case request.method
|
||||
when :post
|
||||
if @user = User.authenticate(@params['user_login'], @params['user_password'])
|
||||
if @user = User.authenticate(params['user_login'], params['user_password'])
|
||||
session['user_id'] = @user.id
|
||||
# If checkbox on login page checked, we don't expire the session after 1 hour
|
||||
# of inactivity
|
||||
session['noexpiry']= @params['user_noexpiry']
|
||||
session['noexpiry']= params['user_noexpiry']
|
||||
if session['noexpiry'] == "on"
|
||||
msg = "will not expire."
|
||||
else
|
||||
|
|
@ -20,7 +20,7 @@ class LoginController < ApplicationController
|
|||
flash['notice'] = "Login successful: session #{msg}"
|
||||
redirect_back_or_default :controller => "todo", :action => "list"
|
||||
else
|
||||
@login = @params['user_login']
|
||||
@login = params['user_login']
|
||||
flash['warning'] = "Login unsuccessful"
|
||||
end
|
||||
end
|
||||
|
|
@ -56,7 +56,7 @@ class LoginController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
user = User.new(@params['user'])
|
||||
user = User.new(params['user'])
|
||||
unless user.valid?
|
||||
session['new_user'] = user
|
||||
redirect_to :controller => 'login', :action => 'signup'
|
||||
|
|
@ -65,7 +65,7 @@ class LoginController < ApplicationController
|
|||
|
||||
user.is_admin = true if User.find_all.empty?
|
||||
if user.save
|
||||
@user = User.authenticate(user.login, @params['user']['password'])
|
||||
@user = User.authenticate(user.login, params['user']['password'])
|
||||
@user.preferences = { "date_format" => "%d/%m/%Y", "week_starts" => "1", "no_completed" => "5", "staleness_starts" => "7", "due_style" => "1", "admin_email" => "butshesagirl@rousette.org.uk"}
|
||||
@user.save
|
||||
flash['notice'] = "Signup successful for user #{@user.login}."
|
||||
|
|
@ -74,8 +74,8 @@ class LoginController < ApplicationController
|
|||
end
|
||||
|
||||
def delete
|
||||
if @params['id'] and ( @params['id'] = @user.id or @user.is_admin )
|
||||
@user = User.find(@params['id'])
|
||||
if params['id'] and ( params['id'] = @user.id or @user.is_admin )
|
||||
@user = User.find(params['id'])
|
||||
# TODO: Maybe it would be better to mark deleted. That way user deletes can be reversed.
|
||||
@user.destroy
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class NoteController < ApplicationController
|
|||
#
|
||||
def add
|
||||
note = @user.notes.build
|
||||
note.attributes = @params["new_note"]
|
||||
note.attributes = params["new_note"]
|
||||
|
||||
if note.save
|
||||
render_partial 'notes_summary', note
|
||||
|
|
@ -40,7 +40,7 @@ class NoteController < ApplicationController
|
|||
|
||||
def update
|
||||
note = check_user_return_note
|
||||
note.attributes = @params["note"]
|
||||
note.attributes = params["note"]
|
||||
if note.save
|
||||
render_partial 'notes', note
|
||||
else
|
||||
|
|
@ -52,7 +52,7 @@ class NoteController < ApplicationController
|
|||
protected
|
||||
|
||||
def check_user_return_note
|
||||
note = Note.find_by_id( @params['id'] )
|
||||
note = Note.find_by_id( params['id'] )
|
||||
if @user == note.user
|
||||
return note
|
||||
else
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class ProjectController < ApplicationController
|
|||
|
||||
def new_project
|
||||
project = @user.projects.build
|
||||
project.attributes = @params['project']
|
||||
project.attributes = params['project']
|
||||
project.name = deurlize(project.name)
|
||||
|
||||
if project.save
|
||||
|
|
@ -72,10 +72,10 @@ class ProjectController < ApplicationController
|
|||
def add_item
|
||||
self.init
|
||||
@item = @user.todos.build
|
||||
@item.attributes = @params["todo"]
|
||||
@item.attributes = params["todo"]
|
||||
|
||||
if @item.due?
|
||||
@item.due = Date.strptime(@params["todo"]["due"], @user.preferences["date_format"])
|
||||
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
|
||||
else
|
||||
@item.due = ""
|
||||
end
|
||||
|
|
@ -165,7 +165,7 @@ class ProjectController < ApplicationController
|
|||
#
|
||||
def update
|
||||
check_user_set_project
|
||||
@project.attributes = @params["project"]
|
||||
@project.attributes = params["project"]
|
||||
@project.name = deurlize(@project.name)
|
||||
if @project.save
|
||||
render_partial 'project_listing', @project
|
||||
|
|
@ -201,7 +201,7 @@ class ProjectController < ApplicationController
|
|||
# Methods for changing the sort order of the projects in the list
|
||||
#
|
||||
def order
|
||||
@params["list-projects"].each_with_index do |id, position|
|
||||
params["list-projects"].each_with_index do |id, position|
|
||||
if check_user_matches_project_user(id)
|
||||
Project.update(id, :position => position + 1)
|
||||
end
|
||||
|
|
@ -212,10 +212,10 @@ class ProjectController < ApplicationController
|
|||
protected
|
||||
|
||||
def check_user_set_project
|
||||
if @params["name"]
|
||||
@project = Project.find_by_name_and_user_id(deurlize(@params["name"]), @user.id)
|
||||
elsif @params['id']
|
||||
@project = Project.find_by_id_and_user_id(@params["id"], @user.id)
|
||||
if params["name"]
|
||||
@project = Project.find_by_name_and_user_id(deurlize(params["name"]), @user.id)
|
||||
elsif params['id']
|
||||
@project = Project.find_by_id_and_user_id(params["id"], @user.id)
|
||||
else
|
||||
redirect_to(:controller => "project", :action => "list" )
|
||||
end
|
||||
|
|
@ -240,7 +240,7 @@ class ProjectController < ApplicationController
|
|||
end
|
||||
|
||||
def check_user_return_item
|
||||
item = Todo.find( @params['id'] )
|
||||
item = Todo.find( params['id'] )
|
||||
if @user == item.user
|
||||
return item
|
||||
else
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ class TodoController < ApplicationController
|
|||
def add_item
|
||||
self.init
|
||||
@item = @user.todos.build
|
||||
@item.attributes = @params["todo"]
|
||||
@item.attributes = params["todo"]
|
||||
|
||||
if @item.due?
|
||||
@item.due = Date.strptime(@params["todo"]["due"], @user.preferences["date_format"])
|
||||
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
|
||||
else
|
||||
@item.due = ""
|
||||
end
|
||||
|
|
@ -87,10 +87,10 @@ class TodoController < ApplicationController
|
|||
#
|
||||
def add_deferred_item
|
||||
self.init
|
||||
@tickle = Deferred.create(@params["todo"])
|
||||
@tickle = Deferred.create(params["todo"])
|
||||
|
||||
if @tickle.due?
|
||||
@tickle.due = Date.strptime(@params["todo"]["due"], @user.preferences["date_format"])
|
||||
@tickle.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
|
||||
else
|
||||
@tickle.due = ""
|
||||
end
|
||||
|
|
@ -162,15 +162,15 @@ class TodoController < ApplicationController
|
|||
#
|
||||
def update_action
|
||||
self.init
|
||||
if @params["on_project_page"] == true
|
||||
if params["on_project_page"] == true
|
||||
@on_page = "project"
|
||||
end
|
||||
@item = check_user_return_item
|
||||
@original_item_context_id = @item.context_id
|
||||
@item.attributes = @params["item"]
|
||||
@item.attributes = params["item"]
|
||||
|
||||
if @item.due?
|
||||
@item.due = Date.strptime(@params["item"]["due"], @user.preferences["date_format"])
|
||||
@item.due = Date.strptime(params["item"]["due"], @user.preferences["date_format"])
|
||||
else
|
||||
@item.due = ""
|
||||
end
|
||||
|
|
@ -182,10 +182,10 @@ class TodoController < ApplicationController
|
|||
#self.init
|
||||
@tickle = check_user_return_item
|
||||
@original_item_context_id = @tickle.context_id
|
||||
@tickle.attributes = @params["item"]
|
||||
@tickle.attributes = params["item"]
|
||||
|
||||
if @tickle.due?
|
||||
@tickle.due = Date.strptime(@params["item"]["due"], @user.preferences["date_format"])
|
||||
@tickle.due = Date.strptime(params["item"]["due"], @user.preferences["date_format"])
|
||||
else
|
||||
@tickle.due = ""
|
||||
end
|
||||
|
|
@ -280,7 +280,7 @@ class TodoController < ApplicationController
|
|||
protected
|
||||
|
||||
def check_user_return_item
|
||||
item = Todo.find( @params['id'] )
|
||||
item = Todo.find( params['id'] )
|
||||
if @user == item.user
|
||||
return item
|
||||
else
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ class UserController < ApplicationController
|
|||
end
|
||||
|
||||
def update_preferences
|
||||
@user.preferences = { "date_format" => "#{@params['prefs']['date_format']}",
|
||||
"week_starts" => "#{@params['prefs']['week_starts']}",
|
||||
"no_completed" => "#{@params['prefs']['no_completed']}",
|
||||
"staleness_starts" => "#{@params['prefs']['staleness_starts']}",
|
||||
"due_style" => "#{@params['prefs']['due_style']}",
|
||||
"admin_email" => "#{@params['prefs']['admin_email']}"
|
||||
@user.preferences = { "date_format" => "#{params['prefs']['date_format']}",
|
||||
"week_starts" => "#{params['prefs']['week_starts']}",
|
||||
"no_completed" => "#{params['prefs']['no_completed']}",
|
||||
"staleness_starts" => "#{params['prefs']['staleness_starts']}",
|
||||
"due_style" => "#{params['prefs']['due_style']}",
|
||||
"admin_email" => "#{params['prefs']['admin_email']}"
|
||||
}
|
||||
if @user.save
|
||||
redirect_to :action => 'preferences'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue