Skip to content
Snippets Groups Projects
Commit e110dc07 authored by Brody Wilton's avatar Brody Wilton Committed by Brody Wilton
Browse files

Implement basic version of report generation

parent f023f4f1
No related branches found
No related tags found
1 merge request!16update requirements txt to include library for pdf creation, comment out...
...@@ -29,4 +29,6 @@ urlpatterns = [ ...@@ -29,4 +29,6 @@ urlpatterns = [
path('uploading_file/', handling_music_file, name='uploading_file'), path('uploading_file/', handling_music_file, name='uploading_file'),
, ,
path('generate_pdf/', generate_pdf, name='generate_pdf') path('generate_pdf/', generate_pdf, name='generate_pdf')
path('pricing/', pricing, name='pricing'),
path('generate_pdf/', generate_pdf, name='generate_pdf')
] ]
...@@ -34,6 +34,9 @@ def handling_music_file(request): ...@@ -34,6 +34,9 @@ def handling_music_file(request):
log_data = get_log_data(Action.invalid_file, 'error') log_data = get_log_data(Action.invalid_file, 'error')
# create_log(None, log_data) # create_log(None, log_data)
return HttpResponse('File invalid',log_data) return HttpResponse('File invalid',log_data)
from .models import User
from django.http import HttpResponse
from reportlab.pdfgen import canvas
def index(request): def index(request):
#for now this authenication just returns the main view #for now this authenication just returns the main view
...@@ -92,3 +95,16 @@ def generate_pdf(request): ...@@ -92,3 +95,16 @@ def generate_pdf(request):
p.save() p.save()
return response return response
#For testing the receipts ONLY. TODO: delete when working
def generate_pdf(request):
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="example.pdf"'
p = canvas.Canvas(response)
p.drawString(100, 800, "Hello, this is a PDF!")
p.showPage()
p.save()
return response
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment