-class OriginalPicture extends Item\r
- @single: () ->\r
+class Pettanr.OriginalPicture extends Peta.Content\r
+ \r
+ @singular: () ->\r
'OriginalPicture'\r
\r
@plural: () ->\r
'OriginalPictures'\r
\r
defaults: {\r
- id: 11\r
+ id: null,\r
+ artist_id: null\r
} \r
\r
- initialize: () ->\r
- confirm("Welcome to Panel")\r
+ is_visible: (operators = Pettanr.cache.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
+ license_url: () ->\r
+ '/original_picture_license_groups/new/' + @get('id')\r
+ \r
+ symbol_option: (context, options) ->\r
+ @retrieve(this, {\r
+ success: (symbol_item) => \r
+ options.success.call(context, symbol_item.symbol_file())\r
+ fail: (response, opt) =>\r
+ options.fail.call(context, response, opt)\r
+ })\r
+ \r
+ filer_caption: (context, options) ->\r
+ controller = Manifest.manifest().controllers['original_pictures']\r
+ action = controller.actions['history']\r
+ list = action.find(id: @get('id'))\r
+ list.open(this, {\r
+ success: (pictures) => \r
+ caption = if _.isEmpty(pictures)\r
+ 'unpublished'\r
+ else\r
+ head = _.first(pictures)\r
+ Pettanr.to_s(head.get('revision'))\r
+ options.success.call(context, caption)\r
+ fail: (response, opt) =>\r
+ options.fail.call(context, response, opt)\r
+ })\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
- @test: () ->\r
- confirm( @single())\r
- confirm( @plural() )\r
- confirm( @class_name() )\r
- confirm( @element_name() )\r
- confirm( @table_name() )\r
- \r
+ initialize: (attr = {}, options = {}) ->\r
+ super(attr, options)\r
\r
- test: () ->\r
-\r
-@Panel = Panel\r