summaryrefslogtreecommitdiff
path: root/app/models/board.rb
blob: 5bb7d3d3722becf551a57a62522078fb6ed37cdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Board < ActiveRecord::Base
  belongs_to :project

  has_many :lists, -> { order(:list_type, :position) }, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent

  validates :project, presence: true, if: :project_needed?

  def project_needed?
    true
  end

  def parent
    project
  end

  def group_board?
    false
  end

  def backlog_list
    lists.merge(List.backlog).take
  end

  def closed_list
    lists.merge(List.closed).take
  end
end