From 7d0a281d5bc03f2a981cbe6cb055fe19760f907d Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 27 Apr 2008 12:18:19 +0000 Subject: [PATCH 1/1] Include tags in GPX success and failure mails. Closes #480. --- app/models/notifier.rb | 4 ++++ app/views/notifier/_gpx_description.rhtml | 14 ++++++++++++++ app/views/notifier/gpx_failure.rhtml | 7 +------ app/views/notifier/gpx_success.rhtml | 7 +------ lib/daemons/gpx_import.rb | 4 ++-- 5 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 app/views/notifier/_gpx_description.rhtml diff --git a/app/models/notifier.rb b/app/models/notifier.rb index b9b81a889..84d097341 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -35,6 +35,8 @@ class Notifier < ActionMailer::Base headers "Auto-Submitted" => "auto-generated" body :trace_name => trace.name, :trace_points => trace.size, + :trace_description => trace.description, + :trace_tags => trace.tags, :possible_points => possible_points end @@ -44,6 +46,8 @@ class Notifier < ActionMailer::Base subject "[OpenStreetMap] GPX Import failure" headers "Auto-Submitted" => "auto-generated" body :trace_name => trace.name, + :trace_description => trace.description, + :trace_tags => trace.tags, :error => error end diff --git a/app/views/notifier/_gpx_description.rhtml b/app/views/notifier/_gpx_description.rhtml new file mode 100644 index 000000000..b31c7744e --- /dev/null +++ b/app/views/notifier/_gpx_description.rhtml @@ -0,0 +1,14 @@ +Hi, + +It looks like your GPX file + + <%= @trace_name %> + +with the description + + <%= @trace_description %> +<% if @trace_tags.length>0 %> +and the following tags: +<% @trace_tags.each do |tag| %> + <%= tag.tag.rstrip %><% end %><% else %> +and no tags.<% end %> diff --git a/app/views/notifier/gpx_failure.rhtml b/app/views/notifier/gpx_failure.rhtml index 2a16bc49e..7035e45d1 100644 --- a/app/views/notifier/gpx_failure.rhtml +++ b/app/views/notifier/gpx_failure.rhtml @@ -1,9 +1,4 @@ -Hi, - -It looks like your GPX file - - <%= @trace_name %> - +<%= render :partial => "gpx_description" %> failed to import. Here's the error: <%= @error %> diff --git a/app/views/notifier/gpx_success.rhtml b/app/views/notifier/gpx_success.rhtml index ae05bb83b..2613d7429 100644 --- a/app/views/notifier/gpx_success.rhtml +++ b/app/views/notifier/gpx_success.rhtml @@ -1,8 +1,3 @@ -Hi, - -It looks like your GPX file - - <%= @trace_name %> - +<%= render :partial => "gpx_description" %> loaded successfully with <%= @trace_points %> out of a possible <%= @possible_points %> points. diff --git a/lib/daemons/gpx_import.rb b/lib/daemons/gpx_import.rb index 07f4cd6a4..e24dc1ad5 100755 --- a/lib/daemons/gpx_import.rb +++ b/lib/daemons/gpx_import.rb @@ -23,14 +23,14 @@ while(true) do if gpx.actual_points > 0 Notifier::deliver_gpx_success(trace, gpx.actual_points) else - trace.destroy Notifier::deliver_gpx_failure(trace, '0 points parsed ok. Do they all have lat,lng,alt,timestamp?') + trace.destroy end rescue Exception => ex logger.info ex.to_s ex.backtrace.each {|l| logger.info l } - trace.destroy Notifier::deliver_gpx_failure(trace, ex.to_s + "\n" + ex.backtrace.join("\n")) + trace.destroy end Signal.trap("TERM", "DEFAULT") -- 2.43.2