##// END OF EJS Templates
- Implementando la funcion Import. (Desarrollo no concluido)
jsalyrosas -
r147:148
parent child
Show More
@@ -0,0 +1,16
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
No newline at end of file
4 {% block content %}
No newline at end of file
5 <div id="content">
No newline at end of file
6 <form action="/abscontrol/saveImport/" method="post" enctype="multipart/form-data">
No newline at end of file
7 <div id="divPattern">
No newline at end of file
8 <div class="divUes">
No newline at end of file
9 <label for="lblFile">Choose File:</label>
No newline at end of file
10 <input type="file" name="txtFile" />
No newline at end of file
11 <input type="submit" name="btnSend" value="Upload" />
No newline at end of file
12 </div>
No newline at end of file
13 </div>
No newline at end of file
14 </form>
No newline at end of file
15 </div>
No newline at end of file
16 {% endblock %} No newline at end of file
@@ -0,0 +1,17
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
No newline at end of file
4 {% block content %}
No newline at end of file
5 <div id="content">
No newline at end of file
6 <div id="divPattern">
No newline at end of file
7 <div class="divUes">
No newline at end of file
8 <label for="lblFile">File:</label>
No newline at end of file
9 <label for="lblFilename">{{ txtFilename }}</label>
No newline at end of file
10 </div>
No newline at end of file
11 <div class="divUes">
No newline at end of file
12 <label for="lblFile">content:</label>
No newline at end of file
13 <p>{{ content }}</p>
No newline at end of file
14 </div>
No newline at end of file
15 </div>
No newline at end of file
16 </div>
No newline at end of file
17 {% endblock %} No newline at end of file
1 NO CONTENT: new file 10644
NO CONTENT: new file 10644
@@ -0,0 +1,20
1 '''
No newline at end of file
2 Created on May 2, 2013
No newline at end of file
3
No newline at end of file
4 @author: Jose Antonio Sal y Rosas Celi
No newline at end of file
5 @contact: jose.salyrosas@jro.igp.gob.pe
No newline at end of file
6 '''
No newline at end of file
7
No newline at end of file
8 class readABSFile(object):
No newline at end of file
9
No newline at end of file
10 __scriptName = "readABSFile.py"
No newline at end of file
11
No newline at end of file
12 def __init__(self, filename):
No newline at end of file
13 self.fileName = filename
No newline at end of file
14
No newline at end of file
15 def readFile(self):
No newline at end of file
16 destination = open(self.fileName, 'wb+')
No newline at end of file
17
No newline at end of file
18 destination.close()
No newline at end of file
19
No newline at end of file
20 No newline at end of file
@@ -17,17 +17,26
17 No newline at end of file
17
18 class PatternInline(admin.StackedInline): No newline at end of file
18 class PatternInline(admin.StackedInline):
19 model = Pattern No newline at end of file
19 model = Pattern
20 readonly_fields = ['date_create', 'date_modified', 'hits']
No newline at end of file
21
No newline at end of file
22 fieldsets = [
No newline at end of file
23 (None, {'fields': ['value']}),
No newline at end of file
24 ('Date information', {'fields': [('date_create', 'date_modified')], 'classes': ['collapse']}),
No newline at end of file
25 ('State', {'fields': ['hits', 'state'], 'classes': ['collapse', 'wide', 'extrapretty']}),
No newline at end of file
26 ] No newline at end of file
20 extra = 0 No newline at end of file
27 extra = 0
21 No newline at end of file
28
22 class ProfileAdmin(admin.ModelAdmin): No newline at end of file
29 class ProfileAdmin(admin.ModelAdmin):
30 readonly_fields = ['date_create', 'date_modified','hits'] No newline at end of file
23 fieldsets = [ No newline at end of file
31 fieldsets = [
24 (None, {'fields': ['name']}),
32 (None, {'fields': ['name']}),
No newline at end of file
33 ('Date information', {'fields': [('date_create', 'date_modified')], 'classes': ['collapse']}),
25 ('Date information', {'fields': ['date_create', 'date_modified'], 'classes': ['collapse']}), No newline at end of file
No newline at end of file
34 ('State', {'fields': ['hits', 'state'], 'classes': ['collapse']}), No newline at end of file
26 ] No newline at end of file
35 ]
27 inlines = [PatternInline] No newline at end of file
36 inlines = [PatternInline]
28 No newline at end of file
37
29 No newline at end of file
38
30 admin.site.register(Profile, ProfileAdmin)
39 admin.site.register(Profile, ProfileAdmin)
No newline at end of file
40 #admin.site.register(Pattern, PatternAdmin)
31 admin.site.register(Pattern, PatternAdmin)
No newline at end of file
No newline at end of file
41 #admin.site.register(AntennaUp)
32 admin.site.register(AntennaUp)
No newline at end of file
No newline at end of file
42 #admin.site.register(AntennaDown) No newline at end of file
33 admin.site.register(AntennaDown) No newline at end of file
@@ -14,4 +14,6
14 url(r'^(?P<profile_id>\d+)/delete/(?P<pattern_id>\d+)/$', 'deletePattern'), No newline at end of file
14 url(r'^(?P<profile_id>\d+)/delete/(?P<pattern_id>\d+)/$', 'deletePattern'),
15 #url(r'^(?P<poll_id>\d+)/results/$', 'results'), No newline at end of file
15 #url(r'^(?P<poll_id>\d+)/results/$', 'results'),
16 #url(r'^(?P<poll_id>\d+)/vote/$', 'vote'), No newline at end of file
16 #url(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
17 url(r'^import/$', 'importProfile'),
No newline at end of file
18 url(r'^saveImport/$', 'saveImport'), No newline at end of file
17 ) No newline at end of file
19 )
@@ -235,3 +235,27
235 newurl = '/abscontrol/edit/%d' % int(profile_id) No newline at end of file
235 newurl = '/abscontrol/edit/%d' % int(profile_id)
236 No newline at end of file
236
237 return redirect(newurl) No newline at end of file
237 return redirect(newurl)
238
No newline at end of file
239 def importProfile(request):
No newline at end of file
240
No newline at end of file
241 return render_to_response('abscontrol/import.html', { })
No newline at end of file
242
No newline at end of file
243 def saveImport(request):
No newline at end of file
244 if request.method == 'POST':
No newline at end of file
245 txtFilename = request.FILES['txtFile']
No newline at end of file
246 if txtFilename:
No newline at end of file
247 destination = open('/tmp/'+txtFilename.name, 'wb+')
No newline at end of file
248 for chunk in txtFilename.chunks():
No newline at end of file
249 destination.write(chunk)
No newline at end of file
250 destination.close()
No newline at end of file
251 f = open('/tmp/'+txtFilename.name, 'r')
No newline at end of file
252 content = f.read()
No newline at end of file
253 #for line in f:
No newline at end of file
254 # lsLine = line.readline()
No newline at end of file
255 f.close()
No newline at end of file
256 #content = lsLine
No newline at end of file
257 else:
No newline at end of file
258 txtFilename = "Error"
No newline at end of file
259 content = "Error"
No newline at end of file
260 return render_to_response('abscontrol/upload.html', {'txtFilename': txtFilename, 'content' : content})
No newline at end of file
261 No newline at end of file
@@ -42,7 +42,7
42 <li><a href="#">Save</a></li> No newline at end of file
42 <li><a href="#">Save</a></li>
43 {% endif %} No newline at end of file
43 {% endif %}
44 <li><a href="#">Save as</a></li>
44 <li><a href="#">Save as</a></li>
No newline at end of file
45 <li><a href="/abscontrol/import">Import</a></li> No newline at end of file
45 <li><a href="#">Import</a></li> No newline at end of file
46 <li><a href="#">Export</a></li> No newline at end of file
46 <li><a href="#">Export</a></li>
47 <li><a href="#">Apply</a></li> No newline at end of file
47 <li><a href="#">Apply</a></li>
48 </ul> No newline at end of file
48 </ul>
General Comments 0
You need to be logged in to leave comments. Login now