2014-11-06 21:50:01 +00:00
|
|
|
class Project < ActiveRecord::Base
|
|
|
|
|
|
|
|
def self.status_keys
|
|
|
|
{upcoming: 0, active: 1, backlog: 2, completed: 3}
|
|
|
|
end
|
|
|
|
|
2014-11-07 21:42:16 +00:00
|
|
|
enum status: self.status_keys
|
2014-11-06 21:50:01 +00:00
|
|
|
|
2014-11-07 21:42:16 +00:00
|
|
|
# HTML
|
2014-11-06 21:50:01 +00:00
|
|
|
def requirements
|
|
|
|
check_date_overdue_output requirements_completed?, requirements_due
|
|
|
|
end
|
|
|
|
|
|
|
|
def design
|
|
|
|
check_date_overdue_output design_completed?, design_due
|
|
|
|
end
|
|
|
|
|
|
|
|
def devops
|
|
|
|
check_date_overdue_output devops_completed?, devops_due
|
|
|
|
end
|
|
|
|
|
|
|
|
def qalaunch
|
|
|
|
check_date_overdue_output qalaunch_completed?, qalaunch_due
|
|
|
|
end
|
|
|
|
|
2014-11-07 21:42:16 +00:00
|
|
|
# JSON
|
|
|
|
def requirements_json
|
|
|
|
check_date_overdue_output requirements_completed?, requirements_due, json: true
|
|
|
|
end
|
|
|
|
|
|
|
|
def design_json
|
|
|
|
check_date_overdue_output design_completed?, design_due, json:true
|
|
|
|
end
|
|
|
|
|
|
|
|
def devops_json
|
|
|
|
check_date_overdue_output devops_completed?, devops_due, json:true
|
|
|
|
end
|
|
|
|
|
|
|
|
def qalaunch_json
|
|
|
|
check_date_overdue_output qalaunch_completed?, qalaunch_due, json:true
|
|
|
|
end
|
2014-11-06 21:50:01 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2014-11-07 21:42:16 +00:00
|
|
|
def check_date_overdue_output completed, due, options = {}
|
|
|
|
if completed
|
|
|
|
if options[:json]
|
|
|
|
"completed"
|
|
|
|
else
|
2014-11-07 20:56:49 +00:00
|
|
|
"<span class='checkmark'>✓</span>".html_safe
|
2014-11-07 21:42:16 +00:00
|
|
|
end
|
|
|
|
elsif Date.today > due
|
|
|
|
if options[:json]
|
|
|
|
"overdue"
|
2014-11-06 21:50:01 +00:00
|
|
|
else
|
2014-11-07 21:42:16 +00:00
|
|
|
"<span class='overdue'>Overdue</span>".html_safe
|
2014-11-06 21:50:01 +00:00
|
|
|
end
|
2014-11-07 21:42:16 +00:00
|
|
|
else
|
|
|
|
due
|
2014-11-06 21:50:01 +00:00
|
|
|
end
|
2014-11-07 21:42:16 +00:00
|
|
|
end
|
2014-11-06 21:50:01 +00:00
|
|
|
|
|
|
|
end
|