Class | Task |
In: |
app/models/task.rb
|
Parent: | ActiveRecord::Base |
# File app/models/task.rb, line 21 21: def mark_as_complete! 22: update_attributes(:completed_at => Time.now) 23: end
# File app/models/task.rb, line 54 54: def assigned_by_is_able_to_edit_or_publish_content 55: if assigned_by && !assigned_by.able_to_edit_or_publish_content? 56: errors.add(:assigned_by_id, "cannot assign tasks") 57: end 58: end
# File app/models/task.rb, line 60 60: def assigned_to_is_able_to_edit_or_publish_content 61: if assigned_to && !assigned_to.able_to_edit_or_publish_content? 62: errors.add(:assigned_to_id, "cannot be assigned tasks") 63: end 64: end
# File app/models/task.rb, line 30 30: def mark_other_tasks_for_the_same_page_as_complete 31: self.class.for_page(self.page_id.to_i).other_than(self).incomplete.all.each do |t| 32: t.mark_as_complete! 33: end 34: end
# File app/models/task.rb, line 36 36: def send_email 37: #Hmm... what if the assign_by or assign_to don't have email addresses? 38: #For now we'll say just don't send an email and log that as a warning 39: if assigned_by.email.blank? 40: logger.warn "Can't send email for task because assigned by user #{assigned_by.login}:#{assigned_by.id} has no email address" 41: elsif assigned_to.email.blank? 42: logger.warn "Can't send email for task because assigned to user #{assigned_to.login}:#{assigned_to.id} has no email address" 43: else 44: email = EmailMessage.create( 45: :sender => assigned_by.email, 46: :recipients => assigned_to.email, 47: :subject => "Page '#{page.name}' has been assigned to you", 48: :body => "http://#{SITE_DOMAIN}#{page.path}\n\n#{comment}" 49: ) 50: end 51: true #don't accidently return false and halt the chain 52: end