cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
storage_image.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # @COPYRIGHT_begin
3 #
4 # Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # @COPYRIGHT_end
19 
20 ##
21 # @package src.clm.views.admin_cm.storage_image
22 # @alldecoratedby{src.clm.utils.decorators.admin_cm_log}
23 #
24 from clm.utils.decorators import admin_cm_log, cm_request
25 from clm.utils.exception import CLMException
26 from clm.models.user import User
27 
28 
29 @admin_cm_log(log=False, pack=True)
30 @cm_request
31 ##
32 #
33 # @clmview_admin_cm
34 # @cm_request_transparent{storage_image.get_list()}
35 #
36 def get_list(cm_response, **data):
37  names = {}
38 
39  for img in cm_response['data']:
40  if str(img['user_id']) not in names:
41  try:
42  user = User.objects.get(pk=img['user_id'])
43  names[str(img['user_id'])] = user.first + " " + user.last
44  except:
45  raise CLMException('user_get')
46  img['owner'] = names[str(img['user_id'])]
47 
48  return cm_response['data']
49 
50 
51 @admin_cm_log(log=False, pack=False)
52 @cm_request
53 ##
54 #
55 # @clmview_admin_cm
56 # @cm_request_transparent{storage_image.get_by_id()}
57 #
58 def get_by_id(cm_response, **data):
59  return cm_response
60 
61 
62 @admin_cm_log(log=True, pack=False)
63 @cm_request
64 ##
65 #
66 # @clmview_admin_cm
67 # @cm_request_transparent{storage_image.delete(}
68 #
69 def delete(cm_response, **data):
70  return cm_response
71 
72 
73 @admin_cm_log(log=True, pack=False)
74 @cm_request
75 ##
76 #
77 # @clmview_admin_cm
78 # @cm_request_transparent{storage_image.edit()}
79 #
80 def edit(cm_response, **data):
81  return cm_response
82 
83 
84 @admin_cm_log(log=True, pack=False)
85 @cm_request
86 ##
87 #
88 # @clmview_admin_cm
89 # @cm_request_transparent{storage_image.download()}
90 #
91 def download(cm_response, **data):
92  return cm_response
93 
94 
95 @admin_cm_log(log=True, pack=False)
96 @cm_request
97 ##
98 #
99 # @clmview_admin_cm
100 # @cm_request_transparent{storage_image.set_public()}
101 #
102 def set_public(cm_response, **data):
103  return cm_response
104 
105 
106 @admin_cm_log(log=True, pack=False)
107 @cm_request
108 ##
109 #
110 # @clmview_admin_cm
111 # @cm_request_transparent{storage_image.set_private()}
112 #
113 def set_private(cm_response, **data):
114  return cm_response
115 
116 
117 @admin_cm_log(log=True, pack=False)
118 @cm_request
119 ##
120 #
121 # @clmview_admin_cm
122 # @cm_request_transparent{storage_image.copy()}
123 #
124 def copy(cm_response, **data):
125  return cm_response
126 
127 
128 @admin_cm_log(log=True, pack=False)
129 @cm_request
130 ##
131 #
132 # @clmview_admin_cm
133 # @cm_request_transparent{storage_image.revoke()}
134 #
135 def revoke(cm_response, **data):
136  return cm_response
137