Skip to content

Commit

Permalink
Add handling for a new disclosure URL field leng
Browse files Browse the repository at this point in the history
Previously program length, the standard intended length for a course of
study, was provided by the school in its program data. The new URL field
allows a school to override the standard program length with a
personalized length based on circumstances of an individual student,
such as a student transferring in with credits.

This commit also fixes a directional error in the intro, changes the
"Print offer" button to simply "Print" and cleans up some dead view
code.
  • Loading branch information
higs4281 committed Nov 18, 2016
1 parent f91ebb0 commit d51c51f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ We follow the [Semantic Versioning 2.0.0](http://semver.org/) format.
## Unreleased
- Fixed Python unit tests when run as part of cfgov-refresh.
- Removed debug print statements from Python unit tests.
- Added handling for a new disclosure URL field, `leng`

## 2.2.7
- Updated the `load_programs` script to be compatible with djangorestframework 3.1.3
Expand Down
4 changes: 3 additions & 1 deletion docs/url-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ consumerfinance.gov/paying-for-college2/
understanding-your-financial-aid-offer/offer/?
iped=204316&pid=business-1042&oid=a9e280139f3238cbc9702c7b0d62e5c238a835a0
&book=650&gib=3000&gpl=1000&hous=3000&insi=4.55&insl=3000&inst=36
&mta=3000&othg=100&othr=500&parl=10000&pelg=1500&perl=3000
&leng=24&mta=3000&othg=100&othr=500&parl=10000&pelg=1500&perl=3000
&ppl=1000&prvl=3000&prvf=2.1&prvi=4.55&schg=2000&stag=2000
&subl=3500&totl=40000&tran=500&tuit=38976&unsl=2000&wkst=3000
```
Expand All @@ -36,6 +36,7 @@ hous | housing | 3000 | room + board
insi | institutional (school) loan interest rate | 0.0455 | rates should be expressed as coefficients, so 4.55% is 0.0455
insl | institutional loans (all) | 3000 | including tuition payment plans
inst | institutional loan term | 48 | in months
leng | program length | 48 | optional field for providing an adjusted program length, in months
mta | military assistance | 3000 |
othg | other grants and scholarships | 100 |
othr | other costs | 500 |
Expand All @@ -58,6 +59,7 @@ wkst | work study | 3000 |
#### Change log
Change | date
:----- | :---
Added `leng` field for optionally adjusting program length | 2016-11-17
Added underscore to list of characters not allowed in a program ID | 2016-08-24
Added note that values should be annual unless otherwise specified | 2016-07-26
Added note for parl: it represents all family contributions | 2016-07-19
Expand Down
4 changes: 2 additions & 2 deletions paying_for_college/templates/worksheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ <h2 class="verify_prompt">
<p class="verify_label-explanation">
Select how long you expect it to take to
complete your program. This may be
shorter than the program length above if
shorter than the program length below if
you transferred in with credits that the
school accepts. For example, it may be
longer if you plan to attend part time
Expand Down Expand Up @@ -3258,7 +3258,7 @@ <h2 class="step_heading">
type="button">
<span class="btn_icon__left cf-icon
cf-icon-print"></span>
Print offer
Print
</button>
</div>
</li>
Expand Down
24 changes: 3 additions & 21 deletions paying_for_college/views.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
import os
import json
import uuid
import re

try:
from collections import OrderedDict
except: # pragma: no cover
from ordereddict import OrderedDict

import requests

from django.utils import timezone
from django.middleware import csrf
from django.core.urlresolvers import reverse
from django.views.generic import View, TemplateView
from django.shortcuts import get_object_or_404, render_to_response
from django.core import serializers
from django.core.exceptions import ObjectDoesNotExist
from django.core.mail import send_mail
from django.template import RequestContext
from django.template.loader import get_template
from django.http import HttpResponse, HttpResponseBadRequest
from django.conf import settings

from haystack.query import SearchQuerySet

from models import School, Worksheet, Feedback, Notification
from models import Program, ConstantCap, ConstantRate
from validators import validate_uuid4 # ,validate_worksheet
from paying_for_college.disclosures.scripts import nat_stats

# from models import BAHRate
from forms import FeedbackForm, EmailForm
BASEDIR = os.path.dirname(__file__)

Expand Down Expand Up @@ -240,16 +230,6 @@ def post(self, request):
return HttpResponseBadRequest("Invalid form")


# class BuildComparisonView(View):

# def get(self, request):
# return render_to_response('worksheet.html',
# {'data_js': "0",
# 'base_template': BASE_TEMPLATE,
# 'url_root': URL_ROOT},
# context_instance=RequestContext(request))


class SchoolRepresentation(View):

def get_school(self, school_id):
Expand Down Expand Up @@ -290,7 +270,9 @@ class StatsRepresentation(View):

def get_stats(self, school, programID):
program = get_program(school, programID)
national_stats = nat_stats.get_prepped_stats(program_length=get_program_length(program, school))
national_stats = nat_stats.get_prepped_stats(
program_length=get_program_length(program, school)
)
return json.dumps(national_stats)

def get(self, request, id_pair=''):
Expand Down
2 changes: 1 addition & 1 deletion src/disclosures/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var app = {
// on program data
if ( !data.hasOwnProperty( 'pidNotFound' ) ) {
financialModel.updateModelWithProgram( schoolValues );
financialView.updateViewWithProgram( schoolValues );
financialView.updateViewWithProgram( schoolValues, urlValues );
}

// Add url values to the financial model
Expand Down
21 changes: 19 additions & 2 deletions src/disclosures/js/utils/query-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ function queryHandler( queryString ) {
roomBoard: 0,
books: 0,
transportation: 0,
otherExpenses: 0
otherExpenses: 0,
urlProgramLength: 0
};
var parameters = {};
var numericKeys = [
'iped', 'tuit', 'hous', 'book', 'tran', 'othr',
'iped', 'tuit', 'hous', 'book', 'leng', 'tran', 'othr',
'pelg', 'schg', 'stag', 'othg', 'mta', 'gib', 'fam', 'wkst', 'parl',
'perl', 'subl', 'unsl', 'ppl', 'gpl', 'prvl', 'prvi', 'prvf', 'insl',
'insi', 'sav', 'totl'
Expand All @@ -26,6 +27,7 @@ function queryHandler( queryString ) {
iped: 'collegeID',
pid: 'programID',
oid: 'offerID',
leng: 'urlProgramLength',
tuit: 'tuitionFees',
hous: 'roomBoard',
book: 'books',
Expand Down Expand Up @@ -103,8 +105,23 @@ function queryHandler( queryString ) {
}
}

/**
* Helper function that makes sure program lengths are divisible by 6,
* so they can be displayed and handled as half-year multiples.
* Both here and in the API, we round up to the next higher 6-month value,
* so 14 months would round up to 18, which is displayed as 1 ½ years.
*/
function adjustProgramLength() {

var lengthValue = valuePairs.urlProgramLength;
if ( lengthValue % 6 !== 0 ) {
valuePairs.urlProgramLength = lengthValue + (6 - (lengthValue % 6));
}
}

getPairs();
remapKeys();
adjustProgramLength();

// move private loan properties to privateLoanMulti
valuePairs.privateLoanMulti = [
Expand Down
9 changes: 7 additions & 2 deletions src/disclosures/js/views/financial-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,15 @@ var financialView = {
* graduate program only content, Pell grants, subsidized loans, and
* Grad PLUS loans.
* @param {object} values - An object with program values
* @param {object} urlvalues - An object with url-derived values
*/
updateViewWithProgram: function( values ) {
updateViewWithProgram: function( values, urlValues ) {
// Update program length
this.$programLength.val( values.programLength ).change();
if ( urlValues.urlProgramLength ) {
this.$programLength.val( urlValues.urlProgramLength / 12 ).change();
} else {
this.$programLength.val( values.programLength ).change();
}
// Update links
linksView.updateLinks( values );
// Update availability of Pell grants, subsidized loans, and gradPLUS loans
Expand Down

0 comments on commit d51c51f

Please sign in to comment.