aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request_event.rb
blob: 706db9d20d0c58cd2ef93d94c68ae65218f02e85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# == Schema Information
# Schema version: 25
#
# Table name: info_request_events
#
#  id              :integer         not null, primary key
#  info_request_id :integer         
#  event_type      :text            
#  params_yaml     :text            
#  created_at      :datetime        
#

# models/info_request_event.rb:
#
# 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.5 2008-01-10 01:13:28 francis Exp $

class InfoRequestEvent < ActiveRecord::Base
    belongs_to :info_request
    validates_presence_of :info_request

    validates_presence_of :event_type
    validates_inclusion_of :event_type, :in => ['sent', 'resent', 'followup_sent', 'followup_resent', 'edit_outgoing']

    # We store YAML version of parameters in the database
    def params=(params)
        self.params_yaml = params.to_yaml
    end
    def params
        YAML.load(self.params_yaml)
    end

    # Used for sorting with the incoming/outgoing messages
    def sent_at
        created_at
    end

end