OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / assets / javascripts / models / picture.js.coffee
1 class Pettanr.Picture extends Peta.Content\r
2   \r
3   @singular: () ->\r
4     'Picture'\r
5   \r
6   @plural: () ->\r
7     'Pictures'\r
8   \r
9   defaults: {\r
10     id: null\r
11   } \r
12   \r
13   @trace_routes: () ->\r
14     {\r
15       resource_picture: ['resource_picture_picture', 'resource_picture']\r
16     }\r
17   \r
18   is_visible: (operators = Pettanr.cache.operators) ->\r
19     return true\r
20   \r
21   filename: () ->\r
22     @get('id') + '.' + @get('ext')\r
23   \r
24   gifname: () ->\r
25     @get('id') + '.gif'\r
26   \r
27   mime_type: () ->\r
28     'image/' + @get('ext')\r
29   \r
30   r_url: (subdir = null) ->\r
31     q = if subdir\r
32       '?subdir=' + subdir\r
33     else\r
34       ''\r
35     '/pictures/' + @filename() + q\r
36   \r
37   alt_name: () ->\r
38     lgn = Pettanr.to_s(@license().license_group().get('caption'))\r
39     ln = Pettanr.to_s(@license().get('caption'))\r
40     lgn + '[' + ln + ']'\r
41   \r
42   symbol_option: (context, options) ->\r
43     @retrieve(this, {\r
44       success: (symbol_item) => \r
45         options.success.call(context, symbol_item.to_symbol())\r
46       fail: (response, opt) =>\r
47         options.fail.call(context, response, opt)\r
48     })\r
49   \r
50   is_enable: () ->\r
51     if @head().resource_picture()\r
52       true\r
53     else\r
54       false\r
55   \r
56   @head: (opid) ->\r
57     #Picture.find( conditions => ['original_picture_id = ?', opid], :order => 'pictures.revision desc')\r
58   \r
59   head: () ->\r
60     Picture.head(@get('original_picture_id'))\r
61   \r
62   is_head: () ->\r
63     #this == @head()\r
64   \r
65   subdirs: () ->\r
66     if @license_extend().reverse < 0\r
67       ['']\r
68     else\r
69       ['', 'v', 'h', 'vh']\r
70   \r
71   is_showable: (operators = Pettanr.cache.operators) ->\r
72     return false if not @original_picture()\r
73     return true if @is_own(operators)\r
74     #@is_enable() and @is_head()\r
75   \r
76   initialize: (attr = {}, options = {}) ->\r
77     super(attr, options)\r
78   \r