<commit_before>define [
  'compiled/backbone-ext/DefaultUrlMixin'
  'Backbone'
  'i18n!publishableModuleItem'
], (DefaultUrlMixin, {Model}, I18n) ->


  # A slightly terrible class that branches the urls and json data for the
  # different module types
  class PublishableModuleItem extends Model

    defaults:
      module_type: null
      course_id: null
      module_id: null
      published: true
      publishable: true

    initialize: ->
      @set('unpublishable', @get('publishable'))
      super

    branch: (key) ->
      (@[key][@get('module_type')] or @[key].generic).call(this)

    url:             -> @branch('urls')
    toJSON:          -> @branch('toJSONs')
    disabledMessage: -> @branch('disabledMessages')

    baseUrl: -> "/api/v1/courses/#{@get('course_id')}"

    urls:
      generic:          -> "#{@baseUrl()}/modules/#{@get('module_id')}/items/#{@get('id')}"
      #attachment:       -> "/api/v1/files/#{@get('id')}"
      wiki_page:        -> "#{@baseUrl()}/pages/#{@get('id')}"
      assignment:       -> "#{@baseUrl()}/assignments/#{@get('id')}"
      discussion_topic: -> "#{@baseUrl()}/discussion_topics/#{@get('id')}"
      module:           -> "#{@baseUrl()}/modules/#{@get('id')}"
      quiz: ->
        action = if @get('published') then 'publish' else 'unpublish'
        "/courses/#{@get('course_id')}/quizzes/#{action}"

    toJSONs:
      generic: ->          module_item: @attributes
      #attachment: ->       hidden: !@get('published')
      wiki_page: ->        wiki_page: @attributes
      assignment: ->       assignment: @attributes
      discussion_topic: -> @attributes
      quiz: ->             quizzes: [@get('id')]
      module: ->           module: @attributes

    disabledMessages:
      generic:          -> I18n.t('disabled', 'Publishing is disabled for this item')

    publish: ->
      @save 'published', yes

    unpublish: ->
      @save 'published', no

<commit_msg>update disabled message for unpublish button<commit_after>define [
  'compiled/backbone-ext/DefaultUrlMixin'
  'Backbone'
  'i18n!publishableModuleItem'
], (DefaultUrlMixin, {Model}, I18n) ->


  # A slightly terrible class that branches the urls and json data for the
  # different module types
  class PublishableModuleItem extends Model

    defaults:
      module_type: null
      course_id: null
      module_id: null
      published: true
      publishable: true

    initialize: ->
      @set('unpublishable', @get('publishable'))
      super

    branch: (key) ->
      (@[key][@get('module_type')] or @[key].generic).call(this)

    url:             -> @branch('urls')
    toJSON:          -> @branch('toJSONs')
    disabledMessage: -> @branch('disabledMessages')

    baseUrl: -> "/api/v1/courses/#{@get('course_id')}"

    urls:
      generic:          -> "#{@baseUrl()}/modules/#{@get('module_id')}/items/#{@get('id')}"
      #attachment:       -> "/api/v1/files/#{@get('id')}"
      wiki_page:        -> "#{@baseUrl()}/pages/#{@get('id')}"
      assignment:       -> "#{@baseUrl()}/assignments/#{@get('id')}"
      discussion_topic: -> "#{@baseUrl()}/discussion_topics/#{@get('id')}"
      module:           -> "#{@baseUrl()}/modules/#{@get('id')}"
      quiz: ->
        action = if @get('published') then 'publish' else 'unpublish'
        "/courses/#{@get('course_id')}/quizzes/#{action}"

    toJSONs:
      generic: ->          module_item: @attributes
      #attachment: ->       hidden: !@get('published')
      wiki_page: ->        wiki_page: @attributes
      assignment: ->       assignment: @attributes
      discussion_topic: -> @attributes
      quiz: ->             quizzes: [@get('id')]
      module: ->           module: @attributes

    disabledMessages:
      generic:          -> I18n.t('disabled', 'Publishing is disabled for this item')
      assignment:       -> I18n.t('disabled_assignment', "Can't unpublish if there are student submissions")
      quiz:             -> I18n.t('disabled_quiz', "Can't unpublish if there are student submissions")
      discussion_topic: -> I18n.t('disabled_discussion_topic', "Can't unpublish if there are student submissions")

    publish: ->
      @save 'published', yes

    unpublish: ->
      @save 'published', no


{'fraction_non_alphanumeric': 0.1732134406057738, 'fraction_numerical': 0.005205868433506862, 'mean_word_length': 2.558080808080808, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 54, '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': '5391073', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1311, 'n_words': 262}