diff options
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/track/track_set.rhtml | 4 | ||||
-rw-r--r-- | app/views/track_mailer/event_digest.rhtml | 57 | ||||
-rw-r--r-- | app/views/user/show.rhtml | 17 |
3 files changed, 74 insertions, 4 deletions
diff --git a/app/views/track/track_set.rhtml b/app/views/track/track_set.rhtml index 380d1dd64..7f89e98db 100644 --- a/app/views/track/track_set.rhtml +++ b/app/views/track/track_set.rhtml @@ -12,7 +12,7 @@ <label for="track_track_medium_email">Send me emails shortly after there are updates</label> <br> --> <%= radio_button "track_thing", "track_medium", "email_daily" %> - <label for="track_thing_track_medium_email">Send me emails at most once a day</label> + <label for="track_thing_track_medium_email_daily">Send me emails at most once a day</label> <!-- <br> <%= radio_button "track_thing", "track_medium", "rss" %> @@ -26,7 +26,7 @@ </p> <div class="form_button"> - <%= hidden_field_tag 'submitted_track_request', 1 %> + <%= hidden_field_tag 'submitted_track', 1 %> <%= submit_tag "Subscribe" %> </div> <% end %> diff --git a/app/views/track_mailer/event_digest.rhtml b/app/views/track_mailer/event_digest.rhtml new file mode 100644 index 000000000..856fdfb52 --- /dev/null +++ b/app/views/track_mailer/event_digest.rhtml @@ -0,0 +1,57 @@ +<% + # Construct the main text of the mail + main_text = '' + for track_thing, alert_results in @email_about_things + main_text += track_thing.params[:describe] + "\n" + main_text += ("=" * track_thing.params[:describe].size) + "\n\n" + for result in alert_results.reverse + if result.class.to_s == "InfoRequestEvent" + event = result + + if not @highlighting.nil? and @highlighting['InfoRequestEvent'][event.id].size > 0 + extract = @highlighting['InfoRequestEvent'][event.id].values.join(" ") + elsif not event.outgoing_message.nil? + extract = excerpt(event.outgoing_message.body_without_salutation, "", 150) + elsif not event.incoming_message.nil? + extract = excerpt(event.incoming_message.get_body_for_quoting, "", 150) + else + extract = excerpt(info_request.initial_request_text, "", 150) + end + extract.gsub!(/\s+/, ' ') + + if event.event_type == 'response' + url = main_url(request_url(event.info_request))+"#incoming-"+event.incoming_message.id.to_s + main_text += event.info_request.public_body.name + " sent a response to " + event.info_request.user.name + elsif event.event_type == 'followup_sent' + url = main_url(request_url(event.info_request))+"#outgoing-"+event.outgoing_message.id.to_s + main_text += event.info_request.user.name + " sent a follow up message to " + event.info_request.public_body.name + elsif event.event_type == 'sent' + # this is unlikely to happen in real life, but happens in the test code + url = main_url(request_url(event.info_request))+"#outgoing-"+event.outgoing_message.id.to_s + main_text += event.info_request.user.name + " sent a request to " + event.info_request.public_body.name + else + raise "unknown type in event_digest " + event.event_type + end + main_text += " (" + simple_date(event.created_at) + ")\n" + main_text += MySociety::Format.wrap_email_body('"' + extract + '"').gsub(/\n+$/, "") + "\n" + main_text += url + "\n" + + main_text += "\n" + else + raise "need to add other types to TrackMailer.event_digest" + end + end + main_text += "\n" + end + + #STDERR.puts main_text + #STDERR.puts @unsubscribe_url +%><%=main_text%>Alter your subscription +======================= + +Please click on the link below to cancel or alter these emails. +<%=@unsubscribe_url%> + +-- the WhatDoTheyKnow team + + diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml index 3585f345f..be89d3899 100644 --- a/app/views/user/show.rhtml +++ b/app/views/user/show.rhtml @@ -21,6 +21,19 @@ <% end %> </p> + <% if not @display_user.track_things.empty? %> + <h2> + <%= @is_you ? 'You are' : 'This person is' %> tracking + <%=pluralize(@display_user.track_things.size, "thing") %> + </h2> + + <ul> + <% for track_thing in @display_user.track_things %> + <li><%= track_thing.params[:describe] %></li> + <% end %> + </ul> + <% end %> + <% if @display_user.info_requests.empty? %> <h2>Freedom of Information requests made by <%= @is_you ? 'you' : 'this person' %></h2> <p><%= @is_you ? 'You have' : 'This person has' %> @@ -28,8 +41,8 @@ <% else %> <h2> - <%=pluralize(@display_user.info_requests.size, "Freedom of Information request") %> - made by <%= @is_you ? 'you' : 'this person' %> + <%= @is_you ? 'You have' : 'This person has' %> + made <%=pluralize(@display_user.info_requests.size, "Freedom of Information request") %> </h2> <%= render :partial => 'request/request_listing', :locals => { :info_requests => @display_user.info_requests.sort { |a,b| b.created_at <=> a.created_at } } %> |