class Fakecrm::Activity

Public Class Methods

transform_comment_params( params ) click to toggle source
# File lib/fakecrm/resource/activity.rb, line 58
def self.transform_comment_params( params )
  if params["comment_notes"]
    if params["comment_contact_id"]
      contact = Contact.get!( params["comment_contact_id"].to_i )
    else
      contact = Contact.search(:params => {:login => 'root'}).first
    end
    new_comment = {
      :contact_id => contact.id,
      :updated_by => 'root',
      :notes => params["comment_notes"].to_s,
      :published => !!params["comment_published"],
      :updated_at => Time.now
    }
    params["comments"] = (Activity.get!(params["id"].to_i).comments || []) rescue []
    params["comments"] << new_comment
  end
  params.delete("comment_notes")
  params.delete("comment_contact_id")
  params.delete("comment_published")

  return params
rescue ::DataMapper::ObjectNotFoundError
  status 404
end

Public Instance Methods

check_state() click to toggle source
# File lib/fakecrm/resource/activity.rb, line 42
def check_state
  custom_type = self.custom_type
  if !custom_type.nil? && !custom_type.states.nil? && !custom_type.states.empty?
    if self.state.nil? || !custom_type.states.include?(self.state)
      # FIXME: localization
      return [false, 'ist kein gültiger Wert']
    end
  end

  return true
end
custom_type() click to toggle source
# File lib/fakecrm/resource/activity.rb, line 38
def custom_type
  CustomType.get!(self.kind) unless self.kind.nil?
end