Sha256: 4346b22616d3de8771476a93266d91ab39491a202a1c7f6fdd14bdbd826f10ee

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

::Card.error_codes[:conflict] = [:conflict, 409]

def content
  db_content or (new_card? && template.db_content)
end

def content=(value)
  self.db_content = value
end

def raw_content
  structure ? template.db_content : content
end


format do
  def chunk_list #override to customize by set
    :default
  end
end

def label
  name
end

def creator
  Card[ creator_id ]
end

def updater
  Card[ updater_id ]
end

def clean_html?
  true
end

def save_content_draft content
  clear_drafts
end

def clear_drafts
  drafts.created_by(Card::Auth.current_id).each do |draft|
    draft.delete
  end
end

event :save_draft, :before=>:store, :on=>:update, :when=>proc{ |c| Env.params['draft'] == 'true' } do
  save_content_draft content
  abort :success
end


event :set_default_content, :on=>:create, :before=>:approve do  
  if !db_content_changed? and template and template.db_content.present?
    self.db_content = template.db_content
  end
end

event :detect_conflict, :before=>:approve, :on=>:update do
  if last_action_id_before_edit and last_action_id_before_edit.to_i != last_action_id and last_action.act.actor_id != Auth.current_id
    errors.add :conflict, "changes not based on latest revision"
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
card-1.15.7 mod/01_core/set/all/content.rb
card-1.15.6 mod/01_core/set/all/content.rb
card-1.15.5 mod/01_core/set/all/content.rb
card-1.15.4 mod/01_core/set/all/content.rb
card-1.15.3 mod/01_core/set/all/content.rb
card-1.15.2 mod/01_core/set/all/content.rb
card-1.15.1 mod/01_core/set/all/content.rb
card-1.15.0 mod/01_core/set/all/content.rb
card-1.15.pre2 mod/01_core/set/all/content.rb
card-1.15.pre mod/01_core/set/all/content.rb