+ picture: () ->\r
+ new Pettanr.Picture({id: @get('picture_id')})\r
+ \r
+ is_visible: (operators) ->\r
+ @is_own(operators)\r
+ \r
+ filename: () ->\r
+ @get('id') + '.' + @get('ext')\r
+ \r
+ mime_type: () ->\r
+ 'image/' + @get('ext')\r
+ \r
+ r_url: () ->\r
+ '/original_pictures/' + @filename()\r
+ \r
+ opt_img_tag: () ->\r
+ {src: @r_url(), width: @get('width'), height: @get('height')}\r
+ \r
+ tmb_opt_img_tag: () ->\r
+ new Pettanr.Image.SymbolPicture({\r
+ attr: {\r
+ src: @r_url()\r
+ },\r
+ picture: this\r
+ })\r
+ \r
+ symbol_option: () ->\r
+ @fetch({cache: true}).done =>\r
+ @trigger('ready:symbol', @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
+ 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
+ \r
+ is_stopped: () ->\r
+ @get('stopped_at') != null\r
+ \r
+ is_unlicensed: () ->\r
+ dt = @get('published_at') || @get('stopped_at')\r
+ return false if not dt\r
+ @get('uploaded_at') > dt\r
+ \r
+ is_published: () ->\r
+ @get('published_at') != null\r
+ \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