Sha256: 48a2efed8a64a7e820a3f1c0670552dde50ca040837c775e72f725d14f1ef1ce

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

module Locomotive
  class SitePolicy < ApplicationPolicy

    class Scope < Scope

      def resolve
        if membership.account.super_admin?
          scope.all
        else
          membership.account.sites
        end
      end

    end

    def index?
      true
    end

    def show?
      true
    end

    def create?
      true
    end

    def update?
      super_admin? || site_staff?
    end

    def destroy?
      super_admin? || site_admin?
    end

    def point?
      !resource.try(:persisted?) || super_admin? || site_admin?
    end

    def update_advanced?
      super_admin? || site_admin?
    end

    def show_developers_documentation?
      super_admin? || site_admin?
    end

    def permitted_attributes
      plain = [:name, :handle, :picture, :remove_picture, :seo_title, :meta_keywords, :meta_description, :timezone_name, :robots_txt, :asset_host, :cache_enabled, :redirect_to_first_domain, :redirect_to_https, :private_access, :password, :prefix_default_locale]
      hash  = { domains: [], locales: [], url_redirections: [] }

      unless update_advanced?
        plain -= [:timezone_name, :robots_txt, :cache_enabled, :prefix_default_locale, :asset_host]
        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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
locomotivecms-3.3.0 app/policies/locomotive/site_policy.rb