source: src/django_gheat/wlheatmap/__init__.py@ 11406

Last change on this file since 11406 was 9746, checked in by rick, 13 years ago
  • Cannot be placed in init as this will causes the CHOICES to load _before_

the database is created, leading to unknown table errors.

  • Added surveyid to upload field to allow selecting which meetrondje to use.
File size: 1.1 KB
RevLine 
[9544]1from django.shortcuts import render_to_response
[9660]2from django.http import HttpResponse,HttpResponseServerError
[9544]3from django.conf import settings
[9660]4from gheat.models import *
[9658]5from django.db import IntegrityError
[9544]6
[9658]7import gheat.dataimport
8import logging
9
10logger = logging.getLogger(__name__)
11logger.setLevel(logging.DEBUG)
12
[9544]13def js_layer_base(request):
14 return render_to_response('js/LayerBase.js', {'settings' : settings },
15 mimetype='application/javascript')
[9658]16
17def process(request):
18 response = HttpResponse()
19 ch = logging.StreamHandler(stream=response)
20 ch.setLevel(logging.DEBUG)
21 formatter = logging.Formatter('%(levelname)-6s - %(name)-20s - %(message)s')
22 ch.setFormatter(formatter)
23 logging.getLogger().addHandler(ch)
24
25 response.write('<pre>')
26 for f in MeetBestand.objects.filter(is_imported=False):
27 logger.info("%s | %s", f.bestand.name, f.meetrondje)
28 try:
29 gheat.dataimport.import_file(f.bestand.path, f.meetrondje)
30 except IntegrityError, e:
31 logger.error(e)
32 continue
33 f.is_imported = True
34 f.save()
35 response.write('</pre>')
36 return response
Note: See TracBrowser for help on using the repository browser.