#!/usr/bin/env python3 """ Move time tracking section from right column to left column with inline quick-add """ # Read the file with open('app/modules/sag/templates/detail.html', 'r', encoding='utf-8') as f: lines = f.readlines() # Find the insertion point in left column (before that closes left column around line 2665) # and the section to remove in right column (around lines 2813-2865) # First, find where to insert (before the that closes left column) insert_index = None for i, line in enumerate(lines): if i >= 2660 and i <= 2670: if '' in line and 'col-lg-4' in lines[i+1]: insert_index = i break print(f"Found insert point at line {insert_index + 1}") # Find where to remove (the time card in right column) remove_start = None remove_end = None for i, line in enumerate(lines): if i >= 2810 and i <= 2820: if 'data-module="time"' in line: remove_start = i - 1 # Start from blank line before break if remove_start: # Find the end of this card for i in range(remove_start, min(remove_start + 100, len(lines))): if '' in lines[i] and i > remove_start + 50: # Make sure we've gone past the card content remove_end = i + 1 # Include the closing div break print(f"Found remove section from line {remove_start + 1} to {remove_end + 1}") # Create the new time tracking section with inline quick-add new_time_section = '''
Tid & Fakturering
:
{% for entry in time_entries %} {% else %} {% endfor %}
Dato Beskrivelse Bruger Timer
{{ entry.worked_date }} {{ entry.description or '-' }} {{ entry.user_name }} {{ entry.original_hours }}
Ingen tid registreret
{% if prepaid_cards %}
Klippekort
{% for card in prepaid_cards %}
#{{ card.card_number or card.id }} {{ '%.2f' % card.remaining_hours }}t tilbage
{% endfor %}
{% endif%}
''' # Build the new file new_lines = [] # Copy lines up to insert point new_lines.extend(lines[:insert_index]) # Insert new time section new_lines.append(new_time_section) # Copy lines from insert point to remove start new_lines.extend(lines[insert_index:remove_start]) # Skip the remove section, copy from remove_end onwards new_lines.extend(lines[remove_end:]) # Write the new file with open('app/modules/sag/templates/detail.html', 'w', encoding='utf-8') as f: f.writelines(new_lines) print(f"✅ File updated successfully!") print(f" - Inserted new time section at line {insert_index + 1}") print(f" - Removed old time section (lines {remove_start + 1} to {remove_end + 1})") print(f" - New file has {len(new_lines)} lines (was {len(lines)} lines)")