Skip to content

Commit

Permalink
issue #22 - start working on budgets implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Mar 27, 2017
1 parent b900598 commit 82d7a13
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 3 deletions.
88 changes: 87 additions & 1 deletion biweeklybudget/flaskapp/templates/budgets.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,95 @@
{% include 'notifications.html' %}
<div class="row" id="content-row">
<div class="col-lg-12">
<h1 class="page-header">Budgets</h1>
<div class="panel panel-default" id="panel-bank-accounts">
<div class="panel-heading">
Periodic Budgets
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Budget</th>
<th>Starting Balance</th>
</tr>
</thead>
<tbody>
{% for b in periodic %}
<tr>
<td>{{ b.name }}</a></td>
<td>{{ b.starting_balance|dollars }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- /.table-responsive -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
<div class="panel panel-default" id="panel-credit-cards">
<div class="panel-heading">
Standing Budgets
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Budget</th>
<th>Current Balance</th>
</tr>
</thead>
<tbody>
{% for b in standing %}
<tr>
<td>{{ b.name }}</a></td>
<td>
<span>{{ b.current_balance|dollars }}</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- /.table-responsive -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<!-- Modal -->
<div class="modal fade" id="budgetModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="budgetModalLabel">Modal title</h4>
</div>
<div class="modal-body" id="budgetModalBody">
<div class="table-responsive">
<table class="table table-bordered table-hover">
<tbody>
</tbody>
</table>
</div>
<!-- /.table-responsive -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="budgetModalSaveButton">Save changes</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
{% endblock %}
14 changes: 13 additions & 1 deletion biweeklybudget/flaskapp/views/budgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,23 @@
from flask import render_template

from biweeklybudget.flaskapp.app import app
from biweeklybudget.db import db_session
from biweeklybudget.models.budget_model import Budget


class BudgetsView(MethodView):

def get(self):
return render_template('budgets.html')
standing = db_session.query(Budget).filter(
Budget.is_active == True, Budget.is_periodic == False
).order_by(Budget.name).all()
periodic = db_session.query(Budget).filter(
Budget.is_active == True, Budget.is_periodic == True
).order_by(Budget.name).all()
return render_template(
'budgets.html',
standing=standing,
periodic=periodic
)

app.add_url_rule('/budgets', view_func=BudgetsView.as_view('budgets_view'))
64 changes: 64 additions & 0 deletions biweeklybudget/tests/acceptance/flaskapp/views/test_budgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""
The latest version of this package is available at:
<http://github.com/jantman/biweeklybudget>
################################################################################
Copyright 2016 Jason Antman <jason@jasonantman.com> <http://www.jasonantman.com>
This file is part of biweeklybudget, also known as biweeklybudget.
biweeklybudget is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
biweeklybudget is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with biweeklybudget. If not, see <http://www.gnu.org/licenses/>.
The Copyright and Authors attributions contained herein may not be removed or
otherwise altered, except to add the Author attribution of a contributor to
this work. (Additional Terms pursuant to Section 7b of the AGPL v3)
################################################################################
While not legally required, I sincerely request that anyone who finds
bugs please submit them at <https://github.com/jantman/biweeklybudget> or
to me via email, and that you send any contributions or improvements
either as a pull request on GitHub, or to me via email.
################################################################################
AUTHORS:
Jason Antman <jason@jasonantman.com> <http://www.jasonantman.com>
################################################################################
"""

import pytest

from biweeklybudget.tests.acceptance_helpers import AcceptanceHelper


@pytest.mark.acceptance
class TestBudgets(AcceptanceHelper):

@pytest.fixture(autouse=True)
def get_page(self, base_url, selenium, testflask, testdb): # noqa
self.baseurl = base_url
selenium.get(base_url + '/budgets')

def test_heading(self, selenium):
heading = selenium.find_element_by_class_name('navbar-brand')
assert heading.text == 'OFX Transactions - BiweeklyBudget'

def test_nav_menu(self, selenium):
ul = selenium.find_element_by_id('side-menu')
assert ul is not None
assert 'nav' in ul.get_attribute('class')
assert ul.tag_name == 'ul'

def test_notifications(self, selenium):
div = selenium.find_element_by_id('notifications-row')
assert div is not None
assert div.get_attribute('class') == 'row'
5 changes: 4 additions & 1 deletion biweeklybudget/tests/fixtures/sampledata.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def load(self):
self.budgets = self._budgets()

def _budgets(self):
return {
res = {
'Periodic1': Budget(
name='Periodic1',
is_periodic=True,
Expand Down Expand Up @@ -95,6 +95,9 @@ def _budgets(self):
current_balance=9482.29
)
}
for x in res.keys():
self.db.add(res[x])
return res

def _add_account(self, acct, statements, transactions):
self.db.add(acct)
Expand Down

0 comments on commit 82d7a13

Please sign in to comment.