Module: Formol::Permissions::SpecialRights
- Defined in:
- lib/formol/generators/install/templates/lib/permissions/special_rights.rb
Overview
add methods to this module to define some rights that acts differently than just checking if user has right for his profile.
For instance, a user can edit a post without having ‘edit_post’ right if he wrotes it, he’s able to edit it
Instance Method Summary collapse
- #able_to_create_post?(topic) ⇒ Boolean
-
#able_to_edit_post?(post) ⇒ Boolean
a user can edit a post if he wrotes it.
-
#able_to_edit_topic?(topic) ⇒ Boolean
a user can edit a topic if he wrotes it.
Instance Method Details
#able_to_create_post?(topic) ⇒ Boolean
19 20 21 |
# File 'lib/formol/generators/install/templates/lib/permissions/special_rights.rb', line 19 def able_to_create_post?(topic) has_right?(:create_post) && !topic.locked? end |
#able_to_edit_post?(post) ⇒ Boolean
a user can edit a post if he wrotes it
15 16 17 |
# File 'lib/formol/generators/install/templates/lib/permissions/special_rights.rb', line 15 def able_to_edit_post?(post) has_right?(:edit_post) || (!post.topic.locked? && post.user_id == user.id) end |
#able_to_edit_topic?(topic) ⇒ Boolean
a user can edit a topic if he wrotes it
10 11 12 |
# File 'lib/formol/generators/install/templates/lib/permissions/special_rights.rb', line 10 def able_to_edit_topic?(topic) has_right?(:edit_topic) || (!topic.locked? && topic.user_id == user.id) end |