debian-mirror-gitlab/app/models/board.rb

30 lines
577 B
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
class Board < ActiveRecord::Base
2018-03-27 19:54:05 +05:30
belongs_to :group
2016-09-13 17:45:13 +05:30
belongs_to :project
2017-09-10 17:25:29 +05:30
has_many :lists, -> { order(:list_type, :position) }, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
2016-09-13 17:45:13 +05:30
2018-03-17 18:26:18 +05:30
validates :project, presence: true, if: :project_needed?
2018-03-27 19:54:05 +05:30
validates :group, presence: true, unless: :project
2018-03-17 18:26:18 +05:30
def project_needed?
2018-03-27 19:54:05 +05:30
!group
2018-03-17 18:26:18 +05:30
end
def parent
2018-03-27 19:54:05 +05:30
@parent ||= group || project
2018-03-17 18:26:18 +05:30
end
def group_board?
2018-03-27 19:54:05 +05:30
group_id.present?
2018-03-17 18:26:18 +05:30
end
2016-11-03 12:29:30 +05:30
2017-09-10 17:25:29 +05:30
def backlog_list
lists.merge(List.backlog).take
end
2017-08-17 22:00:37 +05:30
def closed_list
lists.merge(List.closed).take
2016-11-03 12:29:30 +05:30
end
2016-09-13 17:45:13 +05:30
end