Class: Task

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
StringHelper
Defined in:
app/models/task.rb,
lib/cmgb_rules/app/models/task.rb

Overview

esta linha me fez perder horas debugando include Rails.application.routes.url_helpers

Constant Summary collapse

VALID_NAME_REGEX =
VALIDATE <————————————————
/\A(.*[A-z0-9.,;\'\"\-\/]{3,}.*)+\z/i

Class Method Summary collapse

Instance Method Summary collapse

Methods included from StringHelper

#name_or_empty, #name_or_nothing

Class Method Details

.rulesObject



6
7
8
# File 'lib/cmgb_rules/app/models/task.rb', line 6

def self.rules
  { :CMGB => { :"Task::AfterSave" => "make_trivial_a_business_customer" } }
end

Instance Method Details

#cgmb_make_trivial_customer_a_business_customerObject



10
11
12
13
14
15
16
17
# File 'lib/cmgb_rules/app/models/task.rb', line 10

def cgmb_make_trivial_customer_a_business_customer
  if ((interested.is_a? Customer) &&
      (not resolution.nil?) &&
      (resolution.id == SystemTaskResolution.RESOLVED_WITH_BUSINESS.id))
    interested.is_customer = true
    interested.save!
  end
end

#doneObject



57
58
59
60
# File 'app/models/task.rb', line 57

def done
  self.status = SystemTaskStatus.CLOSED
  self.finish_time = Time.now
end

#done?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/models/task.rb', line 53

def done?
  self.status == SystemTaskStatus.CLOSED
end

#due_critical_levelObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/task.rb', line 38

def due_critical_level
  
  return 0 if done? || due_time.nil?
  
  if (due_time>Time.now)
    if (((due_time-Time.now)/1.day).round>GUARACRM::Application::TASKS_DUE_CRITICAL_DAYS_REMAINING)
      1
    else
      2
    end
  else
      3
  end
end