diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2018-11-09 11:10:03 -0500 |
---|---|---|
committer | Parker Berberian <pberberian@iol.unh.edu> | 2019-01-02 09:35:41 -0500 |
commit | 28a35133ff325aab59204df7372d7cc78ca5e64c (patch) | |
tree | ba0c13f7ed0e7fc5559075e6444b9af7c5de0edc /dashboard/src/booking | |
parent | b02aa2535c7b7beacbc2d7d24d8522fa596afeee (diff) |
Renders Pod Destriptor File earlier
Currently, the PDF is rendered 'on-demand' every time you
visit the booking detail page. This change renders the pdf once
and saves it in the booking model. Advantages:
- saves computation of re-rendering pdf constantly
- fixes issue where pdf fails to render after booking expires
Change-Id: I58d20fadce088d78ebd22f1d6f67cab371823542
Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'dashboard/src/booking')
-rw-r--r-- | dashboard/src/booking/migrations/0002_booking_pdf.py | 18 | ||||
-rw-r--r-- | dashboard/src/booking/models.py | 1 | ||||
-rw-r--r-- | dashboard/src/booking/views.py | 2 |
3 files changed, 20 insertions, 1 deletions
diff --git a/dashboard/src/booking/migrations/0002_booking_pdf.py b/dashboard/src/booking/migrations/0002_booking_pdf.py new file mode 100644 index 0000000..53232c9 --- /dev/null +++ b/dashboard/src/booking/migrations/0002_booking_pdf.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1 on 2018-11-09 16:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('booking', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='booking', + name='pdf', + field=models.TextField(blank=True, default=''), + ), + ] diff --git a/dashboard/src/booking/models.py b/dashboard/src/booking/models.py index d0c77b4..74b766d 100644 --- a/dashboard/src/booking/models.py +++ b/dashboard/src/booking/models.py @@ -57,6 +57,7 @@ class Booking(models.Model): config_bundle = models.ForeignKey(ConfigBundle, on_delete=models.SET_NULL, null=True) project = models.CharField(max_length=100, default="", blank=True, null=True) lab = models.ForeignKey(Lab, null=True, on_delete=models.SET_NULL) + pdf = models.TextField(blank=True, default="") class Meta: db_table = 'booking' diff --git a/dashboard/src/booking/views.py b/dashboard/src/booking/views.py index ab43519..29b53e2 100644 --- a/dashboard/src/booking/views.py +++ b/dashboard/src/booking/views.py @@ -112,7 +112,7 @@ def booking_detail_view(request, booking_id): { 'title': 'Booking Details', 'booking': booking, - 'pdf': ResourceManager().makePDF(booking.resource), + 'pdf': booking.pdf, 'user_id': user.id }) |