Changeset 714

Show
Ignore:
Timestamp:
11/02/07 13:55:41 (1 year ago)
Author:
markku
Message:

Closes #485

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/models/notification_mailer.rb

    r713 r714  
    1111 
    1212  # Functions that the ModelObserver runs when corresponding events 
    13   # for tasks take place 
     13  # for models take place. These class methods are named based on the 
     14  # name of a model and the event name: "#{model name}_#{event name}" 
    1415 
    1516  def self.customer_created(customer) 
     
    3435  def self.task_assigned_workers(task) 
    3536    return unless task.added_worker_ids and not task.added_worker_ids.empty? 
    36     assigned_workers_with_email = User.find(:all, :conditions => ["id IN (?) AND email IS NOT NULL AND email != '' AND notify_on_task_worker = ?", task.added_worker_ids, true]) 
     37    assigned_workers_with_email = User.find(:all, :conditions => ["id IN (?) AND email IS NOT NULL AND email != ? AND notify_on_task_worker = ?", task.added_worker_ids, '', true]) 
    3738    return if assigned_workers_with_email.empty? 
    3839 
     
    101102    end 
    102103 
     104    task_url = url_for(:host => ApplicationController.host, :controller => 'task', :action => 'view', :id => task.id) 
     105    asset = task.asset 
     106 
     107    message = localize("Task {%i} (%s) - %s\n\n%s\n\nAsset: %s (%s)\n", task.id, task.task_type.name, task_url, task.short_description, asset.full_code, asset.name) 
     108    message += localize("Asset type: %s\n", asset.asset_type.name) if asset.asset_type 
     109    message += localize("Creation date: %s\nCreator: %s", format_datetime(task.created_at), task.creator.login_and_name) 
     110 
    103111    recipients recipient 
    104112    subject    "NorfelloCMMS: #{title}" 
    105113    from       NotificationMailer.email_sender 
    106114    sent_on    Time.now 
    107     body       :task => task, :asset => task.asset, :task_url => url_for(:host => ApplicationController.host, :controller => 'task', :action => 'view', :id => task.id), :automatic_message => automatic_message 
     115    body       :message => message, :automatic_message => automatic_message 
    108116 
    109     NotificationMailer._info "Mail generated for task ID:#{task.id} on event :#{event}" 
     117    NotificationMailer._info("Mail generated for task ID:#{task.id} on event :#{event}") 
    110118  end 
    111119 
     
    131139 
    132140  private 
     141 
    133142  def localize(msg, *args) 
    134143    # English is used for all messages 
    135144    return msg % args 
    136145  end 
     146 
     147  def format_datetime(datetime) 
     148    # English is used for all messages 
     149    return datetime.strftime('%Y-%m-%d %H:%M:%S') 
     150  end 
    137151end 
  • trunk/app/views/notification_mailer/task_notification.rhtml

    r652 r714  
    1 <%= _('Task {%i} (%s) - %s', @task.id, @task.task_type.name, @task_url) %> 
    2  
    3 <%= @task.short_description %> 
    4  
    5 <%= _('Asset') %>: <%= "#{@asset.full_code} (#{@asset.name})" %> 
    6 <% if @asset.asset_type -%> 
    7 <%= _('Asset type') %>: <%= @asset.asset_type.name %> 
    8 <% end -%> 
    9 <%= _('Creation date') %>: <%= Localization.format_date(@task.created_at) %> 
    10 <%= _('Creator') %>: <%= @task.creator.login_and_name %> 
     1<%= @message %> 
    112 
    123---- 

© 2004-2007 Norfello Oy All Rights Reserved