27 lines
767 B
Python
27 lines
767 B
Python
import os
|
|
|
|
def patch_volunteer_list():
|
|
with open('core/views.py', 'r') as f:
|
|
lines = f.readlines()
|
|
|
|
# Find volunteer_list
|
|
start_idx = -1
|
|
for i, line in enumerate(lines):
|
|
if 'def volunteer_list(request):' in line:
|
|
start_idx = i
|
|
break
|
|
|
|
if start_idx != -1:
|
|
# Find the context dict
|
|
for i in range(start_idx, start_idx + 100):
|
|
if 'context = {' in lines[i]:
|
|
# Add bulk_tasks to context
|
|
lines.insert(i + 1, " 'bulk_tasks': BulkTask.objects.filter(tenant=tenant).order_by('-created_at')[:5],\n")
|
|
break
|
|
|
|
with open('core/views.py', 'w') as f:
|
|
f.writelines(lines)
|
|
|
|
if __name__ == '__main__':
|
|
patch_volunteer_list()
|