<commit_before>module DataCatalog

  class Organizations < Base
    include Resource

    model Organization

    # == Permissions

    roles Roles
    permission :list   => :basic
    permission :read   => :basic
    permission :create => :curator
    permission :update => :curator
    permission :delete => :curator

    # == Properties
    
    property :name
    property :names
    property :acronym
    property :org_type
    property :description
    property :slug
    property :url
    property :interest
    property :level
    property :source_count
    property :custom
    property :raw,              :w => :admin
    property :user_id,          :w => :nobody
    property :jurisdiction_id
    
    property :jurisdiction do |org|
      if org.jurisdiction_id
        {
          "href" => "/jurisdictions/#{org.jurisdiction_id}",
          "name" => org.jurisdiction.name,
          "slug" => org.jurisdiction.slug,          
        }
      else
        nil
      end
    end

    # == Callbacks

    callback :before_create do |action|
      raise "expecting current_user" unless action.current_user
      action.params["user_id"] = action.current_user.id
    end

  end

  Organizations.build

end<commit_msg>refactor jurisdiction property<commit_after>module DataCatalog

  class Organizations < Base
    include Resource

    model Organization

    # == Permissions

    roles Roles
    permission :list   => :basic
    permission :read   => :basic
    permission :create => :curator
    permission :update => :curator
    permission :delete => :curator

    # == Properties
    
    property :name
    property :names
    property :acronym
    property :org_type
    property :description
    property :slug
    property :url
    property :interest
    property :level
    property :source_count
    property :custom
    property :raw,              :w => :admin
    property :user_id,          :w => :nobody
    property :jurisdiction_id
    
    property :jurisdiction do |org|
      if org.jurisdiction_id
        jurisdiction = org.jurisdiction
        {
          "name" => jurisdiction.name,
          "href" => "/jurisdictions/#{jurisdiction.id}",
          "slug" => jurisdiction.slug,          
        }
      end
    end

    # == Callbacks

    callback :before_create do |action|
      raise "expecting current_user" unless action.current_user
      action.params["user_id"] = action.current_user.id
    end

  end

  Organizations.build

end
{'fraction_non_alphanumeric': 0.08481421647819062, 'fraction_numerical': 0.0, 'mean_word_length': 2.221066319895969, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2614183', 'n_tokens_mistral': 718, 'n_tokens_neox': 680, 'n_words': 185}