Files
erp-efintel-2026-portainer/fix_expense_form.py
T
2026-09-07 18:44:32 -03:00

13 lines
726 B
Python

import re
with open('templates/expenses/expense_form.html', 'r', encoding='utf-8') as f:
content = f.read()
# 1. Add x-data to the form
content = content.replace('<form method="post" enctype="multipart/form-data">', '<form method="post" enctype="multipart/form-data" x-data="expenseForm()">')
# 2. Add x-model to is_reimbursement and x-show to responsible person
# Search for {{ form.is_reimbursement }}
content = content.replace('{{ form.is_reimbursement }}', '{{ form.is_reimbursement }}')
# Wait, I can just inject AlpineJS attributes using django-widget-tweaks or by replacing the input html, but since it's rendered via {{ form.xxx }}, I need to modify `forms.py` to add `x-model` or wrap them in Alpine elements.