mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-20 22:24:09 +01:00
Remove trailing whitespace and tabs
This commit is contained in:
parent
863d780ad0
commit
aa41e20e46
84 changed files with 407 additions and 407 deletions
|
|
@ -1,6 +1,6 @@
|
|||
class Context < ActiveRecord::Base
|
||||
|
||||
has_many :todos, -> { order("todos.due IS NULL, todos.due ASC, todos.created_at ASC").includes(:project) }, :dependent => :delete_all
|
||||
has_many :todos, -> { order("todos.due IS NULL, todos.due ASC, todos.created_at ASC").includes(:project) }, :dependent => :delete_all
|
||||
has_many :recurring_todos, :dependent => :delete_all
|
||||
belongs_to :user
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ class Context < ActiveRecord::Base
|
|||
include AASM
|
||||
|
||||
aasm :column => :state do
|
||||
|
||||
|
||||
state :active, :initial => true
|
||||
state :closed
|
||||
state :hidden
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
class Dependency < ActiveRecord::Base
|
||||
|
||||
# touch to make sure todo caches for predecessor and successor are invalidated
|
||||
|
||||
|
||||
belongs_to :predecessor, :foreign_key => 'predecessor_id', :class_name => 'Todo', :touch => true
|
||||
belongs_to :successor, :foreign_key => 'successor_id', :class_name => 'Todo', :touch => true
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
class MessageGateway < ActionMailer::Base
|
||||
|
||||
|
||||
def receive(email)
|
||||
user = get_receiving_user_from_email_address(email)
|
||||
return false if user.nil?
|
||||
return false unless check_sender_is_in_mailmap(user, email)
|
||||
|
||||
|
||||
context = user.prefs.sms_context
|
||||
todo_params = get_todo_params(email)
|
||||
|
||||
|
|
@ -14,12 +14,12 @@ class MessageGateway < ActionMailer::Base
|
|||
Rails.logger.info "Saved email as todo for user #{user.login} in context #{context.name}"
|
||||
todo
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def get_todo_params(email)
|
||||
params = {}
|
||||
|
||||
|
||||
if email.multipart?
|
||||
params[:description] = get_text_or_nil(email.subject)
|
||||
params[:notes] = get_first_text_plain_part(email)
|
||||
|
|
@ -33,11 +33,11 @@ class MessageGateway < ActionMailer::Base
|
|||
end
|
||||
end
|
||||
params
|
||||
end
|
||||
end
|
||||
|
||||
def get_receiving_user_from_email_address(email)
|
||||
SITE_CONFIG['email_dispatch'] == 'single_user' ? get_receiving_user_from_env_setting : get_receiving_user_from_mail_header(email)
|
||||
end
|
||||
end
|
||||
|
||||
def get_receiving_user_from_env_setting
|
||||
Rails.logger.info "All received email goes to #{ENV['TRACKS_MAIL_RECEIVER']}"
|
||||
|
|
@ -45,7 +45,7 @@ class MessageGateway < ActionMailer::Base
|
|||
Rails.logger.info "WARNING: Unknown user set for TRACKS_MAIL_RECEIVER (#{ENV['TRACKS_MAIL_RECEIVER']})" if user.nil?
|
||||
return user
|
||||
end
|
||||
|
||||
|
||||
def get_receiving_user_from_mail_header(email)
|
||||
user = get_receiving_user_from_sms_email( get_address(email) )
|
||||
Rails.logger.info(user.nil? ? "User unknown": "Email belongs to #{user.login}")
|
||||
|
|
@ -61,7 +61,7 @@ class MessageGateway < ActionMailer::Base
|
|||
user = User.where("preferences.sms_email" => address.strip).includes(:preference).first
|
||||
user = User.where("preferences.sms_email" => address.strip[1.100]).includes(:preference).first if user.nil?
|
||||
return user
|
||||
end
|
||||
end
|
||||
|
||||
def check_sender_is_in_mailmap(user, email)
|
||||
if user.present? and !sender_is_in_mailmap?(user,email)
|
||||
|
|
@ -69,7 +69,7 @@ class MessageGateway < ActionMailer::Base
|
|||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
def sender_is_in_mailmap?(user,email)
|
||||
if SITE_CONFIG['mailmap'].is_a? Hash and SITE_CONFIG['email_dispatch'] == 'to'
|
||||
|
|
@ -89,17 +89,17 @@ class MessageGateway < ActionMailer::Base
|
|||
def get_decoded_text_or_nil(text)
|
||||
return text ? text.decoded.strip : nil
|
||||
end
|
||||
|
||||
|
||||
def get_first_text_plain_part(email)
|
||||
# get all parts from multipart/alternative attachments
|
||||
parts = get_all_parts(email.parts)
|
||||
|
||||
|
||||
# remove all parts that are not text/plain
|
||||
parts.reject{|part| !part.content_type.start_with?("text/plain") }
|
||||
|
||||
|
||||
return parts.count > 0 ? parts[0].decoded.strip : ""
|
||||
end
|
||||
|
||||
|
||||
def get_all_parts(parts)
|
||||
# return a flattened array of parts. If a multipart attachment is found, recurse over its parts
|
||||
all_parts = parts.inject([]) do |set, elem|
|
||||
|
|
@ -111,5 +111,5 @@ class MessageGateway < ActionMailer::Base
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ class Project < ActiveRecord::Base
|
|||
count = 0
|
||||
CSV.foreach(filename, headers: true) do |row|
|
||||
unless find_by_name_and_user_id row[params[:name].to_i], user.id
|
||||
project = new
|
||||
project = new
|
||||
project.name = row[params[:name].to_i]
|
||||
project.user = user
|
||||
project.description = row[params[:description].to_i] if row[params[:description].to_i].present?
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class RecurringTodo < ActiveRecord::Base
|
|||
def remove_from_project!
|
||||
self.project = nil
|
||||
self.save
|
||||
end
|
||||
end
|
||||
|
||||
def clear_todos_association
|
||||
unless todos.nil?
|
||||
|
|
@ -139,4 +139,4 @@ class RecurringTodo < ActiveRecord::Base
|
|||
pattern.continues_recurring?(previous)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
module RecurringTodos
|
||||
|
||||
class AbstractRecurringTodosBuilder
|
||||
class AbstractRecurringTodosBuilder
|
||||
|
||||
attr_reader :mapped_attributes, :pattern
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ module RecurringTodos
|
|||
save_collection(:context, :context_id)
|
||||
end
|
||||
|
||||
def saved_recurring_todo
|
||||
def saved_recurring_todo
|
||||
raise(Exception.new, @recurring_todo.valid? ? "Recurring todo was not saved yet" : "Recurring todos was not saved because of validation errors") unless @saved
|
||||
|
||||
@recurring_todo
|
||||
|
|
@ -103,7 +103,7 @@ module RecurringTodos
|
|||
# should return period specific selector like yearly_selector or daily_selector
|
||||
def selector_key
|
||||
raise Exception.new, "selector_key should be overridden in subclass of AbstractRecurringTodosBuilder"
|
||||
end
|
||||
end
|
||||
|
||||
def get_selector(key)
|
||||
return nil if key.nil?
|
||||
|
|
@ -149,4 +149,4 @@ module RecurringTodos
|
|||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ module RecurringTodos
|
|||
get_show_from_date(previous) <= self.end_date
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
# Determine start date to calculate next date for recurring todo which
|
||||
|
|
@ -196,7 +196,7 @@ module RecurringTodos
|
|||
else
|
||||
return find_xth_day_of_month(x, weekday, month, year)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def find_last_day_x_of_month(weekday, month, year)
|
||||
# count backwards. use UTC to avoid strange timezone oddities
|
||||
|
|
@ -207,7 +207,7 @@ module RecurringTodos
|
|||
end
|
||||
# convert back to local timezone
|
||||
Time.zone.local(last_day.year, last_day.month, last_day.day)
|
||||
end
|
||||
end
|
||||
|
||||
def find_xth_day_of_month(x, weekday, month, year)
|
||||
# 1-4th -> count upwards last -> count backwards. use UTC to avoid strange
|
||||
|
|
@ -224,7 +224,7 @@ module RecurringTodos
|
|||
end
|
||||
# convert back to local timezone
|
||||
Time.zone.local(start.year, start.month, start.day)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module RecurringTodos
|
|||
end
|
||||
|
||||
def only_work_days?(daily_selector)
|
||||
{ 'daily_every_x_day' => false,
|
||||
{ 'daily_every_x_day' => false,
|
||||
'daily_every_work_day' => true}[daily_selector]
|
||||
end
|
||||
|
||||
|
|
@ -32,4 +32,4 @@ module RecurringTodos
|
|||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ module RecurringTodos
|
|||
return start + 2.day if start.wday() == 6 # saturday
|
||||
return start + 1.day if start.wday() == 0 # sunday
|
||||
return start
|
||||
else
|
||||
else
|
||||
# if there was no previous todo, do not add n: the first todo starts on
|
||||
# today or on start_from
|
||||
return previous == nil ? start : start+every_x_days.day-1.day
|
||||
|
|
@ -49,4 +49,4 @@ module RecurringTodos
|
|||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ module RecurringTodos
|
|||
|
||||
def attributes_to_filter
|
||||
%w{
|
||||
monthly_selector monthly_every_x_day monthly_every_x_month
|
||||
monthly_every_x_month2 monthly_every_xth_day monthly_day_of_week
|
||||
monthly_selector monthly_every_x_day monthly_every_x_month
|
||||
monthly_every_x_month2 monthly_every_xth_day monthly_day_of_week
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ module RecurringTodos
|
|||
|
||||
def get_recurrence_selector
|
||||
@selector=='monthly_every_x_day' ? 0 : 1
|
||||
end
|
||||
end
|
||||
|
||||
def get_every_other2
|
||||
get_recurrence_selector == 0 ? 'monthly_every_x_month' : 'monthly_every_x_month2'
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ module RecurringTodos
|
|||
start = Time.utc(start.year, start.month, start.day)+n.months
|
||||
end
|
||||
Time.zone.local(start.year, start.month, every_x_day)
|
||||
end
|
||||
end
|
||||
|
||||
def find_relative_day_of_month(start, n)
|
||||
the_next = get_xth_day_of_month(every_xth_day, day_of_week, start.month, start.year)
|
||||
|
|
@ -113,7 +113,7 @@ module RecurringTodos
|
|||
# support 5th day of the month, we need to handle this case
|
||||
the_next = get_xth_day_of_month(every_xth_day, day_of_week, the_next.month, the_next.year)
|
||||
end
|
||||
the_next
|
||||
the_next
|
||||
end
|
||||
|
||||
def recurrence_pattern_for_specific_day
|
||||
|
|
@ -132,11 +132,11 @@ module RecurringTodos
|
|||
I18n.t('common.month')
|
||||
end
|
||||
I18n.t('todos.recurrence.pattern.every_xth_day_of_every_n_months',
|
||||
x: xth(every_xth_day),
|
||||
day: day_of_week_as_text(day_of_week),
|
||||
x: xth(every_xth_day),
|
||||
day: day_of_week_as_text(day_of_week),
|
||||
n_months: n_months)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ module RecurringTodos
|
|||
mapping = map(mapping, :every_other1, 'weekly_every_x_week')
|
||||
|
||||
{ monday: 1, tuesday: 2, wednesday: 3, thursday: 4, friday: 5, saturday: 6, sunday: 0 }
|
||||
.each do |day, index|
|
||||
.each do |day, index|
|
||||
mapping = map_day(mapping, :every_day, "weekly_return_#{day}", index)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ module RecurringTodos
|
|||
def find_first_day_in_this_week(start)
|
||||
# check if there are any days left this week for the next todo
|
||||
start.wday().upto 6 do |i|
|
||||
return start + (i-start.wday()).days if on_xday(i)
|
||||
return start + (i-start.wday()).days if on_xday(i)
|
||||
end
|
||||
-1
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ module RecurringTodos
|
|||
end
|
||||
|
||||
def attributes_to_filter
|
||||
%w{ yearly_selector yearly_month_of_year yearly_month_of_year2
|
||||
yearly_every_x_day yearly_every_xth_day yearly_day_of_week
|
||||
%w{ yearly_selector yearly_month_of_year yearly_month_of_year2
|
||||
yearly_every_x_day yearly_every_xth_day yearly_day_of_week
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ module RecurringTodos
|
|||
|
||||
def get_recurrence_selector
|
||||
@selector=='yearly_every_x_day' ? 0 : 1
|
||||
end
|
||||
end
|
||||
|
||||
def get_every_other2
|
||||
{ 0 => :yearly_month_of_year, 1 => :yearly_month_of_year2 }[get_recurrence_selector]
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ module RecurringTodos
|
|||
I18n.t("todos.recurrence.pattern.every_year_on", :date => date_as_month_day)
|
||||
else
|
||||
I18n.t("todos.recurrence.pattern.every_year_on",
|
||||
:date => I18n.t("todos.recurrence.pattern.the_xth_day_of_month",
|
||||
:x => xth(every_xth_day),
|
||||
:day => day_of_week_as_text(day_of_week),
|
||||
:date => I18n.t("todos.recurrence.pattern.the_xth_day_of_month",
|
||||
:x => xth(every_xth_day),
|
||||
:day => day_of_week_as_text(day_of_week),
|
||||
:month => month_of_year_as_text(month_of_year)
|
||||
))
|
||||
end
|
||||
|
|
@ -57,7 +57,7 @@ module RecurringTodos
|
|||
validate_not_blank(day_of_week, "The day of the week may not be empty for recurrence setting")
|
||||
else
|
||||
raise "unexpected value of recurrence selector '#{recurrence_selector}'"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_next_date(previous)
|
||||
|
|
@ -105,5 +105,5 @@ module RecurringTodos
|
|||
the_next
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
class Tag < ActiveRecord::Base
|
||||
|
||||
|
||||
has_many :taggings
|
||||
has_many :taggable, :through => :taggings
|
||||
|
||||
|
||||
DELIMITER = "," # Controls how to split and join tagnames from strings. You may need to change the <tt>validates_format_of parameters</tt> if you change this.
|
||||
JOIN_DELIMITER = ", "
|
||||
|
||||
|
|
@ -10,9 +10,9 @@ class Tag < ActiveRecord::Base
|
|||
# rescue the ActiveRecord database constraint errors instead.
|
||||
validates_presence_of :name
|
||||
validates_uniqueness_of :name, :case_sensitive => false
|
||||
|
||||
|
||||
before_create :before_create
|
||||
|
||||
|
||||
# Callback to strip extra spaces from the tagname before saving it. If you
|
||||
# allow tags to be renamed later, you might want to use the
|
||||
# <tt>before_save</tt> callback instead.
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@
|
|||
# The Tagging join model.
|
||||
|
||||
class Tagging < ActiveRecord::Base
|
||||
|
||||
|
||||
belongs_to :tag
|
||||
belongs_to :taggable, :polymorphic => true, :touch => true
|
||||
|
||||
|
||||
after_destroy :delete_orphaned_tag
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def delete_orphaned_tag
|
||||
tag.destroy if tag and tag.taggings.count == 0
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class Todo < ActiveRecord::Base
|
|||
|
||||
aasm :column => :state do
|
||||
|
||||
state :active
|
||||
state :active
|
||||
state :project_hidden
|
||||
state :completed, :before_enter => Proc.new { |t| t.completed_at = Time.zone.now }, :before_exit => Proc.new { |t| t.completed_at = nil}
|
||||
state :deferred, :before_exit => Proc.new { |t| t[:show_from] = nil }
|
||||
|
|
@ -396,11 +396,11 @@ class Todo < ActiveRecord::Base
|
|||
|
||||
def self.import(filename, params, user)
|
||||
default_context = user.contexts.order('id').first
|
||||
|
||||
|
||||
count = 0
|
||||
CSV.foreach(filename, headers: true) do |row|
|
||||
unless find_by_description_and_user_id row[params[:description].to_i], user.id
|
||||
todo = new
|
||||
todo = new
|
||||
todo.user = user
|
||||
todo.description = row[params[:description].to_i].truncate MAX_DESCRIPTION_LENGTH
|
||||
todo.context = Context.find_by_name_and_user_id(row[params[:context].to_i], user.id) || default_context
|
||||
|
|
@ -408,7 +408,7 @@ class Todo < ActiveRecord::Base
|
|||
todo.state = row[params[:completed_at].to_i].present? ? 'completed' : 'active'
|
||||
todo.notes = row[params[:notes].to_i].truncate MAX_NOTES_LENGTH if row[params[:notes].to_i].present?
|
||||
todo.created_at = row[params[:created_at].to_i] if row[params[:created_at].to_i].present?
|
||||
todo.due = row[params[:due].to_i]
|
||||
todo.due = row[params[:due].to_i]
|
||||
todo.completed_at = row[params[:completed_at].to_i] if row[params[:completed_at].to_i].present?
|
||||
todo.save!
|
||||
count += 1
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ require 'bcrypt'
|
|||
class User < ActiveRecord::Base
|
||||
# Virtual attribute for the unencrypted password
|
||||
attr_accessor :password
|
||||
|
||||
|
||||
#for will_paginate plugin
|
||||
cattr_accessor :per_page
|
||||
@@per_page = 5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue