Sha256: a2deffa0b5f5e9fbb2c32011826a12d5a2cd6761ff7bb61e9ef188e0339eb0f7

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

module Catarse
class Update < ActiveRecord::Base
  belongs_to :user
  belongs_to :project
  has_many :notifications, dependent: :destroy
  validates_presence_of :user_id, :project_id, :comment, :comment_html

  auto_html_for :comment do
    html_escape :map => {
      '&' => '&amp;',
      '>' => '&gt;',
      '<' => '&lt;',
      '"' => '"' }
    image
    youtube width: 560, height: 340, wmode: "opaque"
    vimeo width: 560, height: 340
    redcloth :target => :_blank
    link :target => :_blank
  end

  def email_comment_html
    auto_html(comment) do
      html_escape :map => {
        '&' => '&amp;',
        '>' => '&gt;',
        '<' => '&lt;',
        '"' => '"'
      }
      image
      redcloth :target => :_blank
      link :target => :_blank
    end
  end

  def notify_backers
    project.subscribed_users.each do |user|
      Rails.logger.info "[User #{user.id}] - Creating notification for #{user.name}"
      Notification.create_notification_once :updates, user,
        {update_id: self.id, user_id: user.id},
        project_name: project.name,
        project_owner: project.user.display_name,
        project_owner_email: project.user.email,
        from: Catarse::Configuration[:email_no_reply],
        update_title: title,
        update: self,
        update_comment: email_comment_html
    end
  end

end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
catarse_core-1.0.0.beta app/models/catarse/update.rb