mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-15 00:06:10 +08:00
21 lines
673 B
Ruby
21 lines
673 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Api
|
|
module V1
|
|
class ProjectSerializer < ActiveModel::Serializer
|
|
type :projects
|
|
attributes :name, :status, :visibility, :archived, :started_at, :done_at, :start_date, :due_date, :description
|
|
attribute :metadata, if: -> { scope && scope[:metadata] == true }
|
|
|
|
belongs_to :project_folder, serializer: ProjectFolderSerializer
|
|
belongs_to :supervised_by, serializer: UserSerializer
|
|
has_many :project_comments, key: :comments, serializer: CommentSerializer
|
|
|
|
include TimestampableModel
|
|
|
|
def visibility
|
|
object.team_assignments.any? ? 'visible' : 'hidden'
|
|
end
|
|
end
|
|
end
|
|
end
|