scinote-web/app/serializers/api/v1/task_serializer.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

2018-09-05 15:55:04 +08:00
# frozen_string_literal: true
module Api
module V1
2018-10-07 01:53:31 +08:00
class TaskSerializer < ActiveModel::Serializer
2020-08-07 22:51:57 +08:00
include ApplicationHelper
include ActionView::Helpers::TextHelper
include InputSanitizeHelper
type :tasks
2020-03-28 00:35:24 +08:00
attributes :id, :name, :started_on, :due_date, :description, :state, :archived
has_many :output_tasks, key: :outputs,
serializer: TaskSerializer,
class_name: 'MyModule'
has_many :input_tasks, key: :inputs,
serializer: TaskSerializer,
class_name: 'MyModule'
def output_tasks
object.my_modules
end
def input_tasks
object.my_module_antecessors
end
def description
if instance_options[:rte_rendering]
2020-08-07 22:51:57 +08:00
custom_auto_link(object.tinymce_render(:description),
simple_format: false,
tags: %w(img),
team: instance_options[:team])
else
object.description
end
end
2018-09-05 15:55:04 +08:00
end
end
end