Basically, two tables… Action Plans (Planos de Ação) and SubActions (SubAções)
For easier viewing (since Action Plans will be viewed as one of 5 widgets in anotherpage) I don´t want to have yet another widget showing the SubActions of an Action Plan.
So I decided to try to capture the description of each SubAction that references the main Action Plan.
This is the code… that is not working lol. No error message, but also, no text.
def get_subactions(plan_id):
subactions = []
for subacao in SubAcoes:
if subacao['PAsFK'] == plan_id:
subactions.append(subacao['Descricao'])
return subactions
Planos_de_Acoes = [{'id': 1, 'other_field': 'value1'}, {'id': 2, 'other_field': 'value2'}]
SubAcoes = [{'PAsFK': 1, 'Descricao': 'subacao1'}, {'PAsFK': 2, 'Descricao': 'subacao2'}]
for plano in Planos_de_Acoes:
subactions = get_subactions(plano['id'])
subactions_string = "\n".join(subactions)
plano['SubAcoes'] = subactions_string