mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-08 05:32:37 +01:00
Merge branch 'master' into new-gui
Conflicts: app/views/projects/_project_settings.html.erb app/views/todos/_todo.html.erb
This commit is contained in:
commit
9c86396ef0
36 changed files with 94 additions and 105 deletions
|
|
@ -45,23 +45,20 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def set_session_expiration
|
||||
# http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions
|
||||
unless session == nil
|
||||
return if self.controller_name == 'feed' or session['noexpiry'] == "on"
|
||||
# If the method is called by the feed controller (which we don't have
|
||||
# under session control) or if we checked the box to keep logged in on
|
||||
# login don't set the session expiry time.
|
||||
if session
|
||||
# Get expiry time (allow ten seconds window for the case where we have
|
||||
# none)
|
||||
expiry_time = session['expiry_time'] || Time.now + 10
|
||||
if expiry_time < Time.now
|
||||
# Too late, matey... bang goes your session!
|
||||
reset_session
|
||||
else
|
||||
# Okay, you get another hour
|
||||
session['expiry_time'] = Time.now + (60*60)
|
||||
end
|
||||
end
|
||||
# If the method is called by the feed controller (which we don't have
|
||||
# under session control) or if we checked the box to keep logged in on
|
||||
# login don't set the session expiry time.
|
||||
return if session.nil? || self.controller_name == 'feed' || session['noexpiry'] == "on"
|
||||
|
||||
# Get expiry time (allow ten seconds window for the case where we have
|
||||
# none)
|
||||
expiry_time = session['expiry_time'] || Time.now + 10
|
||||
if expiry_time < Time.now
|
||||
# Too late, matey... bang goes your session!
|
||||
reset_session
|
||||
else
|
||||
# Okay, you get another hour
|
||||
session['expiry_time'] = Time.now + (60*60)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -159,7 +156,7 @@ class ApplicationController < ActionController::Base
|
|||
super # handle xml http auth via our own login code
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def sanitize(arg)
|
||||
ActionController::Base.helpers.sanitize(arg)
|
||||
end
|
||||
|
|
@ -272,10 +269,11 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def all_done_todos_for(object)
|
||||
object_name = object.class.name.downcase # context or project
|
||||
@source_view = object_name
|
||||
@source_view = object_name
|
||||
@page_title = t("#{object_name.pluralize}.all_completed_tasks_title", "#{object_name}_name".to_sym => object.name)
|
||||
|
||||
@done = object.todos.completed.paginate :page => params[:page], :per_page => 20, :order => 'completed_at DESC', :include => Todo::DEFAULT_INCLUDES
|
||||
@done = object.todos.completed.reorder('completed_at DESC').includes(Todo::DEFAULT_INCLUDES).
|
||||
paginate(:page => params[:page], :per_page => 20)
|
||||
@count = @done.size
|
||||
render :template => 'todos/all_done'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,11 +18,7 @@ class ContextsController < ApplicationController
|
|||
format.html &render_contexts_html
|
||||
format.m &render_contexts_mobile
|
||||
format.xml { render :xml => @all_contexts.to_xml( :except => :user_id ) }
|
||||
format.rss do
|
||||
@feed_title = 'Tracks Contexts'
|
||||
@feed_description = "Lists all the contexts for #{current_user.display_name}"
|
||||
end
|
||||
format.atom do
|
||||
format.any(:rss, :atom) do
|
||||
@feed_title = 'Tracks Contexts'
|
||||
@feed_description = "Lists all the contexts for #{current_user.display_name}"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class PreferencesController < ApplicationController
|
|||
user_updated = current_user.update_attributes(user_params)
|
||||
prefs_updated = current_user.preference.update_attributes(prefs_params)
|
||||
if (user_updated && prefs_updated)
|
||||
if !params['user']['password'].blank? # password updated?
|
||||
if params['user']['password'].present? # password updated?
|
||||
logout_user t('preferences.password_changed')
|
||||
else
|
||||
preference_updated
|
||||
|
|
|
|||
|
|
@ -38,11 +38,7 @@ class ProjectsController < ApplicationController
|
|||
cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
||||
end
|
||||
format.xml { render :xml => @projects.to_xml( :except => :user_id ) }
|
||||
format.rss do
|
||||
@feed_title = I18n.t('models.project.feed_title')
|
||||
@feed_description = I18n.t('models.project.feed_description', :username => current_user.display_name)
|
||||
end
|
||||
format.atom do
|
||||
format.any(:rss, :atom) do
|
||||
@feed_title = I18n.t('models.project.feed_title')
|
||||
@feed_description = I18n.t('models.project.feed_description', :username => current_user.display_name)
|
||||
end
|
||||
|
|
@ -339,7 +335,7 @@ class ProjectsController < ApplicationController
|
|||
default_context_name = p['default_context_name']
|
||||
p.delete('default_context_name')
|
||||
|
||||
unless default_context_name.blank?
|
||||
if default_context_name.present?
|
||||
default_context = current_user.contexts.where(:name => default_context_name).first_or_create
|
||||
p['default_context_id'] = default_context.id
|
||||
end
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class RecurringTodosController < ApplicationController
|
|||
end
|
||||
|
||||
# update context
|
||||
if params['recurring_todo']['context_id'].blank? && !params['context_name'].blank?
|
||||
if params['recurring_todo']['context_id'].blank? && params['context_name'].present?
|
||||
context = current_user.contexts.where(:name => params['context_name'].strip).first
|
||||
unless context
|
||||
context = current_user.contexts.build
|
||||
|
|
@ -129,7 +129,7 @@ class RecurringTodosController < ApplicationController
|
|||
end
|
||||
|
||||
@saved = @recurring_todo.save
|
||||
unless (@saved == false) || p.tag_list.blank?
|
||||
if @saved && p.tag_list.present?
|
||||
@recurring_todo.tag_with(p.tag_list)
|
||||
@recurring_todo.tags.reload
|
||||
end
|
||||
|
|
@ -255,14 +255,14 @@ class RecurringTodosController < ApplicationController
|
|||
end
|
||||
|
||||
def project_specified_by_name?
|
||||
return false unless @attributes['project_id'].blank?
|
||||
return false if @attributes['project_id'].present?
|
||||
return false if project_name.blank?
|
||||
return false if project_name == 'None'
|
||||
true
|
||||
end
|
||||
|
||||
def context_specified_by_name?
|
||||
return false unless @attributes['context_id'].blank?
|
||||
return false if @attributes['context_id'].present?
|
||||
return false if context_name.blank?
|
||||
true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ module Todos
|
|||
end
|
||||
|
||||
def sequential?
|
||||
return !@params[:todos_sequential].blank? && @params[:todos_sequential]=='true'
|
||||
return @params[:todos_sequential].present? && @params[:todos_sequential]=='true'
|
||||
end
|
||||
|
||||
def specified_by_name?(group_type)
|
||||
|
|
@ -98,18 +98,18 @@ module Todos
|
|||
|
||||
def specified_by_id?(group_type)
|
||||
group_id = send("#{group_type}_id")
|
||||
!group_id.blank?
|
||||
group_id.present?
|
||||
end
|
||||
|
||||
def project_specified_by_name?
|
||||
return false unless @attributes['project_id'].blank?
|
||||
return false if @attributes['project_id'].present?
|
||||
return false if project_name.blank?
|
||||
return false if project_name == 'None'
|
||||
true
|
||||
end
|
||||
|
||||
def context_specified_by_name?
|
||||
return false unless @attributes['context_id'].blank?
|
||||
return false if @attributes['context_id'].present?
|
||||
return false if context_name.blank?
|
||||
true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@ class TodosController < ApplicationController
|
|||
render :content_type => Mime::TEXT
|
||||
end
|
||||
format.xml { render :xml => @todos.to_xml( *todo_xml_params ) }
|
||||
format.rss { @feed_title, @feed_description = 'Tracks Actions', "Actions for #{current_user.display_name}" }
|
||||
format.atom { @feed_title, @feed_description = 'Tracks Actions', "Actions for #{current_user.display_name}" }
|
||||
format.any(:rss, :atom) { @feed_title, @feed_description = 'Tracks Actions', "Actions for #{current_user.display_name}" }
|
||||
format.ics
|
||||
end
|
||||
end
|
||||
|
|
@ -76,7 +75,7 @@ class TodosController < ApplicationController
|
|||
def create
|
||||
@source_view = params['_source_view'] || 'todo'
|
||||
@default_context = current_user.contexts.where(:name => params['default_context_name']).first
|
||||
@default_project = current_user.projects.where(:name => params['default_project_name']).first unless params['default_project_name'].blank?
|
||||
@default_project = current_user.projects.where(:name => params['default_project_name']).first if params['default_project_name'].present?
|
||||
|
||||
@tag_name = params['_tag_name']
|
||||
|
||||
|
|
@ -94,7 +93,7 @@ class TodosController < ApplicationController
|
|||
if @todo.errors.empty?
|
||||
@todo.add_predecessor_list(p.predecessor_list)
|
||||
@saved = @todo.save
|
||||
@todo.tag_with(tag_list) if @saved && !tag_list.blank?
|
||||
@todo.tag_with(tag_list) if @saved && tag_list.present?
|
||||
@todo.update_state_from_project if @saved
|
||||
@todo.block! if @todo.should_be_blocked?
|
||||
else
|
||||
|
|
@ -159,7 +158,7 @@ class TodosController < ApplicationController
|
|||
|
||||
# first build all todos and check if they would validate on save
|
||||
params[:todo][:multiple_todos].split("\n").map do |line|
|
||||
unless line.blank? #ignore blank lines
|
||||
if line.present? #ignore blank lines
|
||||
@todo = current_user.todos.build({:description => line, :context_id => p.context_id, :project_id => p.project_id})
|
||||
validates &&= @todo.valid?
|
||||
|
||||
|
|
@ -177,8 +176,8 @@ class TodosController < ApplicationController
|
|||
todo.add_predecessor(@predecessor)
|
||||
todo.block!
|
||||
end
|
||||
|
||||
todo.tag_with(tag_list) unless (@saved == false) || tag_list.blank?
|
||||
|
||||
todo.tag_with(tag_list) if @saved && tag_list.present?
|
||||
|
||||
@todos << todo
|
||||
@not_done_todos << todo if p.new_context_created || p.new_project_created
|
||||
|
|
@ -205,7 +204,7 @@ class TodosController < ApplicationController
|
|||
else
|
||||
@multiple_error = @todos.size > 0 ? "" : t('todos.next_action_needed')
|
||||
@saved = false
|
||||
@default_tags = current_user.projects.where(:name => @initial_project_name).default_tags unless @initial_project_name.blank?
|
||||
@default_tags = current_user.projects.where(:name => @initial_project_name).default_tags if @initial_project_name.present?
|
||||
end
|
||||
|
||||
@status_message = @todos.size > 1 ? t('todos.added_new_next_action_plural') : t('todos.added_new_next_action_singular')
|
||||
|
|
@ -1170,7 +1169,7 @@ end
|
|||
|
||||
def update_context
|
||||
@context_changed = false
|
||||
if params['todo']['context_id'].blank? && !params['context_name'].blank?
|
||||
if params['todo']['context_id'].blank? && params['context_name'].present?
|
||||
context = current_user.contexts.where(:name => params['context_name'].strip).first
|
||||
unless context
|
||||
@new_context = current_user.contexts.build
|
||||
|
|
@ -1278,21 +1277,21 @@ end
|
|||
# all completed todos [today@00:00, today@now]
|
||||
def get_done_today(completed_todos, includes = {:include => Todo::DEFAULT_INCLUDES})
|
||||
start_of_this_day = Time.zone.now.beginning_of_day
|
||||
completed_todos.completed_after(start_of_this_day).all(includes)
|
||||
completed_todos.completed_after(start_of_this_day).includes(includes[:include])
|
||||
end
|
||||
|
||||
# all completed todos [begin_of_week, start_of_today]
|
||||
def get_done_rest_of_week(completed_todos, includes = {:include => Todo::DEFAULT_INCLUDES})
|
||||
start_of_this_week = Time.zone.now.beginning_of_week
|
||||
start_of_this_day = Time.zone.now.beginning_of_day
|
||||
completed_todos.completed_before(start_of_this_day).completed_after(start_of_this_week).all(includes)
|
||||
completed_todos.completed_before(start_of_this_day).completed_after(start_of_this_week).includes(includes[:include])
|
||||
end
|
||||
|
||||
# all completed todos [begin_of_month, begin_of_week]
|
||||
def get_done_rest_of_month(completed_todos, includes = {:include => Todo::DEFAULT_INCLUDES})
|
||||
start_of_this_month = Time.zone.now.beginning_of_month
|
||||
start_of_this_week = Time.zone.now.beginning_of_week
|
||||
completed_todos.completed_before(start_of_this_week).completed_after(start_of_this_month).all(includes)
|
||||
completed_todos.completed_before(start_of_this_week).completed_after(start_of_this_month).includes(includes[:include])
|
||||
end
|
||||
|
||||
def get_not_done_todos
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue