class Project < ActiveRecord::Base
def self.status_keys
{upcoming: 0, active: 1, backlog: 2, completed: 3}
end
enum status: self.status_keys
# HTML
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
# 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
private
def check_date_overdue_output completed, due, options = {}
if completed
if options[:json]
"completed"
else
"✓".html_safe
end
elsif Date.today > due
if options[:json]
"overdue"
else
"Overdue".html_safe
end
else
due
end
end
end