mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-20 16:06:10 +01:00
Code style fixes
This commit is contained in:
parent
c6bbc67dab
commit
d8acf60049
72 changed files with 458 additions and 594 deletions
|
|
@ -60,7 +60,6 @@ class ApplicationController < ActionController::Base
|
|||
# Returns a count of next actions in the given context or project The result
|
||||
# is count and a string descriptor, correctly pluralised if there are no
|
||||
# actions or multiple actions
|
||||
#
|
||||
def count_undone_todos_phrase(todos_parent)
|
||||
count = count_undone_todos(todos_parent)
|
||||
deferred_count = count_deferred_todos(todos_parent)
|
||||
|
|
@ -83,13 +82,13 @@ class ApplicationController < ActionController::Base
|
|||
init_hidden_todo_counts(['context']) if !@context_hidden_todo_counts
|
||||
count = @context_hidden_todo_counts[todos_parent.id]
|
||||
else
|
||||
count = eval "@#{todos_parent.class.to_s.downcase}_not_done_counts[#{todos_parent.id}]"
|
||||
count = eval("@#{todos_parent.class.to_s.downcase}_not_done_counts[#{todos_parent.id}]", binding, __FILE__, __LINE__)
|
||||
end
|
||||
count || 0
|
||||
end
|
||||
|
||||
def count_deferred_todos(todos_parent)
|
||||
return todos_parent.nil? ? 0 : eval("@#{todos_parent.class.to_s.downcase}_deferred_counts[#{todos_parent.id}]") || 0
|
||||
return todos_parent.nil? ? 0 : eval("@#{todos_parent.class.to_s.downcase}_deferred_counts[#{todos_parent.id}]", binding, __FILE__, __LINE__) || 0
|
||||
end
|
||||
|
||||
# Convert a date object to the format specified in the user's preferences in
|
||||
|
|
@ -101,8 +100,8 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def for_autocomplete(coll, substr)
|
||||
if substr # protect agains empty request
|
||||
filtered = coll.find_all{|item| item.name.downcase.include? substr.downcase}
|
||||
json_elems = Array[*filtered.map{ |e| {:id => e.id.to_s, :value => e.name} }].to_json
|
||||
filtered = coll.find_all{ |item| item.name.downcase.include? substr.downcase }
|
||||
json_elems = Array[*filtered.map{ |e| { :id => e.id.to_s, :value => e.name } }].to_json
|
||||
return json_elems
|
||||
else
|
||||
return ""
|
||||
|
|
@ -110,7 +109,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def format_dependencies_as_json_for_auto_complete(entries)
|
||||
json_elems = Array[*entries.map{ |e| {:value => e.id.to_s, :label => e.specification} }].to_json
|
||||
json_elems = Array[*entries.map{ |e| { :value => e.id.to_s, :label => e.specification } }].to_json
|
||||
return json_elems
|
||||
end
|
||||
|
||||
|
|
@ -138,7 +137,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def handle_unverified_request
|
||||
unless request.format=="application/xml"
|
||||
unless request.format == "application/xml"
|
||||
super # handle xml http auth via our own login code
|
||||
end
|
||||
end
|
||||
|
|
@ -204,7 +203,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
private
|
||||
|
||||
def parse_date_per_user_prefs( s )
|
||||
def parse_date_per_user_prefs(s)
|
||||
prefs.parse_date(s)
|
||||
end
|
||||
|
||||
|
|
@ -220,16 +219,16 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def init_not_done_counts(parents = ['project','context'])
|
||||
def init_not_done_counts(parents=['project', 'context'])
|
||||
parents.each do |parent|
|
||||
eval("@#{parent}_not_done_counts ||= current_user.todos.active.count_by_group('#{parent}_id')")
|
||||
eval("@#{parent}_deferred_counts ||= current_user.todos.deferred.count_by_group('#{parent}_id')")
|
||||
eval("@#{parent}_not_done_counts ||= current_user.todos.active.count_by_group('#{parent}_id')", binding, __FILE__, __LINE__)
|
||||
eval("@#{parent}_deferred_counts ||= current_user.todos.deferred.count_by_group('#{parent}_id')", binding, __FILE__, __LINE__)
|
||||
end
|
||||
end
|
||||
|
||||
def init_hidden_todo_counts(parents = ['project', 'context'])
|
||||
def init_hidden_todo_counts(parents=['project', 'context'])
|
||||
parents.each do |parent|
|
||||
eval("@#{parent}_hidden_todo_counts ||= current_user.todos.active_or_hidden.count_by_group('#{parent}_id')")
|
||||
eval("@#{parent}_hidden_todo_counts ||= current_user.todos.active_or_hidden.count_by_group('#{parent}_id')", binding, __FILE__, __LINE__)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -252,9 +251,9 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def todo_xml_params
|
||||
if params[:limit_fields] == 'index'
|
||||
return [:only => [:id, :created_at, :updated_at, :completed_at] ]
|
||||
return [:only => [:id, :created_at, :updated_at, :completed_at]]
|
||||
else
|
||||
return [:except => :user_id, :include => [:tags, :predecessors, :successors] ]
|
||||
return [:except => :user_id, :include => [:tags, :predecessors, :successors]]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -263,8 +262,8 @@ class ApplicationController < ActionController::Base
|
|||
@source_view = "all_done"
|
||||
@page_title = t("#{object_name.pluralize}.all_completed_tasks_title", "#{object_name}_name".to_sym => object.name)
|
||||
|
||||
@done = object.todos.completed.reorder('completed_at DESC').includes(Todo::DEFAULT_INCLUDES).
|
||||
paginate(:page => params[:page], :per_page => 20)
|
||||
@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
|
||||
|
|
@ -284,5 +283,4 @@ class ApplicationController < ActionController::Base
|
|||
def set_group_view_by
|
||||
@group_view_by = params['_group_view_by'] || cookies['group_view_by'] || 'context'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ class CalendarController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html
|
||||
format.m {
|
||||
cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
||||
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
}
|
||||
format.ics {
|
||||
render :action => 'show', :layout => false, :content_type => Mime[:ics]
|
||||
}
|
||||
format.xml {
|
||||
render :xml => @due_all.to_xml( *[todo_xml_params[0].merge({:root => :todos})] )
|
||||
render :xml => @due_all.to_xml( *[todo_xml_params[0].merge({ :root => :todos })] )
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class ContextsController < ApplicationController
|
||||
|
||||
helper :todos
|
||||
|
||||
before_action :init, :except => [:index, :create, :destroy, :order]
|
||||
|
|
@ -19,15 +18,15 @@ class ContextsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html &render_contexts_html
|
||||
format.m &render_contexts_mobile
|
||||
format.xml { render :xml => @all_contexts.to_xml(:root => :contexts, :except => :user_id) }
|
||||
format.m &render_contexts_mobile
|
||||
format.xml { render :xml => @all_contexts.to_xml(:root => :contexts, :except => :user_id) }
|
||||
format.any(:rss, :atom) do
|
||||
@feed_title = 'Tracks Contexts'
|
||||
@feed_description = "Lists all the contexts for #{current_user.display_name}"
|
||||
end
|
||||
format.text do
|
||||
# somehow passing Mime[:text] using content_type to render does not work
|
||||
headers['Content-Type']=Mime[:text].to_s
|
||||
headers['Content-Type'] = Mime[:text].to_s
|
||||
render :action => 'index', :layout => false, :content_type => Mime[:text]
|
||||
end
|
||||
format.autocomplete &render_autocomplete
|
||||
|
|
@ -41,7 +40,7 @@ class ContextsController < ApplicationController
|
|||
@max_completed = current_user.prefs.show_number_completed
|
||||
@done = @context.todos.completed.limit(@max_completed).reorder(Arel.sql("todos.completed_at DESC, todos.created_at DESC")).includes(Todo::DEFAULT_INCLUDES)
|
||||
@not_done_todos = @context.todos.active_or_hidden.not_project_hidden.reorder(Arel.sql('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?}
|
||||
@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)
|
||||
|
|
@ -93,7 +92,6 @@ class ContextsController < ApplicationController
|
|||
end
|
||||
|
||||
# Edit the details of the context
|
||||
#
|
||||
def update
|
||||
process_params_for_update
|
||||
|
||||
|
|
@ -113,12 +111,12 @@ class ContextsController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.js
|
||||
format.xml {
|
||||
if @saved
|
||||
render :xml => @context.to_xml( :except => :user_id )
|
||||
else
|
||||
render :body => "Error on update: #{@context.errors.full_messages.inject("") {|v, e| v + e + " " }}", :status => 409
|
||||
end
|
||||
}
|
||||
if @saved
|
||||
render :xml => @context.to_xml(:except => :user_id)
|
||||
else
|
||||
render :body => "Error on update: #{@context.errors.full_messages.inject("") { |v, e| v + e + " " }}", :status => 409
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -204,7 +202,7 @@ class ContextsController < ApplicationController
|
|||
@active_contexts = current_user.contexts.active
|
||||
@hidden_contexts = current_user.contexts.hidden
|
||||
@down_count = @active_contexts.size + @hidden_contexts.size
|
||||
cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
||||
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
render
|
||||
end
|
||||
end
|
||||
|
|
@ -214,7 +212,7 @@ class ContextsController < ApplicationController
|
|||
@page_title = "TRACKS::List actions in "+@context.name
|
||||
@not_done = @not_done_todos.select {|t| t.context_id == @context.id }
|
||||
@down_count = @not_done.size
|
||||
cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
||||
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
@mobile_from_context = @context.id
|
||||
render
|
||||
end
|
||||
|
|
@ -270,5 +268,4 @@ class ContextsController < ApplicationController
|
|||
return false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class DataController < ApplicationController
|
||||
|
||||
require 'csv'
|
||||
|
||||
def index
|
||||
|
|
@ -7,7 +6,6 @@ class DataController < ApplicationController
|
|||
end
|
||||
|
||||
def import
|
||||
|
||||
end
|
||||
|
||||
def csv_map
|
||||
|
|
@ -147,8 +145,7 @@ class DataController < ApplicationController
|
|||
def csv_notes
|
||||
content_type = 'text/csv'
|
||||
CSV.generate(result = "") do |csv|
|
||||
csv << ["id", "User ID", "Project", "Note",
|
||||
"Created at", "Updated at"]
|
||||
csv << ["id", "User ID", "Project", "Note", "Created at", "Updated at"]
|
||||
# had to remove project include because it's association order is leaking
|
||||
# through and causing an ambiguous column ref even with_exclusive_scope
|
||||
# didn't seem to help -JamesKebinger
|
||||
|
|
@ -198,7 +195,7 @@ class DataController < ApplicationController
|
|||
|
||||
# adjusts time to utc
|
||||
def adjust_time(timestring)
|
||||
if (timestring=='') or ( timestring == nil)
|
||||
if (timestring == '') or (timestring == nil)
|
||||
return nil
|
||||
else
|
||||
return Time.parse(timestring + 'UTC')
|
||||
|
|
@ -210,8 +207,8 @@ class DataController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def sanitize_filename(filename)
|
||||
filename.gsub(/[^0-9A-z.\-]/, '_')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class FeedlistController < ApplicationController
|
||||
|
||||
helper :feedlist
|
||||
|
||||
def index
|
||||
|
|
@ -37,9 +36,8 @@ class FeedlistController < ApplicationController
|
|||
|
||||
def get_feeds_for(object)
|
||||
respond_to do |format|
|
||||
format.html { render :file => "feedlist/get_feeds_for_#{object.class.name.downcase}"}
|
||||
format.html { render :file => "feedlist/get_feeds_for_#{object.class.name.downcase}" }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -59,6 +59,4 @@ class IntegrationsController < ApplicationController
|
|||
|
||||
return result
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class LoginController < ApplicationController
|
|||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.m { render :action => 'login', :layout => 'mobile' }
|
||||
format.m { render :action => 'login', :layout => 'mobile' }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ class LoginController < ApplicationController
|
|||
return unless should_expire_sessions?
|
||||
# Get expiry time (allow ten seconds window for the case where we have none)
|
||||
time_left = expiry_time - Time.now
|
||||
@session_expired = ( time_left < (10*60) ) # Session will time out before the next check
|
||||
@session_expired = ( time_left < (10 * 60) ) # Session will time out before the next check
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
|
|
@ -54,25 +54,25 @@ class LoginController < ApplicationController
|
|||
|
||||
private
|
||||
|
||||
def handle_post_success
|
||||
session['user_id'] = @user.id
|
||||
# If checkbox on login page checked, we don't expire the session after 1 hour
|
||||
# of inactivity and we remember this user for future browser sessions
|
||||
session['noexpiry'] = params['user_noexpiry']
|
||||
msg = (should_expire_sessions?) ? "will expire after 1 hour of inactivity." : "will not expire."
|
||||
notify :notice, "Login successful: session #{msg}"
|
||||
cookies[:tracks_login] = { :value => @user.login, :expires => Time.now + 1.year, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
unless should_expire_sessions?
|
||||
@user.remember_me
|
||||
cookies[:auth_token] = { :value => @user.remember_token , :expires => @user.remember_token_expires_at, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
end
|
||||
redirect_back_or_home
|
||||
def handle_post_success
|
||||
session['user_id'] = @user.id
|
||||
# If checkbox on login page checked, we don't expire the session after 1 hour
|
||||
# of inactivity and we remember this user for future browser sessions
|
||||
session['noexpiry'] = params['user_noexpiry']
|
||||
msg = (should_expire_sessions?) ? "will expire after 1 hour of inactivity." : "will not expire."
|
||||
notify :notice, "Login successful: session #{msg}"
|
||||
cookies[:tracks_login] = { :value => @user.login, :expires => Time.now + 1.year, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
unless should_expire_sessions?
|
||||
@user.remember_me
|
||||
cookies[:auth_token] = { :value => @user.remember_token , :expires => @user.remember_token_expires_at, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
end
|
||||
redirect_back_or_home
|
||||
end
|
||||
|
||||
def handle_post_failure
|
||||
@login = params['user_login']
|
||||
notify :warning, t('login.unsuccessful')
|
||||
end
|
||||
def handle_post_failure
|
||||
@login = params['user_login']
|
||||
notify :warning, t('login.unsuccessful')
|
||||
end
|
||||
|
||||
def should_expire_sessions?
|
||||
session['noexpiry'] != "on"
|
||||
|
|
@ -82,5 +82,4 @@ class LoginController < ApplicationController
|
|||
return Time.now + 10 unless session['expiry_time']
|
||||
DateTime.strptime(session['expiry_time'], "%FT%T.%L%Z")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
require 'openssl'
|
||||
|
||||
class MailgunController < ApplicationController
|
||||
|
||||
skip_before_action :login_required, :only => [:mailgun]
|
||||
before_action :verify, :only => [:mailgun]
|
||||
protect_from_forgery with: :null_session
|
||||
|
|
@ -34,5 +33,4 @@ class MailgunController < ApplicationController
|
|||
return
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class NotesController < ApplicationController
|
||||
|
||||
before_action :set_source_view
|
||||
|
||||
def index
|
||||
|
|
@ -9,7 +8,7 @@ class NotesController < ApplicationController
|
|||
@source_view = 'note_list'
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xml { render :xml => @all_notes.to_xml(:root => :notes, :except => :user_id ) }
|
||||
format.xml { render :xml => @all_notes.to_xml(:root => :notes, :except => :user_id) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -75,5 +74,4 @@ class NotesController < ApplicationController
|
|||
def note_params
|
||||
params.require(:note).permit(:project_id, :body)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class PreferencesController < ApplicationController
|
||||
|
||||
def index
|
||||
@page_title = t('preferences.page_title')
|
||||
@prefs = current_user.prefs
|
||||
|
|
@ -31,7 +30,7 @@ class PreferencesController < ApplicationController
|
|||
render :body => l(Date.current, :format => format)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def prefs_params
|
||||
params.require(:prefs).permit(
|
||||
|
|
@ -52,5 +51,4 @@ private
|
|||
notify :notice, t('preferences.updated')
|
||||
redirect_to :action => 'index'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class ProjectsController < ApplicationController
|
||||
|
||||
helper :application, :todos, :notes
|
||||
before_action :set_source_view
|
||||
before_action :set_project_from_params, :only => [:update, :destroy, :show, :edit, :set_reviewed]
|
||||
|
|
@ -16,14 +15,14 @@ class ProjectsController < ApplicationController
|
|||
init_not_done_counts(['project'])
|
||||
init_hidden_todo_counts(['project'])
|
||||
if params[:only_active_with_no_next_actions]
|
||||
@projects = current_user.projects.active.select { |p| count_undone_todos(p) == 0 }
|
||||
@projects = current_user.projects.active.select { |p| count_undone_todos(p) == 0 }
|
||||
else
|
||||
@projects = current_user.projects
|
||||
end
|
||||
@active_projects = current_user.projects.active
|
||||
@hidden_projects = current_user.projects.hidden
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
format.html do
|
||||
@page_title = t('projects.list_projects')
|
||||
@count = current_user.projects.count
|
||||
@completed_projects = current_user.projects.completed.limit(10)
|
||||
|
|
@ -32,7 +31,7 @@ class ProjectsController < ApplicationController
|
|||
current_user.projects.cache_note_counts
|
||||
@new_project = current_user.projects.build
|
||||
end
|
||||
format.m do
|
||||
format.m do
|
||||
@completed_projects = current_user.projects.completed
|
||||
@down_count = @active_projects.size + @hidden_projects.size + @completed_projects.size
|
||||
cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
||||
|
|
@ -58,9 +57,9 @@ class ProjectsController < ApplicationController
|
|||
@source_view = params['_source_view'] || 'review'
|
||||
@page_title = t('projects.list_reviews')
|
||||
projects = current_user.projects
|
||||
@projects_to_review = projects.select {|p| p.needs_review?(current_user)}
|
||||
@stalled_projects = projects.select {|p| p.stalled?}
|
||||
@blocked_projects = projects.select {|p| p.blocked?}
|
||||
@projects_to_review = projects.select { |p| p.needs_review?(current_user) }
|
||||
@stalled_projects = projects.select { |p| p.stalled? }
|
||||
@blocked_projects = projects.select { |p| p.blocked? }
|
||||
@current_projects = projects.uncompleted.select { |p| not (p.needs_review?(current_user)) }.sort_by { |p| p.last_reviewed || Time.zone.at(0) }
|
||||
|
||||
init_not_done_counts(['project'])
|
||||
|
|
@ -85,7 +84,7 @@ class ProjectsController < ApplicationController
|
|||
@total = current_user.projects.completed.count
|
||||
@no_projects = @projects.empty?
|
||||
|
||||
@range_low = (page.to_i-1) * items_per_page + 1
|
||||
@range_low = (page.to_i - 1) * items_per_page + 1
|
||||
@range_high = @range_low + @projects.size - 1
|
||||
|
||||
@range_low = 0 if @total == 0
|
||||
|
|
@ -115,7 +114,7 @@ class ProjectsController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.text {
|
||||
# somehow passing Mime[:text] using content_type to render does not work
|
||||
headers['Content-Type']=Mime[:text].to_s
|
||||
headers['Content-Type'] = Mime[:text].to_s
|
||||
render :action => 'index_text_projects_and_actions', :layout => false, :content_type => Mime[:text]
|
||||
}
|
||||
end
|
||||
|
|
@ -133,13 +132,13 @@ class ProjectsController < ApplicationController
|
|||
@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 @max_completed == 0
|
||||
@done = @project.todos.completed
|
||||
.reorder("todos.completed_at DESC")
|
||||
.limit(current_user.prefs.show_number_completed)
|
||||
.includes(Todo::DEFAULT_INCLUDES) unless @max_completed == 0
|
||||
|
||||
@down_count = @not_done_todos.size + @deferred_todos.size + @pending_todos.size
|
||||
@count=@down_count
|
||||
@count = @down_count
|
||||
@next_project = current_user.projects.next_from(@project)
|
||||
@previous_project = current_user.projects.previous_from(@project)
|
||||
@default_tags = @project.default_tags
|
||||
|
|
@ -148,16 +147,16 @@ class ProjectsController < ApplicationController
|
|||
@contexts = current_user.contexts
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.m do
|
||||
format.m do
|
||||
if @project.default_context.nil?
|
||||
@project_default_context = t('projects.no_default_context')
|
||||
else
|
||||
@project_default_context = t('projects.default_context', :context => @project.default_context.name)
|
||||
end
|
||||
cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
||||
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
@mobile_from_project = @project.id
|
||||
end
|
||||
format.xml do
|
||||
format.xml do
|
||||
render :xml => @project.to_xml(:root => :project, :except => :user_id) { |xml|
|
||||
xml.not_done { @not_done_todos.each { |child| child.to_xml(:builder => xml, :skip_instruct => true) } }
|
||||
xml.deferred { @deferred_todos.each { |child| child.to_xml(:builder => xml, :skip_instruct => true) } }
|
||||
|
|
@ -192,12 +191,11 @@ class ProjectsController < ApplicationController
|
|||
head :created, :location => project_url(@project), :text => @project.id
|
||||
end
|
||||
end
|
||||
format.html {redirect_to :action => 'index'}
|
||||
format.html { redirect_to :action => 'index' }
|
||||
end
|
||||
end
|
||||
|
||||
# Edit the details of the project
|
||||
#
|
||||
def update
|
||||
template = ""
|
||||
|
||||
|
|
@ -252,7 +250,7 @@ class ProjectsController < ApplicationController
|
|||
if @saved
|
||||
render :xml => @project.to_xml( :except => :user_id )
|
||||
else
|
||||
render :body => "Error on update: #{@project.errors.full_messages.inject("") {|v, e| v + e + " " }}", :status => 409
|
||||
render :body => "Error on update: #{@project.errors.full_messages.inject("") { |v, e| v + e + " " }}", :status => 409
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
@ -280,7 +278,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def order
|
||||
project_ids = params["container_project"]
|
||||
@projects = current_user.projects.update_positions( project_ids )
|
||||
@projects = current_user.projects.update_positions(project_ids)
|
||||
head :ok
|
||||
rescue
|
||||
notify :error, $!
|
||||
|
|
@ -350,5 +348,4 @@ class ProjectsController < ApplicationController
|
|||
def project_params
|
||||
params.require(:project).permit(:name, :position, :user_id, :description, :state, :default_context_id, :default_tags)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
module RecurringTodos
|
||||
|
||||
class FormHelper
|
||||
|
||||
def initialize(recurring_todo)
|
||||
@recurring_todo = recurring_todo
|
||||
|
||||
@method_map = {
|
||||
# delegate daily_xxx to daily_pattern.xxx
|
||||
"daily" => {prefix: "", method: daily_pattern},
|
||||
"weekly" => {prefix: "", method: weekly_pattern},
|
||||
"monthly" => {prefix: "", method: monthly_pattern},
|
||||
"yearly" => {prefix: "", method: yearly_pattern},
|
||||
"daily" => { prefix: "", method: daily_pattern },
|
||||
"weekly" => { prefix: "", method: weekly_pattern },
|
||||
"monthly" => { prefix: "", method: monthly_pattern },
|
||||
"yearly" => { prefix: "", method: yearly_pattern },
|
||||
# delegate on_xxx to weekly_pattern.on_xxx
|
||||
"on" => {prefix: "on_", method: weekly_pattern}
|
||||
"on" => { prefix: "on_", method: weekly_pattern }
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -47,7 +45,5 @@ module RecurringTodos
|
|||
# no match, let @recurring_todo handle it, or fail
|
||||
@recurring_todo.send(method, *args)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class RecurringTodosController < ApplicationController
|
||||
|
||||
helper :todos, :recurring_todos
|
||||
|
||||
append_before_action :init, :only => [:index, :new, :edit, :create]
|
||||
|
|
@ -34,7 +33,7 @@ class RecurringTodosController < ApplicationController
|
|||
@completed_recurring_todos = current_user.recurring_todos.completed.paginate :page => page, :per_page => items_per_page
|
||||
@total = @count = current_user.recurring_todos.completed.count
|
||||
|
||||
@range_low = (page.to_i-1) * items_per_page + 1
|
||||
@range_low = (page.to_i - 1) * items_per_page + 1
|
||||
@range_high = @range_low + @completed_recurring_todos.size - 1
|
||||
|
||||
@range_low = 0 if @total == 0
|
||||
|
|
@ -98,7 +97,6 @@ class RecurringTodosController < ApplicationController
|
|||
@completed_remaining = current_user.recurring_todos.completed.count
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
format.html do
|
||||
if @saved
|
||||
notify :notice, t('todos.recurring_deleted_success')
|
||||
|
|
@ -107,7 +105,6 @@ class RecurringTodosController < ApplicationController
|
|||
end
|
||||
redirect_to :action => 'index'
|
||||
end
|
||||
|
||||
format.js do
|
||||
render
|
||||
end
|
||||
|
|
@ -165,7 +162,7 @@ class RecurringTodosController < ApplicationController
|
|||
# derived attributes
|
||||
:weekly_return_monday, :weekly_return_tuesday, :weekly_return_wednesday,
|
||||
:weekly_return_thursday, :weekly_return_friday, :weekly_return_saturday, :weekly_return_sunday
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
def all_recurring_todo_params
|
||||
|
|
@ -230,5 +227,4 @@ class RecurringTodosController < ApplicationController
|
|||
where("fai_todos.id IS NULL").
|
||||
each { |rt| current_user.recurring_todos.find(rt.id).toggle_completion! }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class SearchController < ApplicationController
|
||||
|
||||
helper :todos, :application, :notes, :projects, :contexts
|
||||
|
||||
def results
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
class StatsController < ApplicationController
|
||||
|
||||
SECONDS_PER_DAY = 86400;
|
||||
SECONDS_PER_DAY = 86_400;
|
||||
|
||||
helper :todos, :projects, :recurring_todos
|
||||
append_before_action :init, :except => :index
|
||||
|
|
@ -31,15 +30,15 @@ class StatsController < ApplicationController
|
|||
@max = (@actions_done_last_months_array + @actions_created_last_months_array).max
|
||||
|
||||
# set running avg
|
||||
@actions_done_avg_last_months_array = compute_running_avg_array(@actions_done_last_months_array,month_count+1)
|
||||
@actions_created_avg_last_months_array = compute_running_avg_array(@actions_created_last_months_array,month_count+1)
|
||||
@actions_done_avg_last_months_array = compute_running_avg_array(@actions_done_last_months_array,month_count + 1)
|
||||
@actions_created_avg_last_months_array = compute_running_avg_array(@actions_created_last_months_array,month_count + 1)
|
||||
|
||||
# interpolate avg for this month.
|
||||
@interpolated_actions_created_this_month = interpolate_avg_for_current_month(@actions_created_last_months_array)
|
||||
@interpolated_actions_done_this_month = interpolate_avg_for_current_month(@actions_done_last_months_array)
|
||||
|
||||
@created_count_array = Array.new(month_count+1, actions_last_months.select { |x| x.created_at }.size/month_count)
|
||||
@done_count_array = Array.new(month_count+1, actions_last_months.select { |x| x.completed_at }.size/month_count)
|
||||
@created_count_array = Array.new(month_count + 1, actions_last_months.select { |x| x.created_at }.size / month_count)
|
||||
@done_count_array = Array.new(month_count + 1, actions_last_months.select { |x| x.completed_at }.size / month_count)
|
||||
|
||||
render :layout => false
|
||||
end
|
||||
|
|
@ -52,7 +51,6 @@ class StatsController < ApplicationController
|
|||
|
||||
case params['id']
|
||||
when 'avrt', 'avrt_end' # actions_visible_running_time
|
||||
|
||||
# HACK: because open flash chart uses & to denote the end of a parameter,
|
||||
# we cannot use URLs with multiple parameters (that would use &). So we
|
||||
# revert to using two id's for the same selection. avtr_end means that the
|
||||
|
|
@ -72,11 +70,11 @@ class StatsController < ApplicationController
|
|||
end
|
||||
|
||||
# get all running actions that are visible
|
||||
@actions_running_time = current_user.todos.not_completed.not_hidden.not_deferred_or_blocked.
|
||||
select("todos.id, todos.created_at").
|
||||
reorder("todos.created_at DESC")
|
||||
@actions_running_time = current_user.todos.not_completed.not_hidden.not_deferred_or_blocked
|
||||
.select("todos.id, todos.created_at")
|
||||
.reorder("todos.created_at DESC")
|
||||
|
||||
selected_todo_ids = get_ids_from(@actions_running_time, week_from, week_to, params['id']== 'avrt_end')
|
||||
selected_todo_ids = get_ids_from(@actions_running_time, week_from, week_to, params['id'] == 'avrt_end')
|
||||
@selected_actions = selected_todo_ids.size == 0 ? [] : current_user.todos.where("id in (" + selected_todo_ids.join(",") + ")")
|
||||
@count = @selected_actions.size
|
||||
|
||||
|
|
@ -84,7 +82,7 @@ class StatsController < ApplicationController
|
|||
|
||||
when 'art', 'art_end'
|
||||
week_from = params['index'].to_i
|
||||
week_to = week_from+1
|
||||
week_to = week_from + 1
|
||||
|
||||
@chart = Stats::Chart.new('actions_running_time_data')
|
||||
@page_title = "Actions selected from week "
|
||||
|
|
@ -99,7 +97,7 @@ class StatsController < ApplicationController
|
|||
# get all running actions
|
||||
@actions_running_time = current_user.todos.not_completed.select("id, created_at")
|
||||
|
||||
selected_todo_ids = get_ids_from(@actions_running_time, week_from, week_to, params['id']=='art_end')
|
||||
selected_todo_ids = get_ids_from(@actions_running_time, week_from, week_to, params['id'] == 'art_end')
|
||||
@selected_actions = selected_todo_ids.size == 0 ? [] : current_user.todos.where("id in (#{selected_todo_ids.join(",")})")
|
||||
@count = @selected_actions.size
|
||||
|
||||
|
|
@ -145,7 +143,7 @@ class StatsController < ApplicationController
|
|||
if at_end
|
||||
selected_todo_ids << r.id.to_s if weeks >= week_from
|
||||
else
|
||||
selected_todo_ids << r.id.to_s if weeks.between?(week_from, week_to-1)
|
||||
selected_todo_ids << r.id.to_s if weeks.between?(week_from, week_to - 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -161,12 +159,12 @@ class StatsController < ApplicationController
|
|||
end
|
||||
|
||||
def put_events_into_month_buckets(records, array_size, date_method_on_todo)
|
||||
convert_to_array(records.select { |x| x.send(date_method_on_todo) }, array_size) { |r| [difference_in_months(@today, r.send(date_method_on_todo))]}
|
||||
convert_to_array(records.select { |x| x.send(date_method_on_todo) }, array_size) { |r| [difference_in_months(@today, r.send(date_method_on_todo))] }
|
||||
end
|
||||
|
||||
# assumes date1 > date2
|
||||
def difference_in_days(date1, date2)
|
||||
return ((date1.utc.at_midnight-date2.utc.at_midnight)/SECONDS_PER_DAY).to_i
|
||||
return ((date1.utc.at_midnight - date2.utc.at_midnight) / SECONDS_PER_DAY).to_i
|
||||
end
|
||||
|
||||
# assumes date1 > date2
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
module Todos
|
||||
class TodoCreateParamsHelper
|
||||
|
||||
attr_reader :new_project_created, :new_context_created, :attributes
|
||||
|
||||
def initialize(params, user)
|
||||
|
|
@ -85,7 +84,7 @@ module Todos
|
|||
end
|
||||
|
||||
def sequential?
|
||||
return @params[:todos_sequential].present? && @params[:todos_sequential]=='true'
|
||||
return @params[:todos_sequential].present? && @params[:todos_sequential] == 'true'
|
||||
end
|
||||
|
||||
def specified_by_name?(group_type)
|
||||
|
|
@ -110,7 +109,7 @@ module Todos
|
|||
end
|
||||
|
||||
def add_errors(model)
|
||||
@errors.each {|e| model.errors.add(e[:attribute], e[:message]) }
|
||||
@errors.each { |e| model.errors.add(e[:attribute], e[:message]) }
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -124,7 +123,7 @@ module Todos
|
|||
|
||||
# accept empty :todo hash
|
||||
if params[:todo].empty?
|
||||
params[:todo] = {:ignore => true}
|
||||
params[:todo] = { :ignore => true }
|
||||
end
|
||||
|
||||
filtered = params.require(:todo).permit(
|
||||
|
|
@ -136,7 +135,7 @@ module Todos
|
|||
:project => [:name])
|
||||
|
||||
# add back :predecessor_dependencies
|
||||
filtered[:predecessor_dependencies] = {:predecessor => deps } unless deps.nil?
|
||||
filtered[:predecessor_dependencies] = { :predecessor => deps } unless deps.nil?
|
||||
filtered
|
||||
end
|
||||
|
||||
|
|
@ -157,9 +156,8 @@ module Todos
|
|||
# be aware, this will replace the project_id/context_id (string) in @attributes with the new found id (int)
|
||||
@attributes["#{group_type}_id"] = set.find(id).id
|
||||
return false
|
||||
rescue
|
||||
@errors << { :attribute => group_type, :message => "unknown"}
|
||||
rescue
|
||||
@errors << { :attribute => group_type, :message => "unknown" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class TodosController < ApplicationController
|
||||
|
||||
skip_before_action :login_required, :only => [:index, :tag, :list_deferred, :show, :list_hidden, :done]
|
||||
prepend_before_action :login_or_feed_token_required, :only => [:index, :tag, :list_deferred, :show, :list_hidden, :done]
|
||||
append_before_action :find_and_activate_ready, :only => [:index, :list_deferred]
|
||||
|
|
@ -35,29 +34,29 @@ class TodosController < ApplicationController
|
|||
@done = current_user.todos.completed.limit(max_completed).includes(Todo::DEFAULT_INCLUDES) unless max_completed == 0
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
format.html do
|
||||
@page_title = t('todos.task_list_title')
|
||||
# Set count badge to number of not-done, not hidden context items
|
||||
@count = current_user.todos.active.not_hidden.count(:all)
|
||||
@todos_without_project = @not_done_todos.select{|t|t.project.nil?}
|
||||
@todos_without_project = @not_done_todos.select{ |t| t.project.nil? }
|
||||
end
|
||||
format.m do
|
||||
@page_title = t('todos.mobile_todos_page_title')
|
||||
@home = true
|
||||
|
||||
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
||||
cookies[:mobile_url] = { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
determine_down_count
|
||||
|
||||
render :action => 'index'.freeze
|
||||
end
|
||||
format.text do
|
||||
# somehow passing Mime[:text] using content_type to render does not work
|
||||
headers['Content-Type'.freeze]=Mime[:text].to_s
|
||||
headers['Content-Type'.freeze] = Mime[:text].to_s
|
||||
render :content_type => Mime[:text]
|
||||
end
|
||||
format.xml do
|
||||
@xml_todos = params[:limit_to_active_todos] ? @not_done_todos : @todos
|
||||
render :xml => @xml_todos.to_xml( *[todo_xml_params[0].merge({:root => :todos})] )
|
||||
render :xml => @xml_todos.to_xml( *[todo_xml_params[0].merge({ :root => :todos })] )
|
||||
end
|
||||
format.any(:rss, :atom) do
|
||||
@feed_title = 'Tracks Actions'.freeze
|
||||
|
|
@ -73,7 +72,7 @@ class TodosController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.m {
|
||||
@new_mobile = true
|
||||
@return_path=cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
@return_path = cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
@mobile_from_context = current_user.contexts.find(params[:from_context]) if params[:from_context]
|
||||
@mobile_from_project = current_user.projects.find(params[:from_project]) if params[:from_project]
|
||||
if params[:from_project] && !params[:from_context]
|
||||
|
|
@ -123,7 +122,7 @@ class TodosController < ApplicationController
|
|||
redirect_to :action => "index"
|
||||
end
|
||||
format.m do
|
||||
@return_path=cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
@return_path = cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
if @saved
|
||||
onsite_redirect_to @return_path
|
||||
else
|
||||
|
|
@ -176,7 +175,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|
|
||||
if line.present? #ignore blank lines
|
||||
@todo = current_user.todos.build({:description => line, :context_id => p.context_id, :project_id => p.project_id})
|
||||
@todo = current_user.todos.build({ :description => line, :context_id => p.context_id, :project_id => p.project_id })
|
||||
validates &&= @todo.valid?
|
||||
|
||||
@build_todos << @todo
|
||||
|
|
@ -250,7 +249,7 @@ class TodosController < ApplicationController
|
|||
@projects = current_user.projects.active
|
||||
@contexts = current_user.contexts
|
||||
@edit_mobile = true
|
||||
@return_path=cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
@return_path = cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
@ -259,7 +258,7 @@ class TodosController < ApplicationController
|
|||
@todo = current_user.todos.find(params['id'])
|
||||
respond_to do |format|
|
||||
format.m { render :action => 'show' }
|
||||
format.xml { render :xml => @todo.to_xml( *[todo_xml_params[0].merge({:root => :todo})] ) }
|
||||
format.xml { render :xml => @todo.to_xml( *[todo_xml_params[0].merge({ :root => :todo })] ) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -363,7 +362,7 @@ class TodosController < ApplicationController
|
|||
if @saved
|
||||
if cookies[:mobile_url]
|
||||
old_path = cookies[:mobile_url]
|
||||
cookies[:mobile_url] = {:value => nil, :secure => SITE_CONFIG['secure_cookies']}
|
||||
cookies[:mobile_url] = { :value => nil, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
notify(:notice, t("todos.action_marked_complete", :description => @todo.description, :completed => @todo.completed? ? 'complete' : 'incomplete'))
|
||||
onsite_redirect_to old_path
|
||||
else
|
||||
|
|
@ -384,11 +383,11 @@ class TodosController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.js
|
||||
format.xml { render :xml => @todo.to_xml( *todo_xml_params ) }
|
||||
format.html { redirect_to request.referrer}
|
||||
format.html { redirect_to request.referrer }
|
||||
format.m {
|
||||
if cookies[:mobile_url]
|
||||
old_path = cookies[:mobile_url]
|
||||
cookies[:mobile_url] = {:value => nil, :secure => SITE_CONFIG['secure_cookies']}
|
||||
cookies[:mobile_url] = { :value => nil, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
notify(:notice, "Star toggled")
|
||||
onsite_redirect_to old_path
|
||||
else
|
||||
|
|
@ -456,7 +455,7 @@ class TodosController < ApplicationController
|
|||
end
|
||||
|
||||
determine_changes_by_this_update
|
||||
determine_remaining_in_container_count( (@context_changed || @project_changed) ? @original_item : @todo)
|
||||
determine_remaining_in_container_count((@context_changed || @project_changed) ? @original_item : @todo)
|
||||
determine_down_count
|
||||
determine_deferred_tag_count(sanitize(params['_tag_name'])) if source_view_is(:tag)
|
||||
|
||||
|
|
@ -519,7 +518,6 @@ class TodosController < ApplicationController
|
|||
@new_recurring_todo = check_for_next_todo(@todo) if @saved
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
format.html do
|
||||
if @saved
|
||||
message = t('todos.action_deleted_success')
|
||||
|
|
@ -533,7 +531,6 @@ class TodosController < ApplicationController
|
|||
redirect_to :action => 'index'
|
||||
end
|
||||
end
|
||||
|
||||
format.js do
|
||||
if @saved
|
||||
determine_down_count
|
||||
|
|
@ -546,9 +543,7 @@ class TodosController < ApplicationController
|
|||
end
|
||||
render
|
||||
end
|
||||
|
||||
format.xml { render :body => '200 OK. Action deleted.', :status => 200 }
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -563,7 +558,7 @@ class TodosController < ApplicationController
|
|||
format.html
|
||||
format.xml do
|
||||
completed_todos = current_user.todos.completed
|
||||
render :xml => completed_todos.to_xml( *[todo_xml_params[0].merge({:root => :todos})] )
|
||||
render :xml => completed_todos.to_xml( *[todo_xml_params[0].merge({ :root => :todos })] )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -583,7 +578,7 @@ class TodosController < ApplicationController
|
|||
@contexts_to_show = @contexts = current_user.contexts
|
||||
@projects_to_show = @projects = current_user.projects
|
||||
|
||||
includes = params[:format]=='xml' ? [:context, :project] : Todo::DEFAULT_INCLUDES
|
||||
includes = params[:format] == 'xml' ? [:context, :project] : Todo::DEFAULT_INCLUDES
|
||||
|
||||
@not_done_todos = current_user.todos.deferred.includes(includes).reorder('show_from') + current_user.todos.pending.includes(includes)
|
||||
@todos_without_project = @not_done_todos.select{|t|t.project.nil?}
|
||||
|
|
@ -596,7 +591,7 @@ class TodosController < ApplicationController
|
|||
init_data_for_sidebar unless mobile?
|
||||
end
|
||||
format.m
|
||||
format.xml { render :xml => @not_done_todos.to_xml( *[todo_xml_params[0].merge({:root => :todos})] ) }
|
||||
format.xml { render :xml => @not_done_todos.to_xml( *[todo_xml_params[0].merge({ :root => :todos })] ) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -646,14 +641,14 @@ class TodosController < ApplicationController
|
|||
blocked.
|
||||
reorder(Arel.sql('todos.show_from ASC, todos.created_at DESC')).
|
||||
includes(Todo::DEFAULT_INCLUDES)
|
||||
@todos_without_project = @not_done_todos.select{|t| t.project.nil?}
|
||||
@todos_without_project = @not_done_todos.select{ |t| t.project.nil? }
|
||||
|
||||
# If you've set no_completed to zero, the completed items box isn't shown on
|
||||
# the tag page
|
||||
@done = todos_with_tag_ids.completed.
|
||||
limit(current_user.prefs.show_number_completed).
|
||||
reorder('todos.completed_at DESC').
|
||||
includes(Todo::DEFAULT_INCLUDES)
|
||||
@done = todos_with_tag_ids.completed
|
||||
.limit(current_user.prefs.show_number_completed)
|
||||
.reorder('todos.completed_at DESC')
|
||||
.includes(Todo::DEFAULT_INCLUDES)
|
||||
|
||||
@projects = current_user.projects
|
||||
@contexts = current_user.contexts
|
||||
|
|
@ -670,7 +665,7 @@ class TodosController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html
|
||||
format.m {
|
||||
cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
||||
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
}
|
||||
format.text {
|
||||
render :action => 'index', :layout => false, :content_type => Mime[:text]
|
||||
|
|
@ -705,7 +700,6 @@ class TodosController < ApplicationController
|
|||
@tag = Tag.where(:name => @tag_name).first_or_create
|
||||
end
|
||||
|
||||
|
||||
def tags
|
||||
tags_beginning = current_user.tags.where(Tag.arel_table[:name].matches("#{params[:term]}%"))
|
||||
tags_all = current_user.tags.where(Tag.arel_table[:name].matches("%#{params[:term]}%"))
|
||||
|
|
@ -747,7 +741,7 @@ class TodosController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js {render :action => 'update'}
|
||||
format.js { render :action => 'update' }
|
||||
format.m {
|
||||
notify(:notice, t("todos.action_deferred", :description => @todo.description))
|
||||
do_mobile_todo_redirection
|
||||
|
|
@ -759,20 +753,20 @@ class TodosController < ApplicationController
|
|||
@hidden = current_user.todos.hidden
|
||||
respond_to do |format|
|
||||
format.xml {
|
||||
render :xml => @hidden.to_xml( *[todo_xml_params[0].merge({:root => :todos})] )
|
||||
render :xml => @hidden.to_xml( *[todo_xml_params[0].merge({ :root => :todos })] )
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def get_not_completed_for_predecessor(relation, todo_id=nil)
|
||||
items = relation.todos.not_completed.
|
||||
where('(LOWER(todos.description) ' + Common.like_operator + '?)', "%#{params[:term].downcase}%")
|
||||
items = relation.todos.not_completed
|
||||
.where('(LOWER(todos.description) ' + Common.like_operator + '?)', "%#{params[:term].downcase}%")
|
||||
items = items.where("AND NOT(todos.id=?)", todo_id) unless todo_id.nil?
|
||||
|
||||
items.
|
||||
includes(:context, :project).
|
||||
reorder('description ASC').
|
||||
limit(10)
|
||||
items
|
||||
.includes(:context, :project)
|
||||
.reorder('description ASC')
|
||||
.limit(10)
|
||||
end
|
||||
|
||||
def auto_complete_for_predecessor
|
||||
|
|
@ -805,12 +799,12 @@ class TodosController < ApplicationController
|
|||
|
||||
def show_notes
|
||||
@todo = current_user.todos.find(params['id'])
|
||||
@return_path=cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
@return_path = cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to home_path, "Viewing note of todo is not implemented"
|
||||
}
|
||||
format.m {
|
||||
format.m {
|
||||
render :action => "show_notes"
|
||||
}
|
||||
end
|
||||
|
|
@ -839,7 +833,7 @@ class TodosController < ApplicationController
|
|||
def do_mobile_todo_redirection
|
||||
if cookies[:mobile_url]
|
||||
old_path = cookies[:mobile_url]
|
||||
cookies[:mobile_url] = {:value => nil, :secure => SITE_CONFIG['secure_cookies']}
|
||||
cookies[:mobile_url] = { :value => nil, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
onsite_redirect_to old_path
|
||||
else
|
||||
onsite_redirect_to todos_path(:format => 'm')
|
||||
|
|
@ -990,7 +984,7 @@ end
|
|||
return todos_in_container, todos_in_target_container
|
||||
end
|
||||
|
||||
def determine_remaining_in_container_count(todo = @todo)
|
||||
def determine_remaining_in_container_count(todo=@todo)
|
||||
source_view do |from|
|
||||
from.deferred {
|
||||
todos_in_container, todos_in_target_container = find_todos_in_container_and_target_container(todo, @todo)
|
||||
|
|
@ -1060,7 +1054,7 @@ end
|
|||
end
|
||||
|
||||
def determine_completed_count
|
||||
todos=nil
|
||||
todos = nil
|
||||
|
||||
source_view do |from|
|
||||
from.todo { todos = current_user.todos.not_hidden.completed }
|
||||
|
|
@ -1096,7 +1090,6 @@ end
|
|||
date_to_check ||= Time.zone.now
|
||||
|
||||
if recurring_todo.active? && recurring_todo.continues_recurring?(date_to_check)
|
||||
|
||||
# shift the reference date to yesterday if date_to_check is furher in
|
||||
# the past. This is to make sure we do not get older todos for overdue
|
||||
# todos. I.e. checking a daily todo that is overdue with 5 days will
|
||||
|
|
@ -1104,7 +1097,7 @@ end
|
|||
# date. Discard the time part in the compare. We pick yesterday so
|
||||
# that new todos due for today will be created instead of new todos
|
||||
# for tomorrow.
|
||||
date = date_to_check.at_midnight >= Time.zone.now.at_midnight ? date_to_check : Time.zone.now-1.day
|
||||
date = date_to_check.at_midnight >= Time.zone.now.at_midnight ? date_to_check : Time.zone.now - 1.day
|
||||
|
||||
new_recurring_todo = TodoFromRecurringTodo.new(current_user, recurring_todo).create(date)
|
||||
end
|
||||
|
|
@ -1179,7 +1172,6 @@ end
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def update_context
|
||||
@context_changed = false
|
||||
if params['todo']['context_id'].blank? && params['context_name'].present?
|
||||
|
|
@ -1218,7 +1210,7 @@ end
|
|||
end
|
||||
|
||||
def update_due_and_show_from_dates
|
||||
%w{ due show_from }.each {|date| update_date_for_update(date) }
|
||||
%w{ due show_from }.each { |date| update_date_for_update(date) }
|
||||
end
|
||||
|
||||
def update_completed_state
|
||||
|
|
@ -1290,22 +1282,22 @@ end
|
|||
end
|
||||
|
||||
# all completed todos [today@00:00, today@now]
|
||||
def get_done_today(completed_todos, includes = {:include => Todo::DEFAULT_INCLUDES})
|
||||
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).includes(includes[:include])
|
||||
end
|
||||
|
||||
def get_done_in_period(completed_todos, before, after, includes = {:include => Todo::DEFAULT_INCLUDES})
|
||||
def get_done_in_period(completed_todos, before, after, includes={ :include => Todo::DEFAULT_INCLUDES })
|
||||
completed_todos.completed_before(before).completed_after(after).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})
|
||||
def get_done_rest_of_week(completed_todos, includes={ :include => Todo::DEFAULT_INCLUDES })
|
||||
get_done_in_period(completed_todos, Time.zone.now.beginning_of_day, Time.zone.now.beginning_of_week)
|
||||
end
|
||||
|
||||
# all completed todos [begin_of_month, begin_of_week]
|
||||
def get_done_rest_of_month(completed_todos, includes = {:include => Todo::DEFAULT_INCLUDES})
|
||||
def get_done_rest_of_month(completed_todos, includes={ :include => Todo::DEFAULT_INCLUDES })
|
||||
get_done_in_period(completed_todos, Time.zone.now.beginning_of_week, Time.zone.now.beginning_of_month)
|
||||
end
|
||||
|
||||
|
|
@ -1322,5 +1314,4 @@ end
|
|||
redirect_to(uri.path)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
class UsersController < ApplicationController
|
||||
|
||||
before_action :admin_login_required, :only => [ :index, :show ]
|
||||
before_action :admin_or_self_login_required, :only => [ :destroy ]
|
||||
skip_before_action :login_required, :only => [ :new, :create ]
|
||||
prepend_before_action :login_optional, :only => [ :new, :create ]
|
||||
before_action :admin_login_required, :only => [:index, :show]
|
||||
before_action :admin_or_self_login_required, :only => [:destroy]
|
||||
skip_before_action :login_required, :only => [:new, :create]
|
||||
prepend_before_action :login_optional, :only => [:new, :create]
|
||||
|
||||
# GET /users GET /users.xml
|
||||
def index
|
||||
|
|
@ -17,8 +16,8 @@ class UsersController < ApplicationController
|
|||
store_location
|
||||
end
|
||||
format.xml do
|
||||
@users = User.order('login')
|
||||
render :xml => @users.to_xml(:root => :users, :except => [ :password ])
|
||||
@users = User.order('login')
|
||||
render :xml => @users.to_xml(:root => :users, :except => [:password])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -26,16 +25,16 @@ class UsersController < ApplicationController
|
|||
# GET /users/id GET /users/id.xml
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
render :xml => @user.to_xml(:root => :user, :except => [ :password ])
|
||||
render :xml => @user.to_xml(:root => :user, :except => [:password])
|
||||
end
|
||||
|
||||
# GET /users/new
|
||||
def new
|
||||
@auth_types = []
|
||||
unless session[:cas_user]
|
||||
Tracks::Config.auth_schemes.each {|auth| @auth_types << [auth,auth]}
|
||||
Tracks::Config.auth_schemes.each { |auth| @auth_types << [auth, auth] }
|
||||
else
|
||||
@auth_types << ['cas','cas']
|
||||
@auth_types << ['cas', 'cas']
|
||||
end
|
||||
|
||||
if User.no_users_yet?
|
||||
|
|
@ -223,5 +222,4 @@ class UsersController < ApplicationController
|
|||
return false if params[:user][:password].empty?
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue