Ignore:
Timestamp:
Mar 27, 2010, 2:47:54 PM (15 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, client
Children:
8a0d18c
Parents:
ca03565
git-author:
Alex Dehnert <adehnert@…> (03/27/10 14:47:54)
git-committer:
Alex Dehnert <adehnert@…> (03/27/10 14:47:54)
Message:

Allow filtering by term

File:
1 edited

Legend:

Unmodified
Added
Removed
  • remit/finance_core/reporting.py

    rca03565 rdd2c3d9  
    4545
    4646
    47 def get_primary_axis(slug, base_area):
     47def get_primary_axis(slug, base_area, term, ):
    4848    if slug in axes and axes[slug][1]:
    49         return axes[slug][0](base_area)
     49        return axes[slug][0](base_area, term, )
    5050    else:
    5151        raise NotImplementedError
    5252
    53 def get_secondary_axis(slug, base_area):
     53def get_secondary_axis(slug, base_area, term, ):
    5454    if slug in axes and axes[slug][2]:
    55         return axes[slug][0](base_area)
     55        return axes[slug][0](base_area, term, )
    5656    else:
    5757        raise NotImplementedError
    5858
    59 def get_budget_areas(base_area):
     59def get_budget_areas(base_area, term, ):
    6060    name = 'Budget Areas'
    6161    base_area_depth = base_area.depth
     62    areas = base_area.get_descendants()
     63    if term:
     64        areas = areas.filter(Q(always=True) or Q(budget_term=term))
    6265    axis = [
    6366        (
     
    6770            Q(lineitem__budget_area=area),
    6871        )
    69         for area in base_area.get_descendants()
     72        for area in areas
    7073    ]
    71     axis_objs = base_area.get_descendants()
     74    axis_objs = areas
    7275    return name, axis, axis_objs,
    7376
    74 def get_budget_terms(base_area):
     77def get_budget_terms(base_area, term, ):
    7578    name = 'Budget Terms'
    76     terms = finance_core.models.BudgetTerm.objects.all()
     79    if term:
     80        terms = finance_core.models.BudgetTerm.objects.filter(pk=term.pk)
     81    else:
     82        terms = finance_core.models.BudgetTerm.objects.all()
    7783    axis = [
    7884        (
     
    8692    return name, axis, terms
    8793
    88 def get_layers(base_area):
     94def get_layers(base_area, term, ):
    8995    name = 'Layers'
    9096    axis = [
Note: See TracChangeset for help on using the changeset viewer.