Changeset 8a0d18c for remit


Ignore:
Timestamp:
Mar 27, 2010, 3:34:11 PM (15 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, client
Children:
ee37f93
Parents:
dd2c3d9
git-author:
Alex Dehnert <adehnert@…> (03/27/10 15:34:11)
git-committer:
Alex Dehnert <adehnert@…> (03/27/10 15:34:11)
Message:

WIP: Add form for selecting parameters

Location:
remit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • remit/finance_core/reporting.py

    rdd2c3d9 r8a0d18c  
    4646
    4747def get_primary_axis(slug, base_area, term, ):
    48     if slug in axes and axes[slug][1]:
    49         return axes[slug][0](base_area, term, )
     48    if slug in axes and axes[slug][2]:
     49        return (axes[slug][0], ) + axes[slug][1](base_area, term, )
    5050    else:
    5151        raise NotImplementedError
    5252
    5353def get_secondary_axis(slug, base_area, term, ):
    54     if slug in axes and axes[slug][2]:
    55         return axes[slug][0](base_area, term, )
     54    if slug in axes and axes[slug][3]:
     55        return (axes[slug][0], ) + axes[slug][1](base_area, term, )
    5656    else:
    5757        raise NotImplementedError
    5858
    5959def get_budget_areas(base_area, term, ):
    60     name = 'Budget Areas'
    6160    base_area_depth = base_area.depth
    6261    areas = base_area.get_descendants()
     
    7372    ]
    7473    axis_objs = areas
    75     return name, axis, axis_objs,
     74    return axis, axis_objs,
    7675
    7776def get_budget_terms(base_area, term, ):
    78     name = 'Budget Terms'
    7977    if term:
    8078        terms = finance_core.models.BudgetTerm.objects.filter(pk=term.pk)
     
    9088        for term in terms
    9189    ]
    92     return name, axis, terms
     90    return axis, terms
    9391
    9492def get_layers(base_area, term, ):
    95     name = 'Layers'
    9693    axis = [
    9794        (
     
    103100        for layer in finance_core.models.layers
    104101    ]
    105     return name, axis, None,
     102    return axis, None,
    106103
    107104axes = {
    108     'budget-areas': (get_budget_areas, True,  True,  ),
    109     'budget-terms': (get_budget_terms, True,  True,  ),
    110     'layers':       (get_layers,       False, True,  ),
     105    'budget-areas': ('Budget Areas',  get_budget_areas, True,  True,  ),
     106    'budget-terms': ('Budget Terms',  get_budget_terms, True,  True,  ),
     107    'layers':       ('Layers',        get_layers,       False, True,  ),
    111108}
    112109
  • remit/finance_core/views.py

    rdd2c3d9 r8a0d18c  
    2121    if 'compute_method' in request.REQUEST:
    2222        compute_method = request.REQUEST['compute_method']
    23     if 'term' in request.REQUEST:
     23    if 'term' in request.REQUEST and not request.REQUEST['term'] == 'all':
    2424        term_obj = get_object_or_404(finance_core.models.BudgetTerm, slug=request.REQUEST['term'])
    2525        term_name = term_obj.name
     
    8181        print "Table size:\t%dx%d" % (len(primary_labels), len(secondary_labels), )
    8282
     83    term_options = finance_core.models.BudgetTerm.objects.all()
    8384    context = {
    8485        'pagename':'reporting',
    8586        'term_name': term_name,
     87        'term_options': term_options,
    8688        'area': base_area_obj,
     89        'axes': finance_core.reporting.axes,
    8790        'primary_name': primary_name,
    8891        'secondary_name': secondary_name,
  • remit/remit_templates/finance_core/reporting.html

    red4ccc7 r8a0d18c  
    99<h3>Parameters</h3>
    1010
     11<form>
    1112<table class='pretty-table'>
    1213<tr>
    1314    <th>Term</th>
    14     <td>{{term_name}}</td>
     15    <td><select name='term'>
     16    <option {% ifequal term_name "All" %}selected {% endifequal %}value='all'>All</option>
     17    {% for term_opt in term_options %}<option {% ifequal term_name term_opt.name %}selected {% endifequal %}value={{term_opt.slug}}>{{term_opt.name}}</option>{% endfor %}
     18    </select></td>
    1519</tr>
    1620<tr>
    1721    <th>Budget Area</th>
    1822    <td>{{area}}</td>
     23</tr>
     24<tr>
     25    <th>Primary Axis</th>
     26    <td><select name='primary'>
     27    {% for slug, content in axes.items %}{% if content.2 %}<option {% ifequal primary_name content.0 %}selected {% endifequal %}value='{{slug}}'>{{content.0}}</option>{% endif %}{% endfor %}
     28    </select></td>
     29</tr>
     30<tr>
     31    <th>Secondary Axis</th>
     32    <td><select name='secondary'>
     33    {% for slug, content in axes.items %}{% if content.3 %}<option {% ifequal secondary_name content.0 %}selected {% endifequal %}value='{{slug}}'>{{content.0}}</option>{% endif %}{% endfor %}
     34    </select></td>
     35</tr>
     36<tr>
     37    <th colspan='2'><input type='submit' name='submit' value='Submit'></th>
    1938</tr>
    2039</table>
Note: See TracChangeset for help on using the changeset viewer.