OSDN Git Service

fix filer
[pettanr/pettanr.git] / app / assets / javascripts / models / original_picture.js.coffee
1 class Pettanr.OriginalPicture extends Peta.Content\r
2   url: '/original_pictures/'\r
3   \r
4   @singular: () ->\r
5     'OriginalPicture'\r
6   \r
7   @plural: () ->\r
8     'OriginalPictures'\r
9   \r
10   defaults: {\r
11     id: null,\r
12     artist_id: null\r
13   } \r
14   \r
15   is_visible: (operators) ->\r
16     @is_own(operators)\r
17   \r
18   filename: () ->\r
19     @get('id') + '.' + @get('ext')\r
20   \r
21   mime_type: () ->\r
22     'image/' + @get('ext')\r
23   \r
24   r_url: () ->\r
25     '/original_pictures/' + @filename()\r
26   \r
27   opt_img_tag: () ->\r
28     {src: @r_url(), width: @get('width'), height: @get('height')}\r
29   \r
30   tmb_opt_img_tag: () ->\r
31     wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height'))\r
32     {src: @r_url(), width: wh[0], height: wh[1]}\r
33   \r
34   symbol_option: (cb) ->\r
35     _this = this\r
36     this.fetch().done ->\r
37       cb(_this.tmb_opt_img_tag())\r
38   \r
39   revision: () ->\r
40     head = @history()[0]\r
41     if head\r
42       head.revision()\r
43     else\r
44       'unpublished'\r
45   \r
46   is_unpublished: () ->\r
47     @get('published_at') == null and @get('stopped_at') == null\r
48   \r
49   is_stopped: () ->\r
50     @get('stopped_at') != null\r
51   \r
52   is_unlicensed: () ->\r
53     dt = @get('published_at') || @get('stopped_at')\r
54     return false if not dt\r
55     @get('uploaded_at') > dt\r
56   \r
57   is_published: () ->\r
58     @get('published_at') != null\r
59   \r
60   initialize: () ->\r
61     if @id\r
62       @url = @url + @id\r
63   \r
64 class Pettanr.OriginalPicture.Collection extends Backbone.Collection\r
65   model: Pettanr.OriginalPicture\r
66   url: '/original_pictures'\r