##// END OF EJS Templates
- Estandarizada la funcion de importar archivos ABS para utilizar el mismo formato de manejo de perfiles.
jsalyrosas -
r183:184
parent child
Show More
@@ -0,0 +1,23
1 {% extends "abscontrol/index.html" %}
No newline at end of file
2 {% block title %}ABS CONTROL:::::IMPORT PROFILE{% endblock %}
No newline at end of file
3 {% block scripting %}
No newline at end of file
4 <script src="/static/static/js/profiles.js"></script>
No newline at end of file
5 {% endblock %}
No newline at end of file
6 {% block mnu_profile %}
No newline at end of file
7 <nav class="MnuHorizontal" id="mnuProfiles">
No newline at end of file
8 <ul>
No newline at end of file
9 <li><a href="/abscontrol/new">New</a></li>
No newline at end of file
10 <li><a href="/abscontrol/import">Import</a></li>
No newline at end of file
11 </ul>
No newline at end of file
12 </nav>
No newline at end of file
13 {% endblock %}
No newline at end of file
14 {% block maincolumn %}
No newline at end of file
15 <div id="maincolumn">
No newline at end of file
16 <div id="divPattern">
No newline at end of file
17 <div class="divUes">
No newline at end of file
18 <label for="lblError">Error:</label>
No newline at end of file
19 <p>{{ txtError }}</p>
No newline at end of file
20 </div>
No newline at end of file
21 </div>
No newline at end of file
22 </div>
No newline at end of file
23 {% endblock %} No newline at end of file
@@ -1,25 +1,25
1 1 from django.conf.urls import patterns, url No newline at end of file
2 2 No newline at end of file
3 3 urlpatterns = patterns('abscontrol.views', No newline at end of file
4 4 url(r'^$', 'index'), No newline at end of file
5 5 url(r'^new/$', 'new'), No newline at end of file
6 6 url(r'^save/$', 'save'), No newline at end of file
7 7 url(r'^view/(?P<profile_id>\d+)/$', 'view'), No newline at end of file
8 8 url(r'^edit/(?P<profile_id>\d+)/$', 'edit'), No newline at end of file
9 9 url(r'^update/(?P<profile_id>\d+)/$', 'update'), No newline at end of file
10 10 url(r'^changeName/(?P<profile_id>\d+)/$', 'changeName'), No newline at end of file
11 11 #url(r'^(?P<profile_id>\d+)/$', 'detail'), No newline at end of file
12 12 url(r'^(?P<profile_id>\d+)/add/$', 'addPattern'), No newline at end of file
13 13 url(r'^(?P<profile_id>\d+)/save/$', 'savePattern'), No newline at end of file
14 14 url(r'^(?P<profile_id>\d+)/edit/(?P<pattern_id>\d+)/$', 'editPattern'), No newline at end of file
15 15 url(r'^(?P<profile_id>\d+)/view/(?P<pattern_id>\d+)/$', 'viewPattern'), No newline at end of file
16 16 url(r'^(?P<profile_id>\d+)/delete/(?P<pattern_id>\d+)/$', 'deletePattern'), No newline at end of file
17 17 #url(r'^(?P<poll_id>\d+)/results/$', 'results'), No newline at end of file
18 18 #url(r'^(?P<poll_id>\d+)/vote/$', 'vote'), No newline at end of file
19 19 url(r'^import/$', 'importProfile'),
20 No newline at end of file
20 url(r'^showImport/$', 'showImport'),
No newline at end of file
21 No newline at end of file
21 url(r'^saveImport/$', 'saveImport'), No newline at end of file
22 22 url(r'^(?P<profile_id>\d+)/(?P<pattern_id>\d+)/overjro/(?P<antenna_id>\d+)/$', 'overJRO'), No newline at end of file
23 23 url(r'^export/(?P<profile_id>\d+)/$', 'export'), No newline at end of file
24 24 url(r'^send/(?P<profile_id>\d+)/$', 'send'), No newline at end of file
25 25 ) No newline at end of file
@@ -1,424 +1,409
1 1 from django.shortcuts import render_to_response, redirect No newline at end of file
2 2 from django.http import HttpResponse No newline at end of file
3 3 from django.conf import settings No newline at end of file
4 4 from django.utils.encoding import smart_str No newline at end of file
5 5 from django.core.servers.basehttp import FileWrapper No newline at end of file
6 6 import mimetypes No newline at end of file
7 7 No newline at end of file
8 8 from datetime import datetime No newline at end of file
9 9 No newline at end of file
10 10 from abscontrol.models import Profile, Pattern, AntennaDown, AntennaUp No newline at end of file
11 11 No newline at end of file
12 12 from util.readABSFile import readABSFile No newline at end of file
13 13 from util.saveABSFile import saveABSFile No newline at end of file
14 14 from scripts.sendFile import sendFile No newline at end of file
15 15 No newline at end of file
16 16 txtAntenna = "[[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ No newline at end of file
17 17 "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ No newline at end of file
18 18 "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ No newline at end of file
19 19 "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ No newline at end of file
20 20 "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ No newline at end of file
21 21 "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ No newline at end of file
22 22 "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ No newline at end of file
23 23 "[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]]" No newline at end of file
24 24 No newline at end of file
25 25 txtTxUp = "[[1,1,1,1,1,1,1,1]," \ No newline at end of file
26 26 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
27 27 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
28 28 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
29 29 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
30 30 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
31 31 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
32 32 "[1,1,1,1,1,1,1,1]]" No newline at end of file
33 33 No newline at end of file
34 34 txtTxDown = "[[1,1,1,1,0,0,0,0]," \ No newline at end of file
35 35 "[1,1,1,1,0,0,0,0]," \ No newline at end of file
36 36 "[1,1,1,1,0,0,0,0]," \ No newline at end of file
37 37 "[1,1,1,1,0,0,0,0]," \ No newline at end of file
38 38 "[0,0,0,0,1,1,1,1]," \ No newline at end of file
39 39 "[0,0,0,0,1,1,1,1]," \ No newline at end of file
40 40 "[0,0,0,0,1,1,1,1]," \ No newline at end of file
41 41 "[0,0,0,0,1,1,1,1]]" No newline at end of file
42 42 No newline at end of file
43 43 txtRxUp = "[[0,0,0,0,1,1,1,1]," \ No newline at end of file
44 44 "[0,0,0,0,1,1,1,1]," \ No newline at end of file
45 45 "[0,0,0,0,1,1,1,1]," \ No newline at end of file
46 46 "[0,0,0,0,1,1,1,1]," \ No newline at end of file
47 47 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
48 48 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
49 49 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
50 50 "[1,1,1,1,1,1,1,1]]" No newline at end of file
51 51 No newline at end of file
52 52 txtRxDown = "[[1,1,1,1,1,1,1,1]," \ No newline at end of file
53 53 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
54 54 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
55 55 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
56 56 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
57 57 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
58 58 "[1,1,1,1,1,1,1,1]," \ No newline at end of file
59 59 "[1,1,1,1,1,1,1,1]]" No newline at end of file
60 60 No newline at end of file
61 61 txtUes = "[0.533333,0.00000,1.06667,0.00000]" No newline at end of file
62 62 No newline at end of file
63 63 def index(request): No newline at end of file
64 64 #latest_poll_list = profileAntenna.objects.all().order_by('-pub_date')[:5] No newline at end of file
65 65 profile_list = Profile.objects.filter(state=1) No newline at end of file
66 66 return render_to_response('abscontrol/index.html', {'profile_list': profile_list}) No newline at end of file
67 67 No newline at end of file
68 68 def new(request): No newline at end of file
69 69 profile_list = Profile.objects.filter(state=1) No newline at end of file
70 70 txtProfile = datetime.now().strftime("%Y%m%d%H%M%S%f") No newline at end of file
71 71 newprofile = Profile(name=txtProfile) No newline at end of file
72 72 newprofile.save() No newline at end of file
73 73 No newline at end of file
74 74 lsPatterns = None No newline at end of file
75 75 No newline at end of file
76 76 return render_to_response('abscontrol/new.html', {'profile_list': profile_list, No newline at end of file
77 77 'txtAntenna' : txtAntenna, No newline at end of file
78 78 'profile_name' : newprofile.name, No newline at end of file
79 79 'profile_id' : newprofile.id, No newline at end of file
80 80 'lsPatterns' : lsPatterns, No newline at end of file
81 81 'txtUes' : txtUes, 'txtTxUp' : txtTxUp, No newline at end of file
82 82 'txtTxDown' : txtTxDown, 'txtRxUp' : txtRxUp, No newline at end of file
83 83 'txtRxDown' : txtRxDown, No newline at end of file
84 84 }) No newline at end of file
85 85 No newline at end of file
86 86 def save(request): No newline at end of file
87 87 No newline at end of file
88 88 txtProfile = request.POST["txtProfile"] No newline at end of file
89 89 No newline at end of file
90 90 txtAntennaUp = request.POST["txtAntennaUp"] No newline at end of file
91 91 txtTxUp = request.POST["txtTxUp"] No newline at end of file
92 92 txtRxUp = request.POST["txtRxUp"] No newline at end of file
93 93 txtUesUp = request.POST["txtUesUp"] No newline at end of file
94 94 No newline at end of file
95 95 txtAntennaDown = request.POST["txtAntennaDown"] No newline at end of file
96 96 txtTxDown = request.POST["txtTxDown"] No newline at end of file
97 97 txtRxDown = request.POST["txtRxDown"] No newline at end of file
98 98 txtUesDown = request.POST["txtUesDown"] No newline at end of file
99 99 No newline at end of file
100 100 newprofile = Profile(name=txtProfile) No newline at end of file
101 101 newprofile.save() No newline at end of file
102 102 No newline at end of file
103 103 newpattern = newprofile.pattern_set.create(value=1) No newline at end of file
104 104 newpattern.antennaup_set.create(value=txtAntennaUp,tx=txtTxUp,rx=txtRxUp,ues=txtUesUp) No newline at end of file
105 105 newpattern.antennadown_set.create(value=txtAntennaDown,tx=txtTxDown,rx=txtRxDown,ues=txtUesDown) No newline at end of file
106 106 No newline at end of file
107 107 newurl = '/abscontrol/view/%d' % newprofile.id No newline at end of file
108 108 No newline at end of file
109 109 return redirect(newurl) No newline at end of file
110 110 No newline at end of file
111 111 def update(request, profile_id): No newline at end of file
112 112 txtProfile = request.POST["txtProfile"] No newline at end of file
113 113 No newline at end of file
114 114 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
115 115 objProfile.name = txtProfile No newline at end of file
116 116 objProfile.state = 1 No newline at end of file
117 117 objProfile.save() No newline at end of file
118 118 No newline at end of file
119 119 newurl = '/abscontrol/view/%d' % objProfile.id No newline at end of file
120 120 return redirect(newurl) No newline at end of file
121 121 No newline at end of file
122 122 def changeName(request, profile_id): No newline at end of file
123 123 profile_list = Profile.objects.filter(state=1) No newline at end of file
124 124 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
125 125 lsPatterns = objProfile.pattern_set.all() No newline at end of file
126 126 No newline at end of file
127 127 return render_to_response('abscontrol/changeName.html', {'profile_list': profile_list, No newline at end of file
128 128 'objProfile': objProfile, No newline at end of file
129 129 'lsPatterns' : lsPatterns, No newline at end of file
130 130 }) No newline at end of file
131 131 No newline at end of file
132 132 def view(request, profile_id): No newline at end of file
133 133 nextPattern = 0 No newline at end of file
134 134 No newline at end of file
135 135 if request.method == 'GET' and 'pattern' in request.GET: No newline at end of file
136 136 pattern_value = request.GET["pattern"] No newline at end of file
137 137 else: No newline at end of file
138 138 pattern_value = 1 No newline at end of file
139 139 No newline at end of file
140 140 profile_list = Profile.objects.filter(state=1) No newline at end of file
141 141 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
142 142 No newline at end of file
143 143 lsPatterns = objProfile.pattern_set.all() No newline at end of file
144 144 patternChoosen = objProfile.pattern_set.get(value=pattern_value) No newline at end of file
145 145 objAntennaUp = patternChoosen.antennaup_set.get() No newline at end of file
146 146 objAntennaDown = patternChoosen.antennadown_set.get() No newline at end of file
147 147 No newline at end of file
148 148 if len(lsPatterns) > 1: No newline at end of file
149 149 if pattern_value == 1: No newline at end of file
150 150 nextValuePattern = pattern_value + 1 No newline at end of file
151 151 nextPattern = objProfile.pattern_set.get(value=nextValuePattern) No newline at end of file
152 152 No newline at end of file
153 153 No newline at end of file
154 154 return render_to_response('abscontrol/view.html', {'objProfile': objProfile, 'profile_list': profile_list, No newline at end of file
155 155 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, No newline at end of file
156 156 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, No newline at end of file
157 157 'nextPattern' : nextPattern, No newline at end of file
158 158 }) No newline at end of file
159 159 No newline at end of file
160 160 def edit(request, profile_id): No newline at end of file
161 161 if request.method == 'GET' and 'pattern' in request.GET: No newline at end of file
162 162 pattern_value = request.GET["pattern"] No newline at end of file
163 163 else: No newline at end of file
164 164 pattern_value = 1 No newline at end of file
165 165 No newline at end of file
166 166 profile_list = Profile.objects.filter(state=1) No newline at end of file
167 167 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
168 168 No newline at end of file
169 169 lsPatterns = objProfile.pattern_set.all() No newline at end of file
170 170 patternChoosen = objProfile.pattern_set.get(value=pattern_value) No newline at end of file
171 171 objAntennaUp = patternChoosen.antennaup_set.get() No newline at end of file
172 172 objAntennaDown = patternChoosen.antennadown_set.get() No newline at end of file
173 173 No newline at end of file
174 174 return render_to_response('abscontrol/edit.html', {'objProfile': objProfile, 'profile_list': profile_list, No newline at end of file
175 175 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, No newline at end of file
176 176 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, No newline at end of file
177 177 }) No newline at end of file
178 178 No newline at end of file
179 179 def addPattern(request, profile_id): No newline at end of file
180 180 profile_list = Profile.objects.filter(state=1) No newline at end of file
181 181 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
182 182 No newline at end of file
183 183 return render_to_response('abscontrol/addPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, No newline at end of file
184 184 'txtAntenna' : txtAntenna, 'txtUes' : txtUes, No newline at end of file
185 185 'txtTxUp' : txtTxUp, 'txtTxDown' : txtTxDown, No newline at end of file
186 186 'txtRxUp' : txtRxUp, 'txtRxDown' : txtRxDown, No newline at end of file
187 187 }) No newline at end of file
188 188 No newline at end of file
189 189 def editPattern(request, profile_id, pattern_id): No newline at end of file
190 190 profile_list = Profile.objects.filter(state=1) No newline at end of file
191 191 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
192 192 lsPatterns = objProfile.pattern_set.all() No newline at end of file
193 193 patternChoosen = Pattern.objects.get(pk=pattern_id) No newline at end of file
194 194 objAntennaUp = patternChoosen.antennaup_set.get() No newline at end of file
195 195 objAntennaDown = patternChoosen.antennadown_set.get() No newline at end of file
196 196 No newline at end of file
197 197 return render_to_response('abscontrol/editPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, No newline at end of file
198 198 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, No newline at end of file
199 199 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, No newline at end of file
200 200 }) No newline at end of file
201 201 No newline at end of file
202 202 def savePattern(request, profile_id): No newline at end of file
203 203 pattern_id = 0 No newline at end of file
204 204 method = "save" No newline at end of file
205 205 No newline at end of file
206 206 if 'pattern_id' in request.POST: No newline at end of file
207 207 pattern_id = request.POST["pattern_id"] No newline at end of file
208 208 method = "update" No newline at end of file
209 209 No newline at end of file
210 210 maxValuePattern = 0 No newline at end of file
211 211 txtAntennaUp = request.POST["txtAntennaUp"] No newline at end of file
212 212 txtTxUp = request.POST["txtTxUp"] No newline at end of file
213 213 txtRxUp = request.POST["txtRxUp"] No newline at end of file
214 214 txtUesUp = request.POST["txtUesUp"] No newline at end of file
215 215 No newline at end of file
216 216 txtAntennaDown = request.POST["txtAntennaDown"] No newline at end of file
217 217 txtTxDown = request.POST["txtTxDown"] No newline at end of file
218 218 txtRxDown = request.POST["txtRxDown"] No newline at end of file
219 219 txtUesDown = request.POST["txtUesDown"] No newline at end of file
220 220 No newline at end of file
221 221 mode = request.POST["mode"] No newline at end of file
222 222 No newline at end of file
223 223 if method == "save": No newline at end of file
224 224 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
225 225 lsPatterns = objProfile.pattern_set.all() No newline at end of file
226 226 if len(lsPatterns) > 0: No newline at end of file
227 227 for element in lsPatterns: No newline at end of file
228 228 if element.value > maxValuePattern: No newline at end of file
229 229 maxPattern = element.value No newline at end of file
230 230 else: No newline at end of file
231 231 maxPattern = 0 No newline at end of file
232 232 No newline at end of file
233 233 if maxPattern < 10 : No newline at end of file
234 234 newValuePattern = maxPattern + 1 No newline at end of file
235 235 newpattern = objProfile.pattern_set.create(value=newValuePattern) No newline at end of file
236 236 newpattern.antennaup_set.create(value=txtAntennaUp,tx=txtTxUp,rx=txtRxUp,ues=txtUesUp) No newline at end of file
237 237 newpattern.antennadown_set.create(value=txtAntennaDown,tx=txtTxDown,rx=txtRxDown,ues=txtUesDown) No newline at end of file
238 238 error = 0 No newline at end of file
239 239 else: No newline at end of file
240 240 error = 1 # Can not add more patterns No newline at end of file
241 241 No newline at end of file
242 242 if mode == "e": No newline at end of file
243 243 newurl = '/abscontrol/%d/edit/%d' % (int(profile_id), newpattern.id) No newline at end of file
244 244 else: No newline at end of file
245 245 newurl = '/abscontrol/%d/view/%d' % (int(profile_id), newpattern.id) No newline at end of file
246 246 else: No newline at end of file
247 247 txtAntennaUpId = request.POST["txtAntennaUpId"] No newline at end of file
248 248 objAntennaUp = AntennaUp.objects.get(pk=txtAntennaUpId) No newline at end of file
249 249 objAntennaUp.value = txtAntennaUp No newline at end of file
250 250 objAntennaUp.tx = txtTxUp No newline at end of file
251 251 objAntennaUp.rx = txtRxUp No newline at end of file
252 252 objAntennaUp.ues = txtUesUp No newline at end of file
253 253 objAntennaUp.save() No newline at end of file
254 254 No newline at end of file
255 255 txtAntennaDownId = request.POST["txtAntennaDownId"] No newline at end of file
256 256 objAntennaDown = AntennaDown.objects.get(pk=txtAntennaDownId) No newline at end of file
257 257 objAntennaDown.value = txtAntennaDown No newline at end of file
258 258 objAntennaDown.tx = txtTxDown No newline at end of file
259 259 objAntennaDown.rx = txtRxDown No newline at end of file
260 260 objAntennaDown.ues = txtUesDown No newline at end of file
261 261 objAntennaDown.save() No newline at end of file
262 262 No newline at end of file
263 263 if mode == "e": No newline at end of file
264 264 newurl = '/abscontrol/%d/edit/%d' % (int(profile_id), int(pattern_id)) No newline at end of file
265 265 else: No newline at end of file
266 266 newurl = '/abscontrol/%d/view/%d' % (int(profile_id), int(pattern_id)) No newline at end of file
267 267 No newline at end of file
268 268 return redirect(newurl) No newline at end of file
269 269 No newline at end of file
270 270 def viewPattern(request, profile_id, pattern_id): No newline at end of file
271 271 No newline at end of file
272 272 profile_list = Profile.objects.filter(state=1) No newline at end of file
273 273 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
274 274 No newline at end of file
275 275 patternChoosen = Pattern.objects.get(pk=pattern_id) No newline at end of file
276 276 No newline at end of file
277 277 objAntennaUp = patternChoosen.antennaup_set.get() No newline at end of file
278 278 objAntennaDown = patternChoosen.antennadown_set.get() No newline at end of file
279 279 No newline at end of file
280 280 lsPatterns = objProfile.pattern_set.all() No newline at end of file
281 281 No newline at end of file
282 282 return render_to_response('abscontrol/viewPattern.html', {'objProfile': objProfile, 'profile_list': profile_list, No newline at end of file
283 283 'patternChoosen' : patternChoosen, 'lsPatterns' : lsPatterns, No newline at end of file
284 284 'antennaUp' : objAntennaUp, 'antennaDown' : objAntennaDown, No newline at end of file
285 285 }) No newline at end of file
286 286 No newline at end of file
287 287 def deletePattern(request, profile_id, pattern_id): No newline at end of file
288 288 newurl = '/abscontrol/edit/%d' % int(profile_id) No newline at end of file
289 289 No newline at end of file
290 290 return redirect(newurl) No newline at end of file
291 291 No newline at end of file
292 292 def importProfile(request): No newline at end of file
293 293 profile_list = Profile.objects.filter(state=1) No newline at end of file
294 294 return render_to_response('abscontrol/import.html', {'profile_list': profile_list,}) No newline at end of file
295 295
296 No newline at end of file
296 def showImport(request): No newline at end of file
297 297 profile_list = Profile.objects.filter(state=1) No newline at end of file
298 298 if request.method == 'POST': No newline at end of file
299 299 txtFilename = request.FILES['txtFile'] No newline at end of file
300 300 if txtFilename: No newline at end of file
301 301 destination = open('/tmp/'+txtFilename.name, 'wb+') No newline at end of file
302 302 for chunk in txtFilename.chunks(): No newline at end of file
303 303 destination.write(chunk) No newline at end of file
304 304 destination.close() No newline at end of file
305 305 filename = '/tmp/'+txtFilename.name No newline at end of file
306 306 readFile = readABSFile(filename) No newline at end of file
307 307 expName, num_patterns, patterns = readFile.getMetadata()
308 No newline at end of file
308 else:
No newline at end of file
309 No newline at end of file
309 txtFilename = "Error"
No newline at end of file
310 #content = "Error"
No newline at end of file
311 expName = ""
No newline at end of file
312 num_patterns = 0
No newline at end of file
313
No newline at end of file
314 return render_to_response('abscontrol/upload-edit.html', {'txtFilename': txtFilename, 'patterns' : patterns,
No newline at end of file
315 'expName' : expName, 'num_patterns' : num_patterns,
No newline at end of file
316 'profile_list': profile_list,
No newline at end of file
317 })
No newline at end of file
318
No newline at end of file
319 def saveImport(request):
No newline at end of file
320 patterns = []
No newline at end of file
321
No newline at end of file
322 expName = request.POST["txtProfile"]
No newline at end of file
323 num_patterns = int(request.POST["txtNumPatterns"])
No newline at end of file
324 No newline at end of file
325 310 newprofile = Profile(name=expName) No newline at end of file
326 311 newprofile.save()
312 No newline at end of file
327
No newline at end of file
313 No newline at end of file
328 for i in range(0,num_patterns):
No newline at end of file
314 No newline at end of file
329 number = request.POST["txtNumberPattern"+str(i+1)]
No newline at end of file
315 No newline at end of file
330 txtAntennaUp = request.POST["txtAntennaUp"+str(i+1)]
No newline at end of file
316 No newline at end of file
331 txtAntennaDown = request.POST["txtAntennaDown"+str(i+1)]
No newline at end of file
317 No newline at end of file
332 dicPattern = {"number" : number, "up" : txtAntennaUp, "down" : txtAntennaDown}
No newline at end of file
318 No newline at end of file
333 patterns.append(dicPattern)
No newline at end of file
319 No newline at end of file
334 newpattern = newprofile.pattern_set.create(value=number)
No newline at end of file
320 No newline at end of file
335 newpattern.antennaup_set.create(value=txtAntennaUp)
No newline at end of file
321 No newline at end of file
336 newpattern.antennadown_set.create(value=txtAntennaDown)
No newline at end of file
337
No newline at end of file
338 newurl = '/abscontrol/view/%d' % newprofile.id
No newline at end of file
339 No newline at end of file
340 322 return redirect(newurl)
323 No newline at end of file
341 '''
No newline at end of file
324 No newline at end of file
342 return render_to_response('abscontrol/upload-view.html', {'expName' : expName, 'patterns' : patterns,
No newline at end of file
325 No newline at end of file
343 'num_patterns' : num_patterns,
No newline at end of file
326 No newline at end of file
344 })
No newline at end of file
327 No newline at end of file
345 ''' No newline at end of file
No newline at end of file
328 txtError = "No file."
No newline at end of file
329
No newline at end of file
330 return render_to_response('abscontrol/error.html', {'profile_list': profile_list, 'txtError' : txtError, }) No newline at end of file
346 331 No newline at end of file
347 332 def overJRO(request, profile_id, pattern_id, antenna_id): No newline at end of file
348 333 if request.GET["beam"] == "Up": No newline at end of file
349 334 objAntenna = AntennaUp.objects.get(pk=antenna_id) No newline at end of file
350 335 else: No newline at end of file
351 336 objAntenna = AntennaDown.objects.get(pk=antenna_id) No newline at end of file
352 337 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
353 338 exp_name = objProfile.name No newline at end of file
354 339 No newline at end of file
355 340 phase_tx = objAntenna.value No newline at end of file
356 341 gain_tx = objAntenna.tx No newline at end of file
357 342 gain_rx = objAntenna.rx No newline at end of file
358 343 ues_tx = objAntenna.ues No newline at end of file
359 344 only_rx = objAntenna.only_rx No newline at end of file
360 345 No newline at end of file
361 346 return exp_name, phase_tx, gain_tx, gain_rx, ues_tx, only_rx No newline at end of file
362 347 No newline at end of file
363 348 def export(request, profile_id): No newline at end of file
364 349 listPatterns = [] No newline at end of file
365 350 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
366 351 exp_name = objProfile.name No newline at end of file
367 352 lsPatterns = objProfile.pattern_set.all() No newline at end of file
368 353 for element in lsPatterns: No newline at end of file
369 354 objAntennaUp = element.antennaup_set.get() No newline at end of file
370 355 objAntennaDown = element.antennadown_set.get() No newline at end of file
371 356 dicPatterns = {"number" : element.value, "up" : objAntennaUp.value, "down" : objAntennaDown.value} No newline at end of file
372 357 listPatterns.append(dicPatterns) No newline at end of file
373 358 No newline at end of file
374 359 absFile = saveABSFile() No newline at end of file
375 360 absFile.setParameters(settings.MEDIA_ROOT, exp_name, listPatterns) No newline at end of file
376 361 filename, filesize = absFile.save() No newline at end of file
377 362 No newline at end of file
378 363 wrapper = FileWrapper( open( filename, "r" ) ) No newline at end of file
379 364 content_type = mimetypes.guess_type( filename )[0] No newline at end of file
380 365 No newline at end of file
381 366 response = HttpResponse(wrapper, content_type = content_type) No newline at end of file
382 367 response['Content-Description'] = 'File Transfer' No newline at end of file
383 368 response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(filename) No newline at end of file
384 369 response['Content-Transfer-Encoding'] = 'binary' No newline at end of file
385 370 response['Expires'] = '0' No newline at end of file
386 371 response['Cache-Control'] = 'must-revalidate' No newline at end of file
387 372 response['Pragma'] = 'public' No newline at end of file
388 373 response['Content-Length'] = '%s' % str(filesize) No newline at end of file
389 374 response['X-Sendfile'] = '%s' % smart_str(filename) No newline at end of file
390 375 No newline at end of file
391 376 return response No newline at end of file
392 377 No newline at end of file
393 378 def send(request, profile_id): No newline at end of file
394 379 listPatterns = [] No newline at end of file
395 380 objProfile = Profile.objects.get(pk=profile_id) No newline at end of file
396 381 exp_name = objProfile.name No newline at end of file
397 382 No newline at end of file
398 383 lsPatterns = objProfile.pattern_set.all() No newline at end of file
399 384 for element in lsPatterns: No newline at end of file
400 385 objAntennaUp = element.antennaup_set.get() No newline at end of file
401 386 objAntennaDown = element.antennadown_set.get() No newline at end of file
402 387 dicPatterns = {"number" : element.value, "up" : objAntennaUp.value, "down" : objAntennaDown.value} No newline at end of file
403 388 listPatterns.append(dicPatterns) No newline at end of file
404 389 No newline at end of file
405 390 absFile = saveABSFile() No newline at end of file
406 391 absFile.setParameters(settings.MEDIA_ROOT, exp_name, listPatterns) No newline at end of file
407 392 filename, filesize = absFile.save() No newline at end of file
408 393 No newline at end of file
409 394 apiclient = sendFile() No newline at end of file
410 395 apiclient.execute(filename) No newline at end of file
411 396 output = apiclient.getOutput() No newline at end of file
412 397 No newline at end of file
413 398 if output == "OK": No newline at end of file
414 399 message = "File sent successfully." No newline at end of file
415 400 objProfile.hits += 1 No newline at end of file
416 401 objProfile.save() No newline at end of file
417 402 else: No newline at end of file
418 403 message = "Error sending file." No newline at end of file
419 404 No newline at end of file
420 405 profile_list = Profile.objects.all() No newline at end of file
421 406 No newline at end of file
422 407 return render_to_response('abscontrol/sendFile.html', {'message': message, "profile_list" : profile_list, No newline at end of file
423 408 'objProfile': objProfile, No newline at end of file
424 409 }) No newline at end of file
@@ -1,23 +1,23
1 1 {% extends "abscontrol/index.html" %} No newline at end of file
2 2 {% block title %}ABS CONTROL:::::IMPORT PROFILE{% endblock %} No newline at end of file
3 3 No newline at end of file
4 4 {% block mnu_profile %} No newline at end of file
5 5 <nav class="MnuHorizontal" id="mnuProfiles"> No newline at end of file
6 6 <ul> No newline at end of file
7 7 <li><a href="#" id="lnkUpload">Upload</a></li> No newline at end of file
8 8 <li><a href="#" id="lnkCancel">Cancel</a></li> No newline at end of file
9 9 </ul> No newline at end of file
10 10 </nav> No newline at end of file
11 11 {% endblock %} No newline at end of file
12 12 {% block maincolumn %} No newline at end of file
13 13 <div id="maincolumn">
14 No newline at end of file
14 <form name="frmImport" id="frmImport" action="/abscontrol/showImport/" method="post" enctype="multipart/form-data"> No newline at end of file
15 15 <div id="divPattern"> No newline at end of file
16 16 <div class="divUes"> No newline at end of file
17 17 <label for="lblFile">Choose File:</label> No newline at end of file
18 18 <input type="file" name="txtFile" /> No newline at end of file
19 19 </div> No newline at end of file
20 20 </div> No newline at end of file
21 21 </form> No newline at end of file
22 22 </div> No newline at end of file
23 23 {% endblock %} No newline at end of file
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now