Class: News::Administration

Inherits:
News
  • Object
show all
Defined in:
app/models/news/administration.rb

Overview

New corresponding to the administration of this instance of TaxonWorks

Direct Known Subclasses

BlogPost, Notice, Warning

Defined Under Namespace

Classes: BlogPost, Notice, Warning

Instance Method Summary collapse

Instance Method Details

#user_must_be_administratorObject (private)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/models/news/administration.rb', line 13

def user_must_be_administrator
  return unless created_by_id || updated_by_id

  if created_by_id
    user = User.find_by(id: created_by_id)
    unless user&.is_administrator
      errors.add(:base, 'only administrators can edit administration news')
    end
  end

  if updated_by_id
    user = User.find_by(id: updated_by_id)
    unless user&.is_administrator
      errors.add(:base, 'only administrators can edit administration news')
    end
  end

end