class Pettanr.OriginalPicture extends Peta.Content\r
- url: '/original_pictures/'\r
\r
@singular: () ->\r
'OriginalPicture'\r
artist_id: null\r
} \r
\r
- is_visible: (operators) ->\r
+ picture: () ->\r
+ new Pettanr.Cache.Retriever(Pettanr.Picture, @get('picture_id'))\r
+ \r
+ artist: () ->\r
+ new Pettanr.Cache.Retriever(Pettanr.Artist, @get('artist_id'))\r
+ \r
+ is_visible: (operators = Pettanr.cache.operators) ->\r
@is_own(operators)\r
\r
filename: () ->\r
r_url: () ->\r
'/original_pictures/' + @filename()\r
\r
+ license_url: () ->\r
+ '/original_picture_license_groups/new/' + @get('id')\r
+ \r
opt_img_tag: () ->\r
{src: @r_url(), width: @get('width'), height: @get('height')}\r
\r
picture: this\r
})\r
\r
- symbol_option: (cb) ->\r
- _this = this\r
- this.fetch().done ->\r
- cb(_this.tmb_opt_img_tag())\r
+ symbol_option: () ->\r
+ retriever = @retriever()\r
+ @listenTo(retriever, 'retrieve', @retrieve_symbol)\r
+ retriever.retrieve()\r
+ \r
+ retrieve_symbol: (item) -> \r
+ @trigger('ready:symbol', item.tmb_opt_img_tag())\r
+ \r
+ filer_caption: () ->\r
+ history = @history()\r
+ history.fetch({cache: true}).done =>\r
+ caption = if _.isEmpty(history.models)\r
+ 'unpublished'\r
+ else\r
+ head = _.first(history.models)\r
+ Pettanr.to_s(head.get('revision'))\r
+ @trigger('ready:caption', caption)\r
\r
revision: () ->\r
- head = @history()[0]\r
- if head\r
- head.revision()\r
- else\r
- 'unpublished'\r
+ new Pettanr.OriginalPicture.Head({original_picture: this})\r
+ \r
+ history: () ->\r
+ new Pettanr.OriginalPicture.History({original_picture: this})\r
\r
is_unpublished: () ->\r
@get('published_at') == null and @get('stopped_at') == null\r
is_published: () ->\r
@get('published_at') != null\r
\r
- initialize: () ->\r
- if @id\r
- @url = @url + @id\r
+ state: () ->\r
+ switch true\r
+ when @is_unpublished()\r
+ 'unpublished'\r
+ when @is_unlicensed()\r
+ 'unlicensed'\r
+ when @is_stopped()\r
+ 'stopped'\r
+ when @is_published()\r
+ 'published'\r
+ \r
+ initialize: (attr = {}, options = {}) ->\r
+ super(attr, options)\r
+ \r
+class Pettanr.OriginalPicture.History extends Backbone.Collection\r
+ \r
+ initialize: (options) ->\r
+ @original_picture = options.original_picture\r
+ @model = Pettanr.Picture\r
+ @url = @original_picture.default_url() + '/history'\r
+ \r
+class Pettanr.OriginalPicture.Head extends Backbone.View\r
+ tagName: 'span'\r
+ \r
+ initialize: (options) ->\r
+ @original_picture = options.original_picture\r
+ @pictures = new Pettanr.OriginalPicture.History({id: @original_picture.get('id')})\r
+ \r
+ render: () ->\r
+ @pictures.fetch({cache: true}).done =>\r
+ head = @pictures.models[0]\r
+ value = if head\r
+ head.get('revision')\r
+ else\r
+ 'unpublished'\r
+ this.$el.html(value)\r
+ this\r
\r
-class Pettanr.OriginalPicture.Collection extends Backbone.Collection\r
- model: Pettanr.OriginalPicture\r
- url: '/original_pictures'\r