37769-vm/patch_template_view_signs.py
2026-05-30 08:01:02 +00:00

26 lines
1.6 KiB
Python

import sys
file_path = 'core/templates/core/view_signs.html'
with open(file_path, 'r') as f:
content = f.read()
header_old = '<th class="py-3 text-uppercase small ls-1">Voters with Sign</th>'
header_new = header_old + '\n <th class="py-3 text-uppercase small ls-1">Sign Type</th>'
content = content.replace(header_old, header_new)
cell_old = '</a>\n {% endfor %}\n </div>\n </td>'
cell_new = cell_old + '\n <td>\n <span class="badge {% if "Large Sign" in household.sign_types_display %}bg-primary{% else %}bg-success{% endif %} rounded-pill px-3">
{{ household.sign_types_display }}
</span>\n </td>'
content = content.replace(cell_old, cell_new)
icon_old = "icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png'"
icon_new = "icon: item.is_large ? 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png' : 'http://maps.google.com/mapfiles/ms/icons/green-dot.png'"
content = content.replace(icon_old, icon_new)
info_old = "votersCount.textContent = 'Voters: ' + item.voters;"
info_new = info_old + "\n \n var typeDiv = document.createElement('div');\n typeDiv.className = 'mb-2 small fw-bold';\n typeDiv.textContent = 'Type: ' + (item.is_large ? 'Large Sign' : 'Yard Sign');\n container.appendChild(typeDiv);"
content = content.replace(info_old, info_new)
with open(file_path, 'w') as f:
f.write(content)