Class: Project

Inherits:
ApplicationRecord show all
Extended by:
EventfulRecord, Metadata
Includes:
AASM, Api::Messages::FlowcellIO::ProjectExtensions, Api::ProjectIO::Extensions, EventfulRecord, ModelExtensions::Project, SharedBehaviour::Named, Uuid::Uuidable
Defined in:
app/models/project.rb

Defined Under Namespace

Classes: Metadata

Constant Summary collapse

ACTIVE_STATE =
'active'
PROJECT_FUNDING_MODELS =
[
  '',
  'Internal',
  'External',
  'External - own machine'
]

Constants included from Metadata

Metadata::SECTION_FIELDS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Metadata

has_metadata, required_tags

Methods included from EventfulRecord

has_many_events, has_many_lab_events, has_one_event_with_family

Methods included from SharedBehaviour::Named

included

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods included from Api::ProjectIO::Extensions

included

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Class Method Details

.statesObject


17
18
19
# File 'app/models/project.rb', line 17

def self.states
  Project.aasm.states.map(&:name)
end

Instance Method Details

#actionable?Boolean


105
106
107
# File 'app/models/project.rb', line 105

def actionable?
  .budget_division.name != 'Unallocated'
end

#managerObject


96
97
98
99
100
101
102
103
# File 'app/models/project.rb', line 96

def manager
  role = roles.detect { |r| r.name == 'manager' }
  if role.nil?
    nil
  else
    role.users.first
  end
end

#ownerObject


91
92
93
94
# File 'app/models/project.rb', line 91

def owner
  owners_ = owners
  owners_ and owners_.first
end

#ownersObject


82
83
84
85
86
87
88
89
# File 'app/models/project.rb', line 82

def owners
  role = roles.detect { |r| r.name == 'owner' }
  if role.nil?
    []
  else
    role.users
  end
end

#r_and_d?Boolean


116
117
118
# File 'app/models/project.rb', line 116

def r_and_d?
  .budget_division.name == configatron.r_and_d_division
end

#sequencing_budget_divisionObject


120
121
122
# File 'app/models/project.rb', line 120

def sequencing_budget_division
  .budget_division.name
end

#subject_typeObject


159
160
161
# File 'app/models/project.rb', line 159

def subject_type
  'project'
end

#submittable?Boolean


109
110
111
112
113
114
# File 'app/models/project.rb', line 109

def submittable?
  return true if .project_funding_model.present?

  errors.add(:base, 'No funding model specified')
  false
end