-
-
Save toracle/4202529 to your computer and use it in GitHub Desktop.
please
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def report(request): | |
today = datetime.datetime.now() | |
executor = Executor.objects.all() | |
budgets = {'management_budgets': ['out1', 'out2', 'out3', 'out4'], | |
'education_budgets': ['out5', 'out6', 'out7'], | |
'feed_budgets': ['out8', 'out9', 'out10', 'out11', 'out12', 'out13'], | |
'reward_budgets': ['out14', 'out15', 'out16'], | |
'mission_budgets': ['out17', 'out18', 'out19', 'out20', 'out21'], | |
'operation_budgets': ['out22', 'out23', 'out24', 'out25']} | |
result = {} | |
total_sum = 0 | |
for (budget_type, field_names) in budgets.items(): | |
budget_type_sum = 0 | |
for field_name in field_names: | |
result[field_name] = Budget.objects.filter(year=today.year).aggregate(budget_sum=Sum(field_name))['budget_sum'] | |
budget_type_sum += result[field_name] | |
result[budget_type] = budget_type_sum | |
total_sum += budget_type_sum | |
result['total_sum'] = total_sum | |
return render_to_response('report.html', result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment