mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-07 17:58:50 +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
|
||||
|
|
|
|||
|
|
@ -51,10 +51,10 @@ module ProjectsHelper
|
|||
next_project = content_tag(:li, link_to_project_mobile(@next_project, "6", @next_project.shortened_name), :class=>"next") if @next_project
|
||||
return content_tag(:ul, "#{prev_project}#{next_project}".html_safe, :class=>"next-prev-project")
|
||||
end
|
||||
|
||||
|
||||
def project_summary(project)
|
||||
project_description = ''
|
||||
project_description += Tracks::Utils.render_text( project.description ) unless project.description.blank?
|
||||
project_description += Tracks::Utils.render_text( project.description ) if project.description.present?
|
||||
project_description += content_tag(:p,
|
||||
"#{count_undone_todos_phrase(p)}. #{t('projects.project_state', :state => project.state)}".html_safe
|
||||
)
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ module TodosHelper
|
|||
end
|
||||
|
||||
def format_ical_notes(notes)
|
||||
unless notes.nil? || notes.blank?
|
||||
if notes.present?
|
||||
split_notes = notes.split(/\n/)
|
||||
joined_notes = split_notes.join("\\n")
|
||||
end
|
||||
|
|
@ -416,7 +416,7 @@ module TodosHelper
|
|||
def render_animation(animation)
|
||||
html = ""
|
||||
animation.each do |step|
|
||||
unless step.blank?
|
||||
if step.present?
|
||||
html += step + "({ go: function() {\r\n"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
event :unhide do
|
||||
transitions :to => :deferred, :from => [:project_hidden], :guard => Proc.new{|t| !t.show_from.blank? }
|
||||
transitions :to => :deferred, :from => [:project_hidden], :guard => Proc.new{|t| t.show_from.present? }
|
||||
transitions :to => :pending, :from => [:project_hidden], :guard => :uncompleted_predecessors?
|
||||
transitions :to => :active, :from => [:project_hidden]
|
||||
end
|
||||
|
|
@ -119,7 +119,7 @@ class Todo < ActiveRecord::Base
|
|||
|
||||
def check_show_from_in_future
|
||||
if show_from_changed? # only check on change of show_from
|
||||
if !show_from.blank? && (show_from < user.date)
|
||||
if show_from.present? && (show_from < user.date)
|
||||
errors.add("show_from", I18n.t('models.todo.error_date_must_be_future'))
|
||||
end
|
||||
end
|
||||
|
|
@ -270,7 +270,7 @@ class Todo < ActiveRecord::Base
|
|||
# (see http://stackoverflow.com/questions/682920/persisting-the-state-column-on-transition-using-rubyist-aasm-acts-as-state-machi)
|
||||
self[:show_from] = date
|
||||
|
||||
defer if active? && !date.blank? && show_from > user.date
|
||||
defer if active? && date.present? && show_from > user.date
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -305,7 +305,7 @@ class Todo < ActiveRecord::Base
|
|||
return unless predecessor_list.kind_of? String
|
||||
|
||||
@predecessor_array=predecessor_list.split(",").inject([]) do |list, todo_id|
|
||||
predecessor = self.user.todos.find( todo_id.to_i ) unless todo_id.blank?
|
||||
predecessor = self.user.todos.find( todo_id.to_i ) if todo_id.present?
|
||||
list << predecessor unless predecessor.nil?
|
||||
list
|
||||
end
|
||||
|
|
@ -347,7 +347,7 @@ class Todo < ActiveRecord::Base
|
|||
# value will be a string. In that case convert to array
|
||||
deps = [deps] unless deps.class == Array
|
||||
|
||||
deps.each { |dep| self.add_predecessor(self.user.todos.find(dep.to_i)) unless dep.blank? }
|
||||
deps.each { |dep| self.add_predecessor(self.user.todos.find(dep.to_i)) if dep.present? }
|
||||
end
|
||||
|
||||
alias_method :original_context=, :context=
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ protected
|
|||
end
|
||||
|
||||
def password_required?
|
||||
auth_type == 'database' && crypted_password.blank? || !password.blank?
|
||||
auth_type == 'database' && crypted_password.blank? || password.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class TodoFromRichMessage
|
|||
project = extractor.project
|
||||
|
||||
context_id = default_context_id
|
||||
unless context.blank?
|
||||
if context.present?
|
||||
found_context = user.contexts.active.where("name like ?", "%#{context}%").first
|
||||
found_context = user.contexts.where("name like ?", "%#{context}%").first if !found_context
|
||||
context_id = found_context.id if found_context
|
||||
|
|
@ -27,7 +27,7 @@ class TodoFromRichMessage
|
|||
end
|
||||
|
||||
project_id = nil
|
||||
unless project.blank?
|
||||
if project.present?
|
||||
if project[0..3].downcase == "new:"
|
||||
found_project = user.projects.build
|
||||
found_project.name = project[4..259].strip
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<% @projects.each do |p| -%>
|
||||
|
||||
<%= p.name.upcase %>
|
||||
<%= p.description + "\n" unless p.description.blank? -%>
|
||||
<%= p.description + "\n" if p.description.present? -%>
|
||||
<%= count_undone_todos_phrase_text(p)%>. Project is <%= p.state %>.
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<% project = @project %>
|
||||
<%= project_next_prev_mobile %>
|
||||
<h2><%=project.name%></h2>
|
||||
<% unless @project.description.blank? -%>
|
||||
<% if @project.description.present? -%>
|
||||
<div class="project_description"><%= sanitize(@project.description) %></div>
|
||||
<% end -%>
|
||||
<ul class="c">
|
||||
|
|
|
|||
|
|
@ -34,4 +34,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<li id="<%= dom_id(todo) %>" >
|
||||
<%= remote_mobile_checkbox(todo) %>
|
||||
<%= date_span -%> <%= link_to todo.description, todo_path(todo, :format => 'm') -%>
|
||||
<% unless todo.notes.blank? %>
|
||||
<% if todo.notes.present? %>
|
||||
<%= link_to(image_tag("mobile_notes.png", :border => "0"), show_notes_todo_path(todo, :format => 'm')) -%>
|
||||
<% end %>
|
||||
<% if todo.starred? %>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
function html_for_error_messages() {
|
||||
<%
|
||||
# add error about missing todo description that is not available in @todos
|
||||
@multiple_error = content_tag(:div, content_tag(:p, @multiple_error), {:class => 'errorExplanation', :id => 'errorExplanation'}) unless @multiple_error.blank?
|
||||
@multiple_error = content_tag(:div, content_tag(:p, @multiple_error), {:class => 'errorExplanation', :id => 'errorExplanation'}) if @multiple_error.present?
|
||||
error_messages = @multiple_error || ""
|
||||
# add errors of individual @todos
|
||||
@todos.each do |todo|
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ class AddUserId < ActiveRecord::Migration
|
|||
add_column :contexts, :user_id, :integer, :default => 1
|
||||
add_column :projects, :user_id, :integer, :default => 1
|
||||
add_column :todos, :user_id, :integer, :default => 1
|
||||
Context.find(:all).each { |context| context.user_id = 1 }
|
||||
Project.find(:all).each { |project| project.user_id = 1 }
|
||||
Todo.find(:all).each { |todo| todo.user_id = 1 }
|
||||
Context.all.each { |context| context.user_id = 1 }
|
||||
Project.all.each { |project| project.user_id = 1 }
|
||||
Todo.all.each { |todo| todo.user_id = 1 }
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class AddPreferencesToUserTable < ActiveRecord::Migration
|
|||
|
||||
def self.up
|
||||
add_column :users, :preferences, :text
|
||||
@users = User.find(:all)
|
||||
@users = User.all
|
||||
@users.each do |u|
|
||||
u.preferences = { "date_format" => "%d/%m/%Y", "week_starts" => "1", "no_completed" => "5", "staleness_starts" => "7", "due_style" => "1", "admin_email" => "butshesagirl@rousette.org.uk"}
|
||||
u.save
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class AddSubclassAttrToTodos < ActiveRecord::Migration
|
|||
def self.up
|
||||
add_column :todos, :type, :string, :null => false, :default => "Immediate"
|
||||
add_column :todos, :show_from, :date
|
||||
Todo.find(:all).each { |todo| todo.type = "Immediate" }
|
||||
Todo.all.each { |todo| todo.type = "Immediate" }
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ class AddUserPrefRefresh < ActiveRecord::Migration
|
|||
class User < ActiveRecord::Base; serialize :preferences; end
|
||||
|
||||
def self.up
|
||||
@users = User.find(:all)
|
||||
@users = User.all
|
||||
@users.each do |user|
|
||||
user.preferences.merge!({"refresh" => "0"})
|
||||
user.save
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ class PrefToShowHideSidebarItems < ActiveRecord::Migration
|
|||
class User < ActiveRecord::Base; serialize :preferences; end
|
||||
|
||||
def self.up
|
||||
@users = User.find(:all)
|
||||
@users = User.all
|
||||
@users.each do |user|
|
||||
user.preferences.merge!({"show_completed_projects_in_sidebar" => true})
|
||||
user.preferences.merge!({"show_hidden_contexts_in_sidebar" => true})
|
||||
|
|
@ -12,7 +12,7 @@ class PrefToShowHideSidebarItems < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
@users = User.find(:all)
|
||||
@users = User.all
|
||||
@users.each do |user|
|
||||
user.preferences.delete("show_completed_projects_in_sidebar")
|
||||
user.preferences.delete("show_hidden_contexts_in_sidebar")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ class ConvertPreferences < ActiveRecord::Migration
|
|||
class User < ActiveRecord::Base; has_one :preference; serialize :preferences; end
|
||||
|
||||
def self.up
|
||||
@users = User.find(:all)
|
||||
@users = User.all
|
||||
@users.each do |user|
|
||||
user.create_preference
|
||||
user.preference.date_format = user.preferences['date_format']
|
||||
|
|
@ -27,7 +27,7 @@ class ConvertPreferences < ActiveRecord::Migration
|
|||
|
||||
def self.down
|
||||
add_column :users, :preferences, :text
|
||||
@users = User.find(:all)
|
||||
@users = User.all
|
||||
@users.each do |user|
|
||||
user.preferences = { "date_format" => "#{user.preference.date_format}",
|
||||
"week_starts" => "#{user.preference.week_starts}",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class ConvertProjectToStateMachine < ActiveRecord::Migration
|
|||
|
||||
def self.up
|
||||
add_column :projects, :state, :string, :limit => 20, :default => "active", :null => false
|
||||
@projects = Project.find(:all)
|
||||
@projects = Project.all
|
||||
@projects.each do |project|
|
||||
project.state = project.done? ? 'completed' : 'active'
|
||||
project.save
|
||||
|
|
@ -14,7 +14,7 @@ class ConvertProjectToStateMachine < ActiveRecord::Migration
|
|||
|
||||
def self.down
|
||||
add_column :projects, :done, :integer, :limit => 4, :default => 0, :null => false
|
||||
@projects = Project.find(:all)
|
||||
@projects = Project.all
|
||||
@projects.each do |project|
|
||||
project.done = project.state == 'completed'
|
||||
project.save
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class ConvertTodoToStateMachine < ActiveRecord::Migration
|
|||
|
||||
def self.up
|
||||
add_column :todos, :state, :string, :limit => 20, :default => "immediate", :null => false
|
||||
@todos = Todo.find(:all)
|
||||
@todos = Todo.all
|
||||
@todos.each do |todo|
|
||||
if todo.done?
|
||||
todo.state = 'completed'
|
||||
|
|
@ -29,7 +29,7 @@ class ConvertTodoToStateMachine < ActiveRecord::Migration
|
|||
add_column :todos, :done, :integer, :limit => 4, :default => 0, :null => false
|
||||
add_column :todos, :type, :string, :default => "Immediate", :null => false
|
||||
rename_column :todos, 'completed_at', 'completed' #bug in sqlite requires column names as strings
|
||||
@todos = Todo.find(:all)
|
||||
@todos = Todo.all
|
||||
@todos.each do |todo|
|
||||
todo.done = todo.state == 'completed'
|
||||
todo.type = todo.type == 'deferred' ? 'Deferred' : 'Immediate'
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@ class SetNilTimestamps < ActiveRecord::Migration
|
|||
class Context < ActiveRecord::Base; end
|
||||
|
||||
def self.up
|
||||
Project.find(:all, :conditions => { :created_at => nil }).each do |p|
|
||||
Project.where(:created_at => nil ).each do |p|
|
||||
Project.update( p.id, {:created_at => Time.now.utc} )
|
||||
end
|
||||
Project.find(:all, :conditions => { :created_at => nil }).each do |p|
|
||||
Project.where(:created_at => nil ).each do |p|
|
||||
Project.update( p.id, {:updated_at => Time.now.utc} )
|
||||
end
|
||||
Context.find(:all, :conditions => { :created_at => nil }).each do |p|
|
||||
Context.where(:created_at => nil ).each do |p|
|
||||
Context.update( p.id, {:created_at => Time.now.utc} )
|
||||
end
|
||||
Context.find(:all, :conditions => { :created_at => nil }).each do |p|
|
||||
Context.where(:created_at => nil ).each do |p|
|
||||
Context.update( p.id, {:updated_at => Time.now.utc} )
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class UpdateOpenIdUrls < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.up
|
||||
User.find(:all).each do |user|
|
||||
User.all.each do |user|
|
||||
original = user.open_id_url
|
||||
user.normalize_open_id_url
|
||||
say "#{original} -> #{user.open_id_url}"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class AddProjectCompletedAtColumn < ActiveRecord::Migration
|
|||
|
||||
def self.up
|
||||
add_column :projects, :completed_at, :datetime
|
||||
@projects = Project.find(:all)
|
||||
@projects = Project.all
|
||||
@projects.select{ |project| project.state == 'completed'}.each do |project|
|
||||
project.completed_at = project.updated_at
|
||||
project.save
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class ChangeDatesToDatetimes < ActiveRecord::Migration
|
|||
change_column :recurring_todos, :start_from, :datetime
|
||||
change_column :recurring_todos, :end_date, :datetime
|
||||
|
||||
User.all(:include => [:todos, :recurring_todos]).each do |user|
|
||||
User.includes(:todos, :recurring_todos).each do |user|
|
||||
if !user.prefs ## ugly hack for strange edge-case of not having preferences object
|
||||
user.instance_eval do
|
||||
def at_midnight(date)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
class FixIncorrectlyHiddenTodos < ActiveRecord::Migration
|
||||
def self.up
|
||||
hidden_todos_without_project =
|
||||
Todo.find(:all, :conditions => "state='project_hidden' AND project_id IS NULL")
|
||||
Todo.where(:state => 'project_hidden', :project_id => nil)
|
||||
|
||||
active_projects = Project.find(:all, :conditions => "state='active'")
|
||||
active_projects = Project.where(:state => 'active')
|
||||
hidden_todos_in_active_projects =
|
||||
Todo.find(:all, :conditions => ["state='project_hidden' AND project_id IN (?)", active_projects])
|
||||
Todo.where(:state => 'project_hidden').where("project_id IN (?)", active_projects)
|
||||
|
||||
todos_to_fix = hidden_todos_without_project + hidden_todos_in_active_projects
|
||||
todos_to_fix.each do |todo|
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class AddShowAlwaysToRecurringTodo < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :recurring_todos, :show_always, :boolean
|
||||
recurring_todos = RecurringTodo.find(:all)
|
||||
recurring_todos = RecurringTodo.all
|
||||
recurring_todos.each do |recurring_todo|
|
||||
if recurring_todo.show_from_delta == 0 or recurring_todo.show_from_delta.nil?
|
||||
recurring_todo.show_always = true
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class MakeOldRecurringTodosValidate < ActiveRecord::Migration
|
||||
def self.up
|
||||
RecurringTodo.find(:all).each do |rt|
|
||||
RecurringTodo.all.each do |rt|
|
||||
# show_always may not be nil
|
||||
rt.show_always = false if rt.show_always.nil?
|
||||
# start date should be filled
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ class AddRenderedNotes < ActiveRecord::Migration
|
|||
|
||||
say "Clearing show_from dates from completed todos"
|
||||
# clear up completed todos that have show_from set. These could have been left over from before the AASM migration
|
||||
Todo.completed.find(:all, :conditions =>[ "NOT(show_from IS NULL)"]).each {|t| t.show_from=nil; t.save!}
|
||||
Todo.completed.where( "NOT(show_from IS NULL)" ).each {|t| t.show_from=nil; t.save!}
|
||||
|
||||
say "Generating new column values from notes. This may take a while."
|
||||
# Call save! on each todo to force generation of rendered_todos
|
||||
i=0; max = Todo.all.count; start = Time.now
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ module IsTaggable
|
|||
def _add_tags incoming
|
||||
tag_cast_to_string(incoming).each do |tag_name|
|
||||
# added following check to prevent empty tags from being saved (which will fail)
|
||||
unless tag_name.blank?
|
||||
if tag_name.present?
|
||||
begin
|
||||
tag = Tag.where(:name => tag_name).first_or_create
|
||||
raise Tag::Error, "tag could not be saved: #{tag_name}" if tag.new_record?
|
||||
|
|
|
|||
|
|
@ -160,13 +160,10 @@ module LoginSystem
|
|||
format.html { redirect_to login_path }
|
||||
format.m { redirect_to login_path(:format => 'm') }
|
||||
format.js { render :partial => 'login/redirect_to_login' }
|
||||
format.xml { basic_auth_denied }
|
||||
format.rss { basic_auth_denied }
|
||||
format.atom { basic_auth_denied }
|
||||
format.text { basic_auth_denied }
|
||||
format.any(:xml, :rss, :atom, :text) { basic_auth_denied }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# store current uri in the session.
|
||||
# we can return to this location by calling return_location
|
||||
def store_location
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ class DoneTodos
|
|||
|
||||
def self.done_today(todos, includes = {:include => Todo::DEFAULT_INCLUDES})
|
||||
start_of_this_day = Time.zone.now.beginning_of_day
|
||||
todos.completed_after(start_of_this_day).all(includes)
|
||||
# TODO: refactor to remove outer hash from includes param
|
||||
todos.completed_after(start_of_this_day).includes(includes[:include])
|
||||
end
|
||||
|
||||
def self.done_rest_of_week(todos, includes = {:include => Todo::DEFAULT_INCLUDES})
|
||||
|
|
@ -37,6 +38,7 @@ class DoneTodos
|
|||
private
|
||||
|
||||
def self.done_between(todos, includes, start_date, end_date)
|
||||
todos.completed_before(start_date).completed_after(end_date).all(includes)
|
||||
# TODO: refactor to remove outer hash from includes param
|
||||
todos.completed_before(start_date).completed_after(end_date).includes(includes[:include])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue