diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin_public_body_controller.rb | 2 | ||||
-rw-r--r-- | app/mailers/request_mailer.rb | 3 | ||||
-rw-r--r-- | app/models/foi_attachment.rb | 2 | ||||
-rw-r--r-- | app/models/public_body.rb | 23 | ||||
-rw-r--r-- | app/views/admin_public_body/_form.html.erb | 2 | ||||
-rw-r--r-- | app/views/comment/_single_comment.html.erb | 4 | ||||
-rw-r--r-- | app/views/general/_stylesheet_includes.html.erb | 2 | ||||
-rw-r--r-- | app/views/layouts/no_chrome.html.erb | 1 | ||||
-rw-r--r-- | app/views/request/_bubble.html.erb | 2 |
9 files changed, 29 insertions, 12 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index e0da234b0..88e275960 100644 --- a/app/controllers/admin_public_body_controller.rb +++ b/app/controllers/admin_public_body_controller.rb @@ -143,6 +143,8 @@ class AdminPublicBodyController < AdminController @errors = "" if request.post? dry_run_only = (params['commit'] == 'Upload' ? false : true) + # (FIXME: both of these cases could now be changed to use + # PublicBody.import_csv_from_file.) # Read file from params if params[:csv_file] csv_contents = params[:csv_file].read diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb index c8a19afa8..af1a75df9 100644 --- a/app/mailers/request_mailer.rb +++ b/app/mailers/request_mailer.rb @@ -19,7 +19,8 @@ class RequestMailer < ApplicationMailer end mail(:from => from_user.name_and_email, - :to => info_request.incoming_name_and_email) + :to => info_request.incoming_name_and_email, + :subject => info_request.email_subject_followup) end # Used when a response is uploaded using the API diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb index 914420a2b..acbfc8a34 100644 --- a/app/models/foi_attachment.rb +++ b/app/models/foi_attachment.rb @@ -69,7 +69,7 @@ class FoiAttachment < ActiveRecord::Base tries = 0 delay = 1 begin - binary_data = File.open(self.filepath, "rb" ).read + binary_data = File.open(self.filepath, "rb" ){ |file| file.read } if self.content_type =~ /^text/ @cached_body = convert_string_to_utf8_or_binary(binary_data, 'UTF-8') else diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 8e474c797..eb0905f9e 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -369,10 +369,24 @@ class PublicBody < ActiveRecord::Base class ImportCSVDryRun < StandardError end - # Import from CSV. Just tests things and returns messages if dry_run is true. - # Returns an array of [array of errors, array of notes]. If there are errors, - # always rolls back (as with dry_run). + # Import from a string in CSV format. + # Just tests things and returns messages if dry_run is true. + # Returns an array of [array of errors, array of notes]. If there + # are errors, always rolls back (as with dry_run). def self.import_csv(csv, tag, tag_behaviour, dry_run, editor, available_locales = []) + tmp_csv = nil + Tempfile.open('alaveteli') do |f| + f.write csv + tmp_csv = f + end + PublicBody.import_csv_from_file(tmp_csv.path, tag, tag_behaviour, dry_run, editor, available_locales) + end + + # Import from a CSV file. + # Just tests things and returns messages if dry_run is true. + # Returns an array of [array of errors, array of notes]. If there + # are errors, always rolls back (as with dry_run). + def self.import_csv_from_file(csv_filename, tag, tag_behaviour, dry_run, editor, available_locales = []) errors = [] notes = [] available_locales = [I18n.default_locale] if available_locales.empty? @@ -398,7 +412,8 @@ class PublicBody < ActiveRecord::Base set_of_importing = Set.new() field_names = { 'name'=>1, 'request_email'=>2 } # Default values in case no field list is given line = 0 - CSV.parse(csv) do |row| + + CSV.foreach(csv_filename) do |row| line = line + 1 # Parse the first line as a field list if it starts with '#' diff --git a/app/views/admin_public_body/_form.html.erb b/app/views/admin_public_body/_form.html.erb index c577d1e18..18bf1d15b 100644 --- a/app/views/admin_public_body/_form.html.erb +++ b/app/views/admin_public_body/_form.html.erb @@ -82,7 +82,7 @@ </div> </div> <div class="control-group"> - <label for="public_body_home_page"><%=_("Home page")%></label> + <label for="public_body_home_page" class="control-label"><%=_("Home page")%></label> <div class="controls"> <%= f.text_field :home_page, :class => "span4" %> <p class="help-block">(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</p> diff --git a/app/views/comment/_single_comment.html.erb b/app/views/comment/_single_comment.html.erb index d2edc8dbe..a6d234b34 100644 --- a/app/views/comment/_single_comment.html.erb +++ b/app/views/comment/_single_comment.html.erb @@ -17,10 +17,10 @@ </div> <p class="event_actions"> <% if !comment.id.nil? %> - <%= link_to "Link to this", comment_path(comment), :class => "link_to_this" %> <% if !@user.nil? && @user.admin_page_links? %> - | <%= link_to "Admin", admin_request_edit_comment_path(comment) %> + <%= link_to "Admin", admin_request_edit_comment_path(comment) %> | <% end %> + <%= link_to "Link to this", comment_path(comment), :class => "link_to_this" %> <!-- | <%= link_to _('Report abuse'), comment_path(comment) %> --> <% end %> </p> diff --git a/app/views/general/_stylesheet_includes.html.erb b/app/views/general/_stylesheet_includes.html.erb index b3f32054c..7a1648efd 100644 --- a/app/views/general/_stylesheet_includes.html.erb +++ b/app/views/general/_stylesheet_includes.html.erb @@ -17,6 +17,6 @@ <%= stylesheet_link_tag 'ie7.css' %> <![endif]--> <% if AlaveteliConfiguration::force_registration_on_new_request %> - <%= stylesheet_link_tag 'jquery.fancybox-1.3.4.pack.js', :rel => "stylesheet" %> + <%= stylesheet_link_tag 'jquery.fancybox-1.3.4.css', :rel => "stylesheet" %> <% end %> <% end %> diff --git a/app/views/layouts/no_chrome.html.erb b/app/views/layouts/no_chrome.html.erb index 589e1bb76..e613b8ca2 100644 --- a/app/views/layouts/no_chrome.html.erb +++ b/app/views/layouts/no_chrome.html.erb @@ -14,7 +14,6 @@ <%= stylesheet_link_tag 'application', :title => "Main", :rel => "stylesheet" %> <%= stylesheet_link_tag 'fonts', :rel => "stylesheet" %> - <%= stylesheet_link_tag 'theme', :rel => "stylesheet" %> <!--[if LT IE 7]> <%= stylesheet_link_tag 'ie6', :rel => "stylesheet" %> <![endif]--> diff --git a/app/views/request/_bubble.html.erb b/app/views/request/_bubble.html.erb index 8827d114d..e038bb3dc 100644 --- a/app/views/request/_bubble.html.erb +++ b/app/views/request/_bubble.html.erb @@ -13,7 +13,7 @@ :file_name => a.display_filename + '.html') %> <% img_filename = "icon_" + a.content_type.sub('/', '_') + "_large.png" - full_filename = File.expand_path(File.join(File.dirname(__FILE__), "../../assets/images", img_filename)) + full_filename = File.expand_path(Rails.root.join('app', 'assets', 'images', img_filename)) if File.exist?(full_filename) %> <%= link_to image_tag(img_filename, :class => "attachment_image", :alt => "Attachment"), attachment_path %> <% else %> |