Merge branch 'master' into rails4

Conflicts:
	Gemfile.lock
	config/routes.rb
This commit is contained in:
Reinier Balt 2013-06-17 09:25:02 +02:00
commit 4a485558e2
51 changed files with 5475 additions and 5015 deletions

View file

@ -21,6 +21,7 @@ class ApplicationController < ActionController::Base
before_filter :set_time_zone
before_filter :set_zindex_counter
before_filter :set_locale
append_before_filter :set_group_view_by
prepend_before_filter :login_required
prepend_before_filter :enable_mobile_content_negotiation
after_filter :set_charset
@ -291,4 +292,8 @@ class ApplicationController < ActionController::Base
render :template => 'todos/done'
end
def set_group_view_by
@group_view_by = params['_group_view_by'] || cookies['group_view_by'] || 'context'
end
end

View file

@ -42,6 +42,7 @@ class ContextsController < ApplicationController
@max_completed = current_user.prefs.show_number_completed
@done = @context.todos.completed.limit(@max_completed).reorder("todos.completed_at DESC, todos.created_at DESC").includes(Todo::DEFAULT_INCLUDES)
@not_done_todos = @context.todos.active.reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC").includes(Todo::DEFAULT_INCLUDES)
@todos_without_project = @not_done_todos.select{|t| t.project.nil?}
@deferred_todos = @context.todos.deferred.includes(Todo::DEFAULT_INCLUDES)
@pending_todos = @context.todos.pending.includes(Todo::DEFAULT_INCLUDES)
@ -49,6 +50,9 @@ class ContextsController < ApplicationController
@projects = current_user.projects
@contexts = current_user.contexts
@projects_to_show = @projects.active
@contexts_to_show = [@context]
@count = @not_done_todos.count + @deferred_todos.count + @pending_todos.count
@page_title = "TRACKS::Context: #{@context.name}"
respond_to do |format|

View file

@ -47,29 +47,6 @@ class LoginController < ApplicationController
logout_user
end
def expire_session
# this is a hack to enable cucumber to expire a session by calling this
# method. The method will be unavailable for production environment
@user.forget_me if logged_in?
cookies.delete :auth_token
session['user_id'] = nil
reset_session
unless Rails.env.production?
session['expiry_time'] = Time.now
respond_to do |format|
format.html { render :text => "Session expired for test purposes"}
format.js { render :text => "" }
end
else
respond_to do |format|
format.html { render :text => "Not available for production use"}
format.js { render :text => "" }
end
end
end
def check_expiry
# Gets called by periodically_call_remote to check whether
# the session has timed out yet

View file

@ -131,12 +131,14 @@ class ProjectsController < ApplicationController
@not_done_todos = @project.todos.active_or_hidden.includes(Todo::DEFAULT_INCLUDES)
@deferred_todos = @project.todos.deferred.includes(Todo::DEFAULT_INCLUDES)
@pending_todos = @project.todos.pending.includes(Todo::DEFAULT_INCLUDES)
@contexts_to_show = current_user.contexts.active
@projects_to_show = [@project]
@done = {}
@done = @project.todos.completed.
reorder("todos.completed_at DESC").
limit(current_user.prefs.show_number_completed).
includes(Todo::DEFAULT_INCLUDES) unless current_user.prefs.show_number_completed == 0
includes(Todo::DEFAULT_INCLUDES) unless @max_completed == 0
@count = @not_done_todos.size
@down_count = @count + @deferred_todos.size + @pending_todos.size

View file

@ -3,7 +3,6 @@ class TodosController < ApplicationController
skip_before_filter :login_required, :only => [:index, :tag]
prepend_before_filter :login_or_feed_token_required, :only => [:index, :tag]
append_before_filter :find_and_activate_ready, :only => [:index, :list_deferred]
append_before_filter :set_group_view_by, :only => [:index, :tag, :create, :list_deferred, :destroy, :defer, :update, :toggle_check]
protect_from_forgery :except => :check_deferred
@ -594,13 +593,8 @@ class TodosController < ApplicationController
get_params_for_tag_view
@page_title = t('todos.tagged_page_title', :tag_name => @tag_title)
@source_view = params['_source_view'] || 'tag'
if mobile?
# mobile tags are routed with :name ending on .m. So we need to chomp it
@tag_name = @tag_name.chomp('.m')
else
init_data_for_sidebar
end
init_data_for_sidebar unless mobile?
todos_with_tag_ids = find_todos_with_tag_expr(@tag_expr)
@ -833,8 +827,9 @@ class TodosController < ApplicationController
end
def get_params_for_tag_view
# use sanitize to prevent XSS attacks
filter_format_for_tag_view
# use sanitize to prevent XSS attacks
@tag_expr = []
@tag_expr << sanitize(params[:name]).split(',')
@tag_expr << sanitize(params[:and]).split(',') if params[:and]
@ -850,6 +845,27 @@ class TodosController < ApplicationController
@tag_title = @single_tag ? @tag_name : tag_title(@tag_expr)
end
def filter_format_for_tag_view
# routes for tag view do not set :format
if params[:name] =~ /.*\.m$/
set_format_for_tag_view(:m)
elsif params[:name] =~ /.*\.txt$/
set_format_for_tag_view(:txt)
# set content-type to text/plain or it remains text/html
response.headers["Content-Type"] = 'text/plain'
elsif params[:format].nil?
# if no format is given, default to html
# note that if url has ?format=m, we should not overwrite it here
request.format, params[:format] = :html, :html
end
end
def set_format_for_tag_view(format)
# tag name ends with .m, set format to :m en remove .m from name
request.format, params[:format] = format, format
params[:name] = params[:name].chomp(".#{format.to_s}")
end
def get_ids_from_tag_expr(tag_expr)
ids = []
tag_expr.each do |tag_list|