Sha256: 167794e99e5e9685c2f58d25d7fc4cf7dd6b7d15e994975aaa642f693cc1623c

Contents?: true

Size: 1.49 KB

Versions: 26

Compression:

Stored size: 1.49 KB

Contents

class App.Models.Article extends App.Models.Base
  @identity = "Article"
  @resources =
    url: '/user/articles', paginate: {per: 5}
    main:
      url: '/articles', paginate: {per: 3}
    admin:
      url: '/admin/articles', paginate: {per: 4}

  @attributes =
    title:
      validations:
        presence: true
        length: {within: [3, 255]}
    content:
      validations:
        presence: true
        length: {minimum: 100}
      remoteName: "text"
    createdAt:
      type: "Date"
      remoteName: "created_at"
    updatedAt:
      type: "Date"
      remoteName: "updated_at"
    commentsCount:
      type: "Int"
      remoteName: "comments_count"
    publishedAt:
      type: "Date"
      remoteName: "published_at"
    published: {}
    adminReview:
      remoteName: "admin_review"
    adminRate:
      type: "Int"
      remoteName: "admin_rate"
    categoryId:
      type: "Int"
      remoteName: "category_id"
    adminReviewStartedAt:
      remoteName: "admin_review_started_at"

  @receivedSignal: (signal, data) ->

  @validate = ["vulgarityLevel"]

  constructor: (data) ->
    super data
    @published = if @publishedAt? then true else false

  receivedSignal: (signal, data) ->

  vulgarityLevel: ->
    if (this.title? and /fuck/i.exec(this.title)) or (this.content? and /fuck/i.exec(this.content))
      this.addErrorMessage "Article contains strong language.", for: 'base'

  setDefaultValuesForAdminReview: ->
    @adminRate ?= 3
    @categoryId ?= 6
    @adminReviewStartedAt = Date.now()

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
loco-rails-3.0.3 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.5.3 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.5.2 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-3.0.2 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-3.0.1 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.5.1 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.5.0 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.4.0 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.3.0 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-3.0.0 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.2.2 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.2.1 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.2.0 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.1.0 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-2.0.0 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-1.5.2 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-1.5.1 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-1.5.0 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-1.4.0 test/dummy/app/assets/javascripts/models/article.coffee
loco-rails-1.3.3 test/dummy/app/assets/javascripts/models/article.coffee