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