class Pettanr.OriginalPicture extends Peta.Content @singular: () -> 'OriginalPicture' @plural: () -> 'OriginalPictures' defaults: { id: null, artist_id: null } is_visible: (operators) -> @is_own(operators) filename: () -> @get('id') + '.' + @get('ext') mime_type: () -> 'image/' + @get('ext') r_url: () -> '/original_pictures/' + @filename() opt_img_tag: () -> {src: @r_url(), width: @get('width'), height: @get('height')} tmb_opt_img_tag: () -> wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height')) {src: @r_url(), width: wh[0], height: wh[1]} symbol_option: () -> @tmb_opt_img_tag() revision: () -> head = @history()[0] if head head.revision() else 'unpublished' is_unpublished: () -> @get('published_at') == null and @get('stopped_at') == null is_stopped: () -> @get('stopped_at') != null is_unlicensed: () -> dt = @get('published_at') || @get('stopped_at') return false if not dt @get('uploaded_at') > dt is_published: () -> @get('published_at') != null initialize: () -> if @id @url = @url + @id class Pettanr.OriginalPicture.Collection extends Backbone.Collection model: Pettanr.OriginalPicture url: '/original_pictures'