aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/public_body.rb24
-rw-r--r--app/models/request_mailer.rb27
2 files changed, 48 insertions, 3 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 2b9546d39..e05efc77e 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -23,7 +23,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: public_body.rb,v 1.102 2008-08-31 12:46:52 francis Exp $
+# $Id: public_body.rb,v 1.103 2008-09-02 17:44:14 francis Exp $
require 'csv'
require 'set'
@@ -366,6 +366,28 @@ class PublicBody < ActiveRecord::Base
return [errors, notes]
end
+ # Does this user have the power of FOI officer for this body?
+ def is_foi_officer?(user)
+ user_domain = user.email
+ user_domain =~ /@(.*)/
+ user_domain = $1
+
+ our_domain = self.request_email
+ our_domain =~ /@(.*)/
+ our_domain = $1
+
+ if user_domain.nil? or our_domain.nil?
+ return false
+ end
+
+ return our_domain == user_domain
+ end
+ def foi_officer_domain_required
+ our_domain = self.request_email
+ our_domain =~ /@(.*)/
+ return $1
+ end
+
end
diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb
index 7762121e4..93b170aed 100644
--- a/app/models/request_mailer.rb
+++ b/app/models/request_mailer.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: request_mailer.rb,v 1.52 2008-09-01 16:14:01 francis Exp $
+# $Id: request_mailer.rb,v 1.53 2008-09-02 17:44:14 francis Exp $
class RequestMailer < ApplicationMailer
@@ -43,6 +43,30 @@ class RequestMailer < ApplicationMailer
end
end
+ # Used when an FOI officer uploads a response from their web browser - this is
+ # the "fake" email used to store in the same format in the database as if they
+ # had emailed it.
+ def fake_response(info_request, from_user, body, attachment_name, attachment_content)
+ @from = from_user.name_and_email
+ @recipients = info_request.incoming_name_and_email
+ @body = {
+ :body => body
+ }
+ if !attachment_name.nil? && !attachment_content.nil?
+ IncomingMessage # load global filename_to_mimetype XXX should move filename_to_mimetype to proper namespace
+ calc_mime = filename_to_mimetype(attachment_name)
+ if calc_mime
+ content_type = calc_mime
+ else
+ content_type = 'application/octet-stream'
+ end
+
+ attachment :content_type => content_type,
+ :body => attachment_content,
+ :filename => attachment_name
+ end
+ end
+
# Incoming message arrived for a request, but new responses have been stopped.
def stopped_responses(info_request, email)
@from = contact_from_name_and_email
@@ -147,7 +171,6 @@ class RequestMailer < ApplicationMailer
@body = { :count => @count, :info_request => info_request, :url => main_url(comment_url(earliest_unalerted_comment)) }
end
-
# Class function, called by script/mailin with all incoming responses.
# [ This is a copy (Monkeypatch!) of function from action_mailer/base.rb,
# but which additionally passes the raw_email to the member function, as we