diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/incoming_message.rb | 18 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 11 |
2 files changed, 26 insertions, 3 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 0d4a07d00..5e57694c2 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -19,7 +19,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: incoming_message.rb,v 1.137 2008-08-29 21:40:55 francis Exp $ +# $Id: incoming_message.rb,v 1.138 2008-08-29 22:39:36 francis Exp $ # TODO # Move some of the (e.g. quoting) functions here into rblib, as they feel @@ -822,6 +822,22 @@ class IncomingMessage < ActiveRecord::Base return nil end + + # Returns space separated list of file extensions of attachments to this message. Defaults to + # the normal extension for known mime type, otherwise uses other extensions. + def get_present_file_extensions + ret = {} + for attachment in self.get_attachments_for_display + ext = mimetype_to_extension(attachment.content_type) + ext = File.extname(attachment.filename).gsub(/^[.]/, "") if ext.nil? && !attachment.filename.nil? + ret[ext] = 1 if !ext.nil? + end + return ret.keys.join(" ") + end + # Return space separated list of all file extensions known + def IncomingMessage.get_all_file_extentions + return $file_extension_to_mime_type.keys.join(" ") + end end diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 48015500a..08e0fa0b8 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -20,7 +20,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request_event.rb,v 1.52 2008-08-20 23:56:21 francis Exp $ +# $Id: info_request_event.rb,v 1.53 2008-08-29 22:39:36 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request @@ -69,7 +69,8 @@ class InfoRequestEvent < ActiveRecord::Base [ :requested_by, 'B', "requested_by" ], [ :requested_from, 'F', "requested_from" ], [ :request, 'R', "request" ], - [ :variety, 'V', "variety" ] + [ :variety, 'V', "variety" ], + [ :filetype, 'T', "filetype" ] ], :if => :indexed_by_search, :eager_load => [ :incoming_message, :outgoing_message, :comment, { :info_request => [ :user, :public_body ] } ] @@ -115,6 +116,12 @@ class InfoRequestEvent < ActiveRecord::Base end return '' end + def filetype + if self.event_type == 'response' + return self.incoming_message.get_present_file_extensions + end + return '' + end def indexed_by_search if ['sent', 'followup_sent', 'response', 'comment'].include?(self.event_type) if info_request.prominence == 'backpage' |