From 0a66905b1c399840d82f3f59d2c0cacb6c30595e Mon Sep 17 00:00:00 2001 From: Maciej Pienczyn Date: Tue, 7 Apr 2026 08:27:04 +0200 Subject: [PATCH] fix(workflow): test mode emails to maciej.pienczyn@inpi.pl, fix Polish chars Email notifications limited to test address during development. Fixed missing Polish characters in notification titles and body. Commented out production email loop (TODO marker for re-enable). Co-Authored-By: Claude Opus 4.6 (1M context) --- services/admission_workflow.py | 62 +++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/services/admission_workflow.py b/services/admission_workflow.py index ab95653..3cde54e 100644 --- a/services/admission_workflow.py +++ b/services/admission_workflow.py @@ -322,11 +322,11 @@ def notify_office_managers(db, meeting, results: dict) -> tuple: meeting_id_str = f"{meeting.meeting_number}/{meeting.year}" action_url = f"/rada/posiedzenia/{meeting.id}/przyjecia" - title = f"Rada {meeting_id_str} -- nowi czlonkowie" + title = f"Rada {meeting_id_str} — nowi członkowie" if needs_attention > 0: - message = f"Przyjeto {total} firm. {needs_attention} wymaga uzupelnienia profilu." + message = f"Przyjęto {total} firm. {needs_attention} wymaga uzupełnienia profilu." else: - message = f"Przyjeto {total} firm. Wszystkie profile sa juz uzupelnione." + message = f"Przyjęto {total} firm. Wszystkie profile są już uzupełnione." for manager in managers: try: @@ -351,9 +351,9 @@ def notify_office_managers(db, meeting, results: dict) -> tuple: # Build HTML table rows = [] for m in results.get('matched', []): - rows.append(f"{m['matched_name']}Profil istnieje") + rows.append(f"{m['matched_name']}✓ Profil istnieje") for c in results.get('created', []): - rows.append(f"{c['name']}Wymaga uzupelnienia") + rows.append(f"{c['name']}⏳ Wymaga uzupełnienia") table_html = f""" @@ -364,28 +364,44 @@ def notify_office_managers(db, meeting, results: dict) -> tuple: body_html = f"""

Na posiedzeniu Rady {meeting_id_str} ({meeting.meeting_date.strftime('%d.%m.%Y')}) - przyjeto {total} nowych czlonkow.

+ przyjęto {total} nowych członków.

{table_html} - {'

Uwaga: ' + str(needs_attention) + ' firm wymaga uzupelnienia profilu na portalu.

' if needs_attention else ''} -

Przejdz do dashboardu przyjec

+ {'

Uwaga: ' + str(needs_attention) + ' firm wymaga uzupełnienia profilu na portalu.

' if needs_attention else ''} +

Przejdź do dashboardu przyjęć

""" - body_text = f"Na posiedzeniu Rady {meeting_id_str} przyjeto {total} nowych czlonkow. {needs_attention} wymaga uzupelnienia profilu." + body_text = f"Na posiedzeniu Rady {meeting_id_str} przyjęto {total} nowych członków. {needs_attention} wymaga uzupełnienia profilu." - for manager in managers: - if manager.email: - try: - send_email( - to=manager.email, - subject=f"[NordaBiz] Rada {meeting_id_str} -- przyjeto {total} nowych czlonkow", - body_text=body_text, - body_html=body_html, - email_type='system', - recipient_name=manager.name - ) - email_count += 1 - except Exception as e: - logger.error(f"Failed to email {manager.email}: {e}") + # TEST MODE: send only to maciej.pienczyn@inpi.pl during testing + test_email = 'maciej.pienczyn@inpi.pl' + try: + send_email( + to=test_email, + subject=f"[NordaBiz] Rada {meeting_id_str} — przyjęto {total} nowych członków", + body_text=body_text, + body_html=body_html, + email_type='system', + recipient_name='Maciej Pienczyn' + ) + email_count = 1 + except Exception as e: + logger.error(f"Failed to send test email: {e}") + + # TODO: Po zakończeniu testów — odkomentować pętlę poniżej i usunąć test_email + # for manager in managers: + # if manager.email: + # try: + # send_email( + # to=manager.email, + # subject=f"[NordaBiz] Rada {meeting_id_str} — przyjęto {total} nowych członków", + # body_text=body_text, + # body_html=body_html, + # email_type='system', + # recipient_name=manager.name + # ) + # email_count += 1 + # except Exception as e: + # logger.error(f"Failed to email {manager.email}: {e}") except Exception as e: logger.error(f"Failed to send admission emails: {e}")