<commit_before>#
# Model for a comment
#

Base = require "./base.coffee"
sd = require("sharify").data
_ = require 'underscore'

module.exports = class Comment extends Base

  urlRoot: -> "#{sd.API_URL}/blocks/#{@block_id}/comments"

  initialize: (attrs, {@block_id})->
    super

  sync: (method, model, options)->
    model.set('body', '[deleted]') if model.get('body') is ''
    super

  getPermissions: (user)->
    return "" unless @has('user') and user?

    permissions = ['can-read']

    # Comment owner can edit
    if @belongsToCurrentUser(user)
      permissions.push 'can-edit'

    (_.uniq permissions).join ' '

  belongsToCurrentUser: (user)->
    @get('user').id is user.id

  allows: (permission, user) ->
    _.include @getPermissions(user), permission<commit_msg>no join for comment either<commit_after>#
# Model for a comment
#

Base = require "./base.coffee"
sd = require("sharify").data
_ = require 'underscore'

module.exports = class Comment extends Base

  urlRoot: -> "#{sd.API_URL}/blocks/#{@block_id}/comments"

  initialize: (attrs, {@block_id})->
    super

  sync: (method, model, options)->
    model.set('body', '[deleted]') if model.get('body') is ''
    super

  getPermissions: (user)->
    return "" unless @has('user') and user?

    permissions = ['can-read']

    # Comment owner can edit
    if @belongsToCurrentUser(user)
      permissions.push 'can-edit'

    (_.uniq permissions)

  belongsToCurrentUser: (user)->
    @get('user').id is user.id

  allows: (permission, user) ->
    _.include @getPermissions(user), permission
{'fraction_non_alphanumeric': 0.16114649681528662, 'fraction_numerical': 0.0, 'mean_word_length': 3.566860465116279, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '5485373', 'n_tokens_mistral': 512, 'n_tokens_neox': 501, 'n_words': 129}