Skip to content

Commit

Permalink
Merge pull request #80 from /issues/79
Browse files Browse the repository at this point in the history
Issues/79
  • Loading branch information
jantman authored May 28, 2017
2 parents 78eb6e1 + 634991c commit c4bd20c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Unreleased Changes
* When adding or updating the ``actual_amount`` of a Transaction against a Standing Budget, update the ``current_balance`` of the budget.
* Fix ordering of Transactions table on Pay Period view, to properly sort by date and then amount.
* Numerous fixes to date-sensitive acceptance tests.
* `Issue #79 <https://github.com/jantman/biweeklybudget/issues/79>`_ - Update ``/pay_period_for`` view to redirect to current pay period when called with no query parameters; add bookmarkable link to current pay period to Pay Periods view.

0.1.1 (2017-05-20)
------------------
Expand Down
2 changes: 1 addition & 1 deletion biweeklybudget/flaskapp/templates/payperiods.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="panel panel-default">
<div class="panel-heading">Pay Periods</div>
<div class="panel-heading">Pay Periods <em><a href="/pay_period_for">(permalink to current pay period)</a></em></div>
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="pay-period-table">
<thead>
Expand Down
13 changes: 9 additions & 4 deletions biweeklybudget/flaskapp/views/payperiods.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,15 @@ class PeriodForDateView(MethodView):
"""

def get(self):
d_str = request.args.get('date')
d = datetime.strptime(d_str, '%Y-%m-%d').date()
pp = BiweeklyPayPeriod.period_for_date(d, db_session)
logger.debug('Found period for %s (%s): %s', d_str, d, pp)
d_str = request.args.get('date', None)
if d_str is None:
pp = BiweeklyPayPeriod.period_for_date(
datetime.now().date(), db_session
)
else:
d = datetime.strptime(d_str, '%Y-%m-%d').date()
pp = BiweeklyPayPeriod.period_for_date(d, db_session)
logger.debug('Found period for %s (%s): %s', d_str, d, pp)
return redirect(
'/payperiod/%s' % pp.start_date.strftime('%Y-%m-%d'),
code=301
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ def test_current_period_end(self, base_url, selenium):
assert selenium.current_url == \
base_url + '/payperiod/' + start_date.strftime('%Y-%m-%d')

def test_current_pay_period(self, base_url, selenium):
start_date = PAY_PERIOD_START_DATE
print("PayPeriod start date: %s" % start_date)
self.get(selenium, base_url + '/pay_period_for')
self.wait_for_load_complete(selenium)
assert selenium.current_url == \
base_url + '/payperiod/' + start_date.strftime('%Y-%m-%d')


@pytest.mark.acceptance
class TestFindPayPeriod(AcceptanceHelper):
Expand Down

0 comments on commit c4bd20c

Please sign in to comment.