mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-13 02:44:22 +01:00
Merge branch 'master' into new-gui
Conflicts: Gemfile.lock
This commit is contained in:
commit
463f5e922d
37 changed files with 1083 additions and 501 deletions
|
|
@ -27,6 +27,7 @@ class MessageGateway < ActionMailer::Base
|
|||
todo = todo_builder.construct
|
||||
todo.save!
|
||||
Rails.logger.info "Saved email as todo for user #{user.login} in context #{context.name}"
|
||||
todo
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -49,10 +50,26 @@ class MessageGateway < ActionMailer::Base
|
|||
if user.nil?
|
||||
user = User.where("preferences.sms_email" => address.strip[1.100]).includes(:preference).first
|
||||
end
|
||||
if user.present? and !sender_is_in_mailmap?(user,email)
|
||||
Rails.logger.warn "#{email.from[0]} not found in mailmap for #{user.login}"
|
||||
return nil
|
||||
end
|
||||
Rails.logger.info(!user.nil? ? "Email belongs to #{user.login}" : "User unknown")
|
||||
return user
|
||||
end
|
||||
|
||||
|
||||
def sender_is_in_mailmap?(user,email)
|
||||
if SITE_CONFIG['mailmap'].is_a? Hash and SITE_CONFIG['email_dispatch'] == 'to'
|
||||
# Look for the sender in the map of allowed senders
|
||||
SITE_CONFIG['mailmap'][user.preference.sms_email].include? email.from[0]
|
||||
else
|
||||
# We can't check the map if it's not defined, or if the lookup is the
|
||||
# wrong way round, so just allow it
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def get_user_from_email_address(email)
|
||||
SITE_CONFIG['email_dispatch'] == 'single_user' ? get_user_from_env_setting : get_user_from_mail_header(email)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -138,9 +138,9 @@ class Project < ActiveRecord::Base
|
|||
@age_in_days ||= ((Time.now.utc - created_at).to_i / 1.day) + 1
|
||||
end
|
||||
|
||||
def self.import(params, user)
|
||||
def self.import(filename, params, user)
|
||||
count = 0
|
||||
CSV.foreach(params[:file], headers: true) do |row|
|
||||
CSV.foreach(filename, headers: true) do |row|
|
||||
unless find_by_name_and_user_id row[params[:name].to_i], user.id
|
||||
project = new
|
||||
project.name = row[params[:name].to_i]
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class RecurringTodo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def daily_every_x_days=(x)
|
||||
every_other1 = x if recurring_period=='daily'
|
||||
self.every_other1 = x if recurring_period=='daily'
|
||||
end
|
||||
|
||||
def daily_every_x_days
|
||||
|
|
@ -489,7 +489,7 @@ class RecurringTodo < ActiveRecord::Base
|
|||
|
||||
case self.recurrence_selector
|
||||
when 0 # specific day of the month
|
||||
if start.mday > day
|
||||
if (previous && start.mday >= day) || (previous.nil? && start.mday > day)
|
||||
# there is no next day n in this month, search in next month
|
||||
#
|
||||
# start += n.months
|
||||
|
|
|
|||
|
|
@ -399,11 +399,11 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def self.import(params, user)
|
||||
default_context = Context.where(:user_id=>user.id).order('id').first
|
||||
def self.import(filename, params, user)
|
||||
default_context = user.contexts.order('id').first
|
||||
|
||||
count = 0
|
||||
CSV.foreach(params[:file], headers: true) do |row|
|
||||
CSV.foreach(filename, headers: true) do |row|
|
||||
unless find_by_description_and_user_id row[params[:description].to_i], user.id
|
||||
todo = new
|
||||
todo.user = user
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue