diff --git a/order-events/app/events/billing/append_enrollment.py b/order-events/app/events/billing/append_enrollment.py index 81ca3d4..a355cd1 100644 --- a/order-events/app/events/billing/append_enrollment.py +++ b/order-events/app/events/billing/append_enrollment.py @@ -96,7 +96,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool: pass try: - author = data['author'] + author = data.get('author') course_id = data['course']['id'] course = course_layer.collection.get_items( KeyPair( @@ -118,15 +118,21 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool: 'user': pick(('id', 'name'), data['user']), 'course': pick(('id', 'name'), data['course']), 'unit_price': course['unit_price'], - 'author': { - 'id': author['user_id'], - 'name': author['name'], - }, # Post-migration: uncomment the following line # 'enrolled_at': data['created_at'], 'enrolled_at': data['create_date'], 'created_at': now_, - }, + } + | ( + { + 'author': { + 'id': author['user_id'], + 'name': author['name'], + } + } + if author + else {} + ), cond_expr='attribute_not_exists(sk)', ) except Exception as exc: diff --git a/order-events/app/events/billing/template.html b/order-events/app/events/billing/template.html index 9fc1adb..43d30df 100644 --- a/order-events/app/events/billing/template.html +++ b/order-events/app/events/billing/template.html @@ -83,8 +83,8 @@ margin-bottom: 0.625rem; } - .text-nowrap { - text-wrap: nowrap; + .whitespace-nowrap { + white-space: nowrap; } @@ -177,9 +177,9 @@ Colaborador Curso - Matriculado em + Matriculado em Autor - Valor unit. + Valor unit. @@ -187,12 +187,14 @@ {{ x.user.name }} {{ x.course.name }} - + {{ x.enrolled_at|datetime_format('%d/%m/%Y, %H:%M') }} - {{ x.author.name }} - {{ x.unit_price|currency }} + {{ x.author.name if x.author else 'N/A' }} + + {{ x.unit_price|currency }} + {% endfor %} @@ -204,7 +206,7 @@ > Total - + {{ items| map(attribute='unit_price')|map('float')|sum|currency }}