X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fstory.js.coffee;h=dc17136e8a15bb45b50b83d8a2b14bb91b91e92b;hb=674d4fb2e72c2e1653b13d026af884559fd9eb4e;hp=6ab4cf13e5df6f3c826311960bfa97fcd9962939;hpb=70027b80e56b5fbea8d63d520fbbf92050959f28;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/models/story.js.coffee b/app/assets/javascripts/models/story.js.coffee index 6ab4cf13..dc17136e 100644 --- a/app/assets/javascripts/models/story.js.coffee +++ b/app/assets/javascripts/models/story.js.coffee @@ -1,15 +1,37 @@ class Pettanr.Story extends Peta.Binder - @single: () -> + url: '/stories/' + + @singular: () -> 'Story' @plural: () -> 'Stories' defaults: { - id: 11 + id: null, + visible: 0, + author_id: null } - initialize: () -> - confirm("Welcome to Panel") + author: () -> + new Pettanr.Cache.Retriever(Pettanr.Author, @get('author_id')) + + overwrite: (options) -> + operators = Pettanr.cache.operators + return false if not operators.author + @set('author_id', operators.author.id) + + is_visible: (operators = Pettanr.cache.operators) -> + switch super(operators) + when null + return true + when false + return false + else + @get('visible') > 0 + + initialize: (attr = {}, options = {}) -> + super(attr, options) + if @id + @url = @url + @id -