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",
|
||||
"bird",
|
||||
"costs",
|
||||
"export",
|
||||
"rescuer",
|
||||
"sites",
|
||||
]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import csv
|
||||
|
||||
from costs.models import Costs
|
||||
from bird.models import FallenBird
|
||||
from costs.models import Costs
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
@ -9,20 +9,14 @@ from django.shortcuts import render
|
|||
|
||||
@login_required(login_url="account_login")
|
||||
def site_exports(request):
|
||||
return render(
|
||||
request,
|
||||
"export/export_site.html",
|
||||
)
|
||||
return render(request, "export/overview.html")
|
||||
|
||||
|
||||
@login_required(login_url="account_login")
|
||||
def export_costs(request):
|
||||
costs = Costs.objects.all().values_list(
|
||||
"id_bird__bird_identifier",
|
||||
"costs",
|
||||
"created",
|
||||
"comment",
|
||||
"user__username")
|
||||
"id_bird__bird_identifier", "costs", "created", "comment", "user__username"
|
||||
)
|
||||
response = HttpResponse(content_type="text/csv")
|
||||
response["Content-Disposition"] = "attachment, filename=fbf_costs.csv"
|
||||
writer = csv.writer(response)
|
||||
|
@ -51,12 +45,14 @@ def export_birds(request):
|
|||
"user__username",
|
||||
"status__description",
|
||||
"aviary__description",
|
||||
"sent_to"
|
||||
"sent_to",
|
||||
)
|
||||
response = HttpResponse(content_type="text/csv")
|
||||
response["Content-Disposition"] = "attachment, filename=fbf_birds.csv"
|
||||
writer = csv.writer(response)
|
||||
writer.writerow(["Vogel",
|
||||
writer.writerow(
|
||||
[
|
||||
"Vogel",
|
||||
"Patienten Alias",
|
||||
"Alter",
|
||||
"Geschlecht",
|
||||
|
@ -70,8 +66,9 @@ def export_birds(request):
|
|||
"Benutzer",
|
||||
"Status",
|
||||
"Voliere",
|
||||
"Übersandt"
|
||||
])
|
||||
"Übersandt",
|
||||
]
|
||||
)
|
||||
for bird in birds:
|
||||
writer.writerow(bird)
|
||||
return response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue