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

Last change on this file since 9779 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
Line 
1from django.shortcuts import render_to_response
2from django.http import HttpResponse,HttpResponseServerError
3from django.conf import settings
4from gheat.models import *
5from django.db import IntegrityError
6
7import gheat.dataimport
8import logging
9
10logger = logging.getLogger(__name__)
11logger.setLevel(logging.DEBUG)
12
13def js_layer_base(request):
14 return render_to_response('js/LayerBase.js', {'settings' : settings },
15 mimetype='application/javascript')
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.