ref: master
plugins/work_assignment/lib/ext/article.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
require_dependency 'article' class Article before_validation :work_assignment_save_into_author_folder after_validation :work_assignment_change_visibility def work_assignment_save_into_author_folder return unless not self.is_a? Folder and self.parent.kind_of? WorkAssignmentPlugin::WorkAssignment author_folder = self.parent.find_or_create_author_folder self.author self.name = WorkAssignmentPlugin::WorkAssignment.versioned_name self, author_folder self.parent = author_folder end def work_assignment_change_visibility if WorkAssignmentPlugin.is_submission?(self) related_work_assignment = self.parent.parent if(!related_work_assignment.publish_submissions) self.show_to_followers = false end self.published = self.parent.published end end settings_items :work_assignment_read_by_ids, type: Array, default: [] def work_assignment_read_by @work_assignment_read_by ||= Person.where(id: self.work_assignment_read_by_ids).all end def work_assignment_read_by_names self.work_assignment_read_by.map(&:name) end end |