Created
March 9, 2010 07:55
-
-
Save anonymous/326365 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Comment < ActiveRecord::Base | |
| hobo_model # Don't put anything above this | |
| fields do | |
| title :string, :required, :name => true, :primary_content => true | |
| comment :text, :required | |
| internal :boolean | |
| timestamps | |
| end | |
| belongs_to :owner, :class_name => "User", :creator => true | |
| belongs_to :version, :accessible => true | |
| #never_show :owner | |
| # --- Permissions --- # | |
| def emailoptout?(user) | |
| !user.email_optout? | |
| end | |
| def create_permitted? | |
| acting_user.administrator? || version.creatable_by?(acting_user) | |
| end | |
| def update_permitted? | |
| acting_user.administrator? | |
| end | |
| def destroy_permitted? | |
| acting_user.administrator? | |
| end | |
| def view_permitted?(field) | |
| acting_user.administrator? || !internal | |
| end | |
| def owner_view_permitted? | |
| true | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment