Changeset 9746
- Timestamp:
- Dec 3, 2011, 10:58:19 AM (13 years ago)
- Location:
- src/django_gheat/wlheatmap
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/wlheatmap/__init__.py
r9674 r9746 35 35 response.write('</pre>') 36 36 return response 37 38 from django import forms39 from django.core.files.base import ContentFile40 41 def get_apperatuur_choices(item):42 return sorted(set(Apparatuur.objects.values_list(item,item)))43 44 class MeetBestandForm(forms.Form):45 naam = forms.ChoiceField(choices=Gebruiker.objects.values_list('naam','naam'))46 kaart = forms.ChoiceField(choices=get_apperatuur_choices('kaart'))47 antenne = forms.ChoiceField(choices=get_apperatuur_choices('antenne'))48 bestand = forms.FileField()49 50 #51 # curl -F naam=huub -F kaart=onbekend -F antenne=onbekend -F bestand=@manage.py http://localhost:8000/wlheatp/add/meetbestand/52 def add_meetbestand(request):53 if request.method == 'POST':54 form = MeetBestandForm(request.POST, request.FILES)55 if form.is_valid():56 gebruiker = Gebruiker.objects.get(naam=form.cleaned_data['naam'])57 apparatuur, created = Apparatuur.objects.get_or_create(kaart=form.cleaned_data['kaart'],58 antenne=form.cleaned_data['antenne'])59 meetrondje, created = MeetRondje.objects.get_or_create(gebruiker=gebruiker,60 datum=None,61 naam=(form.cleaned_data['bestand']),62 apparatuur=apparatuur)63 64 meetbestand, created = MeetBestand.objects.get_or_create(meetrondje=meetrondje,is_imported=False)65 if created:66 meetbestand.bestand.save(form.cleaned_data['bestand'].name,form.cleaned_data['bestand'])67 meetbestand.save()68 return HttpResponse('OK')69 else:70 return HttpResponseServerError('ERROR File does already exists')71 else:72 return HttpResponseServerError('ERROR No valid input')73 else:74 form = MeetBestandForm()75 return render_to_response('add_file.html', {'form': form}) -
src/django_gheat/wlheatmap/urls.py
r9660 r9746 1 1 from django.conf.urls.defaults import * 2 2 from django.views.generic.simple import direct_to_template 3 #from django.views.generic.base import TemplateView4 3 from django.conf import settings 5 4 6 #class HomeView(TemplateView):7 # template_name = 'home.html'8 #9 #urlpatterns = patterns('',10 # ('^$', HomeView.as_view())11 #)12 5 13 6 urlpatterns = patterns('wlheatmap', … … 20 13 url(r'^filters/$', 'filters.serve_filters'), 21 14 url(r'^process/$', 'process'), 22 url(r'^add/meetbestand/$', ' add_meetbestand'),15 url(r'^add/meetbestand/$', 'forms.add_meetbestand'), 23 16 )
Note:
See TracChangeset
for help on using the changeset viewer.