Export overview
This commit is contained in:
parent
caa16cc260
commit
0fcec94275
3 changed files with 26 additions and 28 deletions
|
@ -73,6 +73,7 @@ INSTALLED_APPS = [
|
||||||
"aviary",
|
"aviary",
|
||||||
"bird",
|
"bird",
|
||||||
"costs",
|
"costs",
|
||||||
|
"export",
|
||||||
"rescuer",
|
"rescuer",
|
||||||
"sites",
|
"sites",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
from costs.models import Costs
|
|
||||||
from bird.models import FallenBird
|
from bird.models import FallenBird
|
||||||
|
from costs.models import Costs
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
@ -9,20 +9,14 @@ from django.shortcuts import render
|
||||||
|
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def site_exports(request):
|
def site_exports(request):
|
||||||
return render(
|
return render(request, "export/overview.html")
|
||||||
request,
|
|
||||||
"export/export_site.html",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def export_costs(request):
|
def export_costs(request):
|
||||||
costs = Costs.objects.all().values_list(
|
costs = Costs.objects.all().values_list(
|
||||||
"id_bird__bird_identifier",
|
"id_bird__bird_identifier", "costs", "created", "comment", "user__username"
|
||||||
"costs",
|
)
|
||||||
"created",
|
|
||||||
"comment",
|
|
||||||
"user__username")
|
|
||||||
response = HttpResponse(content_type="text/csv")
|
response = HttpResponse(content_type="text/csv")
|
||||||
response["Content-Disposition"] = "attachment, filename=fbf_costs.csv"
|
response["Content-Disposition"] = "attachment, filename=fbf_costs.csv"
|
||||||
writer = csv.writer(response)
|
writer = csv.writer(response)
|
||||||
|
@ -51,27 +45,30 @@ def export_birds(request):
|
||||||
"user__username",
|
"user__username",
|
||||||
"status__description",
|
"status__description",
|
||||||
"aviary__description",
|
"aviary__description",
|
||||||
"sent_to"
|
"sent_to",
|
||||||
)
|
)
|
||||||
response = HttpResponse(content_type="text/csv")
|
response = HttpResponse(content_type="text/csv")
|
||||||
response["Content-Disposition"] = "attachment, filename=fbf_birds.csv"
|
response["Content-Disposition"] = "attachment, filename=fbf_birds.csv"
|
||||||
writer = csv.writer(response)
|
writer = csv.writer(response)
|
||||||
writer.writerow(["Vogel",
|
writer.writerow(
|
||||||
"Patienten Alias",
|
[
|
||||||
"Alter",
|
"Vogel",
|
||||||
"Geschlecht",
|
"Patienten Alias",
|
||||||
"gefunden am",
|
"Alter",
|
||||||
"Fundort",
|
"Geschlecht",
|
||||||
"Pateient angelegt am",
|
"gefunden am",
|
||||||
"Pateient aktualisiert am",
|
"Fundort",
|
||||||
"Fundumstände",
|
"Pateient angelegt am",
|
||||||
"Diagnose bei Fund",
|
"Pateient aktualisiert am",
|
||||||
"Finder (Nachname)",
|
"Fundumstände",
|
||||||
"Benutzer",
|
"Diagnose bei Fund",
|
||||||
"Status",
|
"Finder (Nachname)",
|
||||||
"Voliere",
|
"Benutzer",
|
||||||
"Übersandt"
|
"Status",
|
||||||
])
|
"Voliere",
|
||||||
|
"Übersandt",
|
||||||
|
]
|
||||||
|
)
|
||||||
for bird in birds:
|
for bird in birds:
|
||||||
writer.writerow(bird)
|
writer.writerow(bird)
|
||||||
return response
|
return response
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue