Class: Submission
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Submission
- Includes:
- ActiveModel::ForbiddenAttributesProtection, PublicActivity::Common
- Defined in:
- app/models/submission.rb
Instance Method Summary (collapse)
-
- (Boolean) is_approved?
Test if the submission has been approved.
-
- (Boolean) is_denied?
Test if the submission has been denied.
-
- (Boolean) is_pending?
Test if the submission has not yet been moderated.
- - (Object) moderation_text
-
- (Object) update_children_moderation_flag
Cascade moderation to children submissions as well.
Instance Method Details
- (Boolean) is_approved?
Test if the submission has been approved. (moderation flag is true)
43 44 45 |
# File 'app/models/submission.rb', line 43 def is_approved? moderation_flag ? true : false end |
- (Boolean) is_denied?
Test if the submission has been denied. (moderation flag is false)
49 50 51 |
# File 'app/models/submission.rb', line 49 def is_denied? (moderation_flag == false) ? true : false end |
- (Boolean) is_pending?
Test if the submission has not yet been moderated. (moderation flag is nil)
55 56 57 |
# File 'app/models/submission.rb', line 55 def is_pending? moderation_flag.nil? end |
- (Object) moderation_text
30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/submission.rb', line 30 def moderation_text case self.moderation_flag when true return "Approved" when false return "Rejected" when nil return "Pending" end end |
- (Object) update_children_moderation_flag
Cascade moderation to children submissions as well. Child content submitted to the same feed will recieve the same moderation as a parent content.
62 63 64 65 66 67 68 69 70 71 |
# File 'app/models/submission.rb', line 62 def update_children_moderation_flag if self.changed.include?('moderation_flag') and self.content.has_children? self.content.children.each do |child| similiar_submissions = Submission.where(:content_id => child.id, :feed_id => self.feed_id, :moderation_flag => self.moderation_flag_was) similiar_submissions.each do |child_submission| child_submission.update_attributes({:moderation_flag => self.moderation_flag, :moderator_id => self.moderator_id}) end end end end |