Index: app/controllers/todos_controller.rb =================================================================== --- app/controllers/todos_controller.rb (revision 595) +++ app/controllers/todos_controller.rb (working copy) @@ -37,13 +37,15 @@ def create @todo = current_user.todos.build p = params['request'] || params - + if p['todo']['show_from'] && !mobile? p['todo']['show_from'] = parse_date_per_user_prefs(p['todo']['show_from']) end @todo.attributes = p['todo'] - + todo_context_name = "blank" + todo_project_name = p['project_name'] + if p['todo']['project_id'].blank? && !p['project_name'].blank? && p['project_name'] != 'None' project = current_user.projects.find_by_name(p['project_name'].strip) unless project @@ -53,6 +55,7 @@ @new_project_created = true end @todo.project_id = project.id + todo_project_name = project.name end if p['todo']['context_id'].blank? && !p['context_name'].blank? @@ -65,6 +68,7 @@ @not_done_todos = [@todo] end @todo.context_id = context.id + todo_context_name = context.name end if @todo.due? @@ -76,6 +80,12 @@ @saved = @todo.save if @saved @todo.tag_with(params[:tag_list], current_user) if params[:tag_list] + #Add email code here + does_include_tag = params[:tag_list].index('agenda') + if todo_context_name == "@errands" || todo_context_name == "@phone" || does_include_tag != nil || params[:tag_list] == "agenda" then + TaskMailer.deliver_add(@todo,todo_project_name,todo_context_name) + end + #End Added Code @todo.reload end Index: app/models/task_mailer.rb =================================================================== --- app/models/task_mailer.rb (revision 0) +++ app/models/task_mailer.rb (revision 0) @@ -0,0 +1,21 @@ +class TaskMailer < ActionMailer::Base + +# def add(sent_at = Time.now) + # @subject = 'TaskMailer#add' + # @body = {} + # @recipients = '' + #@from = '' + #@sent_on = sent_at + #@headers = {} +# end + + def add(todo,todo_project_name,todo_context_name) + @subject = todo.description + ' - ' + todo_context_name + " [" + todo_project_name + "]" + @body["todo"] = todo + @recipients = 'youremailherer@email.com' + @from = todo_context_name + ' ' + @sent_on = Time.now + end + + +end Index: app/views/task_mailer/add.rhtml =================================================================== --- app/views/task_mailer/add.rhtml (revision 0) +++ app/views/task_mailer/add.rhtml (revision 0) @@ -0,0 +1,9 @@ +<% if !@todo.due.blank? %> +Due: <%= @todo.due %> +<% end -%> +<% if !@todo.notes.blank? %> +Notes: <%= @todo.notes %> +<% end -%> +<% if !@todo.tag_list.blank? %> +Tags: <%= @todo.tag_list%> +<% end -%> \ No newline at end of file Index: app/views/task_mailer/add.rhtml =================================================================== --- app/views/task_mailer/add.rhtml (revision 0) +++ app/views/task_mailer/add.rhtml (revision 0) @@ -0,0 +1,9 @@ +<% if !@todo.due.blank? %> +Due: <%= @todo.due %> +<% end -%> +<% if !@todo.notes.blank? %> +Notes: <%= @todo.notes %> +<% end -%> +<% if !@todo.tag_list.blank? %> +Tags: <%= @todo.tag_list%> +<% end -%> \ No newline at end of file