<commit_before>{Module} = require 'jraphical'

module.exports = class JVocabulary extends Module

  @share()

  {daisy} = require 'bongo'
  {KodingError} = require '../error'

  {permit} = require './group/permissionset'

  Validators = require './group/validators'
  {Inflector} = require 'bongo'

  @trait __dirname, '../traits/protected'

  @set
    softDelete      : yes
    sharedMethods   :
      static        : ['create']
      instance      : ['remove', 'modify']
    schema          :
      title         : String
      description   : String
      exclusive     :
        type        : Boolean
        default     : no
      group         :
        type        : String
        validate    : require('./name').validateName
      collectionName:
        type        : String
        default     : ->
          {name} = require './tag'
          "#{Inflector.pluralize name}__#{@group.replace /-/g, '_'}"
    relationships   :
      tag           :
        targetType  : 'JTag'
        as          : 'vocabulary'
    permissions     :
      'create vocabularies'     : ['moderator']
      'edit vocabularies'       : ['moderator']
      'delete vocabularies'     : ['moderator']
      'edit own vocabularies'   : ['moderator']
      'delete own vocabularies' : ['moderator']

  @create$ = permit 'create vocabularies',
    success:(client, formData, callback)->
      formData.group = client.context.group
      @create formData, callback

  @create = (formData, callback)->
    JGroup = require './group'
    vocabulary = new this
      title       : formData.title
      description : formData.description
      group       : formData.group
    queue = [
      ->
        vocabulary.save (err)->
          if err then callback err
          else queue.next()
    ]
    if formData.group
      queue.push ->
        JGroup.one slug: formData.group, (err, group)-><commit_msg>vocabularies: let's comment-out the perms until we're ready...<commit_after>{Module} = require 'jraphical'

module.exports = class JVocabulary extends Module

  @share()

  {daisy} = require 'bongo'
  {KodingError} = require '../error'

  {permit} = require './group/permissionset'

  Validators = require './group/validators'
  {Inflector} = require 'bongo'

  @trait __dirname, '../traits/protected'

  @set
    softDelete      : yes
    sharedMethods   :
      static        : ['create']
      instance      : ['remove', 'modify']
    schema          :
      title         : String
      description   : String
      exclusive     :
        type        : Boolean
        default     : no
      group         :
        type        : String
        validate    : require('./name').validateName
      collectionName:
        type        : String
        default     : ->
          {name} = require './tag'
          "#{Inflector.pluralize name}__#{@group.replace /-/g, '_'}"
    relationships   :
      tag           :
        targetType  : 'JTag'
        as          : 'vocabulary'
    # permissions     :
    #   'create vocabularies'     : ['moderator']
    #   'edit vocabularies'       : ['moderator']
    #   'delete vocabularies'     : ['moderator']
    #   'edit own vocabularies'   : ['moderator']
    #   'delete own vocabularies' : ['moderator']

  @create$ = permit 'create vocabularies',
    success:(client, formData, callback)->
      formData.group = client.context.group
      @create formData, callback

  @create = (formData, callback)->
    JGroup = require './group'
    vocabulary = new this
      title       : formData.title
      description : formData.description
      group       : formData.group
    queue = [
      ->
        vocabulary.save (err)->
          if err then callback err
          else queue.next()
    ]
    if formData.group
      queue.push ->
        JGroup.one slug: formData.group, (err, group)->
{'fraction_non_alphanumeric': 0.11929000261028452, 'fraction_numerical': 0.0, 'mean_word_length': 1.8176470588235294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '7552473', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1122, 'n_words': 266}