
import sys

with open('core/templates/core/voter_detail.html', 'r') as f:
    content = f.read()

old_thead = '''                                    <tr>
                                        <th class="ps-4">Date</th>
                                        <th>Event Type</th>
                                        <th>Status</th>
                                        <th>Description</th>
                                        <th class="pe-4 text-end">Actions</th>
                                    </tr>'''
new_thead = '''                                    <tr>
                                        <th class="ps-4">Date</th>
                                        <th>Event Name</th>
                                        <th>Event Type</th>
                                        <th>Status</th>
                                        <th>Description</th>
                                        <th class="pe-4 text-end">Actions</th>
                                    </tr>'''

if old_thead in content:
    content = content.replace(old_thead, new_thead)
else:
    print("Warning: old_thead not found")

old_tbody = '''                                    {% for participation in event_participations %}
                                    <tr>
                                        <td class="ps-4 text-nowrap">{{ participation.event.date|date:"M d, Y" }}</td>
                                        <td><span class="badge bg-light text-dark border">{{ participation.event.event_type.name }}</span></td>'''
new_tbody = '''                                    {% for participation in event_participations %}
                                    <tr>
                                        <td class="ps-4 text-nowrap">{{ participation.event.date|date:"M d, Y" }}</td>
                                        <td><strong>{{ participation.event.name|default:"(No Name)" }}</strong></td>
                                        <td><span class="badge bg-light text-dark border">{{ participation.event.event_type.name }}</span></td>'''

if old_tbody in content:
    content = content.replace(old_tbody, new_tbody)
else:
    print("Warning: old_tbody not found")

with open('core/templates/core/voter_detail.html', 'w') as f:
    f.write(content)
