Class: Locomotive::SitePolicy
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- Locomotive::SitePolicy
- Defined in:
- app/policies/locomotive/site_policy.rb
Defined Under Namespace
Classes: Scope
Instance Attribute Summary
Attributes inherited from ApplicationPolicy
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #edit? ⇒ Boolean
- #index? ⇒ Boolean
- #new ⇒ Object
- #permitted_attributes ⇒ Object
- #point? ⇒ Boolean
- #show? ⇒ Boolean
- #show_developers_documentation? ⇒ Boolean
- #update? ⇒ Boolean
- #update_advanced? ⇒ Boolean
Methods inherited from ApplicationPolicy
#destroy_all?, #initialize, #new?, #persisted?, #site_admin?, #site_admin_or_designer?, #site_staff?, #super_admin?
Constructor Details
This class inherits a constructor from Locomotive::ApplicationPolicy
Instance Method Details
#create? ⇒ Boolean
32 33 34 |
# File 'app/policies/locomotive/site_policy.rb', line 32 def create? !account.visitor? end |
#destroy? ⇒ Boolean
40 41 42 |
# File 'app/policies/locomotive/site_policy.rb', line 40 def destroy? super_admin? || site_admin? end |
#edit? ⇒ Boolean
24 25 26 |
# File 'app/policies/locomotive/site_policy.rb', line 24 def edit? super_admin? || site_staff? end |
#index? ⇒ Boolean
16 17 18 |
# File 'app/policies/locomotive/site_policy.rb', line 16 def index? true end |
#new ⇒ Object
28 29 30 |
# File 'app/policies/locomotive/site_policy.rb', line 28 def new !account.visitor? end |
#permitted_attributes ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/policies/locomotive/site_policy.rb', line 56 def permitted_attributes plain = [ :name, :handle, :picture, :remove_picture, :seo_title, :meta_keywords, :meta_description, :robots_txt, :maximum_uploaded_file_size, :timezone_name, :timezone, :cache_enabled, :cache_control, :cache_vary, :asset_host, :redirect_to_first_domain, :redirect_to_https, :private_access, :password, :prefix_default_locale, :bypass_browser_locale, :overwrite_same_content_assets, :allow_dots_in_slugs, :permitted_params_from_policy ] hash = { domains: [], locales: [], url_redirections: [] } if persisted? && !update_advanced? plain -= [:timezone_name, :timezone, :robots_txt, :cache_enabled, :cache_control, :cache_vary, :prefix_default_locale, :bypass_browser_locale, :asset_host, :maximum_uploaded_file_size] hash.delete(:locales) hash.delete(:url_redirections) end unless point? plain -= [:handle, :redirect_to_first_domain, :redirect_to_https, :private_access, :password] hash.delete(:domains) end plain << hash end |
#point? ⇒ Boolean
44 45 46 |
# File 'app/policies/locomotive/site_policy.rb', line 44 def point? !persisted? || super_admin? || site_admin? end |
#show? ⇒ Boolean
20 21 22 |
# File 'app/policies/locomotive/site_policy.rb', line 20 def show? true end |
#show_developers_documentation? ⇒ Boolean
52 53 54 |
# File 'app/policies/locomotive/site_policy.rb', line 52 def show_developers_documentation? super_admin? || site_admin? end |
#update? ⇒ Boolean
36 37 38 |
# File 'app/policies/locomotive/site_policy.rb', line 36 def update? super_admin? || site_staff? && !membership.visitor? end |
#update_advanced? ⇒ Boolean
48 49 50 |
# File 'app/policies/locomotive/site_policy.rb', line 48 def update_advanced? super_admin? || site_admin? end |