Class: InboxItem

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
AASM
Defined in:
app/models/inbox_item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#convertObject

Returns the value of attribute convert.



10
11
12
# File 'app/models/inbox_item.rb', line 10

def convert
  @convert
end

#dateObject

Returns the value of attribute date.



10
11
12
# File 'app/models/inbox_item.rb', line 10

def date
  @date
end

#log_timeObject

Returns the value of attribute log_time.



10
11
12
# File 'app/models/inbox_item.rb', line 10

def log_time
  @log_time
end

#log_typeObject

Returns the value of attribute log_type.



10
11
12
# File 'app/models/inbox_item.rb', line 10

def log_type
  @log_type
end

#project_idObject

Returns the value of attribute project_id.



10
11
12
# File 'app/models/inbox_item.rb', line 10

def project_id
  @project_id
end

Class Method Details

.unconvertedObject



51
52
53
# File 'app/models/inbox_item.rb', line 51

def self.unconverted
  where(aasm_state: ['unread', 'read'])
end

.unreadObject



47
48
49
# File 'app/models/inbox_item.rb', line 47

def self.unread
  where(aasm_state: 'unread')
end

Instance Method Details

#do_conversionObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/models/inbox_item.rb', line 27

def do_conversion
  transaction do
    project = user.projects.find(project_id)

  	l = project.log_entries.build({
      user_id: user.id,
			log_time: self.log_time,
      date: self.date,
      log_type: self.log_type,
			task_name: self.subject,
			task_description: self.body,
      technical_risks: project.technical_risks
			})
    
		l.save!
    update_attribute(:log_entry_id, l.id)
    file_uploads.update_all(log_entry_id: l.id)
  end
end

#titleObject



55
56
57
# File 'app/models/inbox_item.rb', line 55

def title
  subject
end