Skip to content
Snippets Groups Projects

Resolve "Export to Excel"

Merged Piotr Gawron requested to merge 131-export-to-excel into master
13 files
+ 134
49
Compare changes
  • Side-by-side
  • Inline
Files
13
import traceback
from datetime import datetime
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse
from django.urls import reverse
from django.utils import timezone
from web.models import Appointment
from web.views import e500_error
@@ -29,9 +31,11 @@ def get_appointments(request, type, min_date, max_date):
raise TypeError("Unknown query type: " + type)
if min_date is not None:
min_date = datetime.strptime(min_date, "%Y-%m-%d").replace(tzinfo=timezone.now().tzinfo)
result = result.filter(datetime_when__gt=min_date)
if max_date is not None:
max_date = datetime.strptime(max_date, "%Y-%m-%d").replace(tzinfo=timezone.now().tzinfo)
result = result.filter(datetime_when__lt=max_date)
return result.order_by("datetime_when")
@@ -57,12 +61,12 @@ def appointments(request, type):
sliced_subjects = all_appointments[start:(start + length)]
appointments = sliced_subjects
result_appointments = sliced_subjects
count_filtered = all_appointments.count()
data = []
for appointment in appointments:
for appointment in result_appointments:
data.append(serialize_appointment(appointment))
return JsonResponse({
Loading