def run_import_file(): tr = Trace() tr.user = User.objects.get(id=1) tr.name = 'test_import' tr.ctime = datetime.now() tr.save() tr.create_from_file('c:/benoit/django/serpentine/media/' + 'import.gpx')
def modify(request): if request.method == 'POST': track = request.POST['track'] tr = Trace() tr.name = 'modified' tr.user = User.objects.get(username=request.user.username) tr.ctime = datetime.datetime.now() tr.save() points = json.loads(track) tr.create_from_array(points) return HttpResponseRedirect('/trace/' + unicode(tr.id) + '/') else: return HttpResponseRedirect('/trace/1')
def handle_uploaded_file(f): destination = open(settings.MEDIA_ROOT + 'import.gpx', 'w') for chunk in f.chunks(): destination.write(chunk) destination.close() # on enregistre un minimum sur l'entête de trace pour pouvoir enregistrer les points tr = Trace() tr.user = User.objects.get(username=request.user.username) tr.name = f.name tr.ctime = datetime.datetime.now() tr.save() tr.create_from_file(settings.MEDIA_ROOT + 'import.gpx') return tr