Changeset 9660 for src/django_gheat
- Timestamp:
- Sep 4, 2011, 6:14:03 PM (13 years ago)
- Location:
- src/django_gheat
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/models.py
r9659 r9660 157 157 class MeetBestand(models.Model): 158 158 meetrondje = models.ForeignKey(MeetRondje) 159 bestand = models.FileField(upload_to='scan-data/%Y/%m/%d' ,storage=OverwriteStorage())159 bestand = models.FileField(upload_to='scan-data/%Y/%m/%d') 160 160 is_imported = models.BooleanField(default=False) 161 161 class Meta: 162 162 verbose_name_plural = 'MeetBestanden' 163 unique_together = ('meetrondje', 'bestand') 163 164 def __unicode__(self): 164 165 return "%s - %s" % (self.meetrondje, self.bestand) -
src/django_gheat/wlheatmap/__init__.py
r9658 r9660 1 1 from django.shortcuts import render_to_response 2 from django.http import HttpResponse 2 from django.http import HttpResponse,HttpResponseServerError 3 3 from django.conf import settings 4 from gheat.models import MeetBestand4 from gheat.models import * 5 5 from django.db import IntegrityError 6 6 … … 35 35 response.write('</pre>') 36 36 return response 37 38 from django import forms 39 from django.core.files.base import ContentFile 40 41 class MeetBestandForm(forms.Form): 42 naam = forms.ChoiceField(choices=Gebruiker.objects.values_list('naam','naam')) 43 kaart = forms.ChoiceField(choices=set(Apparatuur.objects.values_list('kaart','kaart'))) 44 antenne = forms.ChoiceField(choices=set(Apparatuur.objects.values_list('antenne','antenne'))) 45 bestand = forms.FileField() 46 47 def add_meetbestand(request): 48 if request.method == 'POST': 49 form = MeetBestandForm(request.POST, request.FILES) 50 if form.is_valid(): 51 gebruiker = Gebruiker.objects.get(naam=form.cleaned_data['naam']) 52 apparatuur, created = Apparatuur.objects.get_or_create(kaart=form.cleaned_data['kaart'], 53 antenne=form.cleaned_data['antenne']) 54 meetrondje, created = MeetRondje.objects.get_or_create(gebruiker=gebruiker, 55 datum=None, 56 naam=(form.cleaned_data['bestand']), 57 apparatuur=apparatuur) 58 59 meetbestand, created = MeetBestand.objects.get_or_create(meetrondje=meetrondje,is_imported=False) 60 if created: 61 meetbestand.bestand.save(form.cleaned_data['bestand'].name,form.cleaned_data['bestand']) 62 meetbestand.save() 63 return HttpResponse('OK') 64 else: 65 return HttpResponseServerError('ERROR File does already exists') 66 67 else: 68 form = MeetBestandForm() 69 return render_to_response('add_file.html', {'form': form}) -
src/django_gheat/wlheatmap/urls.py
r9658 r9660 20 20 url(r'^filters/$', 'filters.serve_filters'), 21 21 url(r'^process/$', 'process'), 22 url(r'^add/meetbestand/$', 'add_meetbestand'), 22 23 )
Note:
See TracChangeset
for help on using the changeset viewer.