12
12
from reportlab .lib .enums import TA_CENTER
13
13
from reportlab .lib .pagesizes import A4
14
14
from reportlab .lib .styles import getSampleStyleSheet , ParagraphStyle
15
+ from reportlab .lib .units import inch
15
16
from reportlab .pdfbase import pdfmetrics
16
17
from reportlab .pdfbase .ttfonts import TTFont
17
18
from reportlab .platypus import NextPageTemplate , Paragraph , Table , TableStyle
@@ -332,7 +333,8 @@ def generate_report(
332
333
333
334
data , styles = self ._get_table_data_and_styles (data , normal_style , subheading_style )
334
335
table_data .extend (data )
335
- table = Table (table_data )
336
+ max_column_width = 4 * inch
337
+ table = Table (table_data , colWidths = [None , max_column_width ])
336
338
table .setStyle (
337
339
TableStyle (
338
340
[
@@ -343,6 +345,7 @@ def generate_report(
343
345
("ALIGN" , (0 , 0 ), (- 1 , - 1 ), "LEFT" ),
344
346
("FONTNAME" , (0 , 2 ), (- 1 , - 1 ), "BCSans" ),
345
347
("FONTNAME" , (0 , 0 ), (- 1 , 1 ), "BCSans-Bold" ),
348
+ ("WORDWRAP" , (0 , 0 ), (- 1 , - 1 )),
346
349
]
347
350
+ styles
348
351
)
@@ -422,52 +425,62 @@ def _get_valid_event_ids(self, start_date, end_date):
422
425
.join (EventConfiguration , Event .event_configuration )
423
426
.join (Work , Event .work )
424
427
.filter (
425
- func .coalesce (Event .actual_date , Event .anticipated_date ).between (
426
- start_date .date (), end_date .date ()
427
- ),
428
428
or_ (
429
- Event .event_configuration_id .in_ (self .decision_configuration_ids ), # Decision events
430
- and_ ( # High profile work with pcp
431
- Work .is_high_priority .is_ (True ),
432
- EventConfiguration .event_category_id == EventCategoryEnum .PCP .value ,
433
- EventConfiguration .event_type_id == EventTypeEnum .COMMENT_PERIOD .value
434
- ),
435
- and_ ( # High profile events
436
- Work .is_high_priority .is_ (True ),
437
- Event .high_priority .is_ (True ),
438
- EventConfiguration .event_category_id .not_in ([EventCategoryEnum .CALENDAR .value , EventCategoryEnum .FINANCE .value ])
439
- ),
440
- and_ (
441
- Work .work_type_id == 1 , # Project Notification
442
- EventConfiguration .event_category_id == EventCategoryEnum .MILESTONE .value ,
443
- EventConfiguration .event_type_id == EventTypeEnum .REFERRAL .value ,
444
- EventConfiguration .name == "Project Notification Report referred to Decision Maker" ,
445
- ),
446
- and_ (
447
- Work .work_type_id == 2 , # Minister's Designation
448
- EventConfiguration .event_category_id == EventCategoryEnum .MILESTONE .value ,
449
- EventConfiguration .event_type_id == EventTypeEnum .REFERRAL .value ,
450
- EventConfiguration .name != "Minister's Designation Report referred to Decision Maker" ,
451
- ),
452
429
and_ (
453
- Work . work_type_id == 5 , # Exemption Order
454
- EventConfiguration .event_category_id == EventCategoryEnum . MILESTONE .value ,
455
- EventConfiguration . event_type_id == EventTypeEnum . REFERRAL . value ,
456
- EventConfiguration . name != "Exemption Request Package Referred to Minister" ,
430
+ # Keep Minister's decision with no actual date if anticipated date indicates it should have been made
431
+ EventConfiguration .event_type_id == EventTypeEnum . MINISTER_DECISION .value ,
432
+ Event . actual_date . is_ ( None ) ,
433
+ Event . anticipated_date < start_date . date ()
457
434
),
458
435
and_ (
459
- Work .work_type_id == 6 , # Assessment
460
- EventConfiguration .event_category_id == EventCategoryEnum .MILESTONE .value ,
461
- EventConfiguration .event_type_id == EventTypeEnum .REFERRAL .value ,
462
- EventConfiguration .name .in_ (["EAC Referral Package sent to Ministers" , "Termination Package Referred to Minister" ])
463
- ),
464
- and_ (
465
- Work .work_type_id == 7 , # Ammendment
466
- EventConfiguration .event_category_id == EventCategoryEnum .MILESTONE .value ,
467
- EventConfiguration .event_type_id == EventTypeEnum .REFERRAL .value ,
468
- EventConfiguration .name == "Amendment Decision Package Referred to Decision Maker"
469
- ),
470
- ),
436
+ func .coalesce (Event .actual_date , Event .anticipated_date ).between (
437
+ start_date .date (), end_date .date ()
438
+ ),
439
+ or_ (
440
+ Event .event_configuration_id .in_ (self .decision_configuration_ids ), # Decision events
441
+ and_ ( # High profile work with pcp
442
+ Work .is_high_priority .is_ (True ),
443
+ EventConfiguration .event_category_id == EventCategoryEnum .PCP .value ,
444
+ EventConfiguration .event_type_id == EventTypeEnum .COMMENT_PERIOD .value
445
+ ),
446
+ and_ ( # High profile events
447
+ Work .is_high_priority .is_ (True ),
448
+ Event .high_priority .is_ (True ),
449
+ EventConfiguration .event_category_id .not_in ([EventCategoryEnum .CALENDAR .value , EventCategoryEnum .FINANCE .value ])
450
+ ),
451
+ and_ (
452
+ Work .work_type_id == 1 , # Project Notification
453
+ EventConfiguration .event_category_id == EventCategoryEnum .MILESTONE .value ,
454
+ EventConfiguration .event_type_id == EventTypeEnum .REFERRAL .value ,
455
+ EventConfiguration .name == "Project Notification Report referred to Decision Maker" ,
456
+ ),
457
+ and_ (
458
+ Work .work_type_id == 2 , # Minister's Designation
459
+ EventConfiguration .event_category_id == EventCategoryEnum .MILESTONE .value ,
460
+ EventConfiguration .event_type_id == EventTypeEnum .REFERRAL .value ,
461
+ EventConfiguration .name != "Minister's Designation Report referred to Decision Maker" ,
462
+ ),
463
+ and_ (
464
+ Work .work_type_id == 5 , # Exemption Order
465
+ EventConfiguration .event_category_id == EventCategoryEnum .MILESTONE .value ,
466
+ EventConfiguration .event_type_id == EventTypeEnum .REFERRAL .value ,
467
+ EventConfiguration .name != "Exemption Request Package Referred to Minister" ,
468
+ ),
469
+ and_ (
470
+ Work .work_type_id == 6 , # Assessment
471
+ EventConfiguration .event_category_id == EventCategoryEnum .MILESTONE .value ,
472
+ EventConfiguration .event_type_id == EventTypeEnum .REFERRAL .value ,
473
+ EventConfiguration .name .in_ (["EAC Referral Package sent to Ministers" , "Termination Package Referred to Minister" ])
474
+ ),
475
+ and_ (
476
+ Work .work_type_id == 7 , # Ammendment
477
+ EventConfiguration .event_category_id == EventCategoryEnum .MILESTONE .value ,
478
+ EventConfiguration .event_type_id == EventTypeEnum .REFERRAL .value ,
479
+ EventConfiguration .name == "Amendment Decision Package Referred to Decision Maker"
480
+ ),
481
+ ),
482
+ )
483
+ )
471
484
)
472
485
)
473
486
return valid_events
0 commit comments