Skip to content

Commit

Permalink
Merge pull request #128 from schbetsy/upgrade-everything
Browse files Browse the repository at this point in the history
Add Django 1.11 compatibility, and other modernization
  • Loading branch information
schbetsy committed Jul 31, 2018
2 parents fffe6d6 + 927adbd commit 267c457
Show file tree
Hide file tree
Showing 20 changed files with 225 additions and 545 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ build/
develop-eggs/
dist/
eggs/
.eggs/
parts/
sdist/
var/
Expand Down Expand Up @@ -47,6 +48,7 @@ coverage.xml
*.log
*.pot
oah
*.sqlite3

# Sphinx documentation
docs/_build/
Expand Down
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ language: python
python:
- 2.7.14
install:
- pip install -r requirements/test.txt
- pip install tox
- pip install coveralls
script:
- export DJANGO_SETTINGS_MODULE=settings_for_testing
- coverage run manage.py test
- tox
- python2.7 setup.py bdist_wheel
after_success:
- coveralls
Expand Down
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ These instructions are for installation on a Mac with OS X Yosemite (version 10.

**Optional**
* [Homebrew](http://brew.sh)
* [MySQL](http://www.mysql.com)
* [MySQL Python](http://mysql-python.sourceforge.net/)

#### Steps for firing up Django
- It's useful to create a [virtualenv](https://virtualenv.pypa.io/en/latest/) virtual environment to keep Python dependencies sandboxed:
Expand All @@ -40,7 +38,7 @@ cd ~/workspace
git clone https://github.com/cfpb/owning-a-home-api.git
cd owning-a-home-api/
setvirtualenvproject
pip install -r requirements/test.txt
pip install -e '.[testing]'
```

- Initialize your database, load some basic data and launch a development server:
Expand Down Expand Up @@ -69,14 +67,25 @@ This repo contains limited data, but you can explore mortgage interest rates in

## Deeper dive

You can find more about using the API endpoints and the optional use of a MySQL database in our [API documentation pages](https://cfpb.github.io/owning-a-home-api/).
You can find [additional documentation for the `ratechecker` app](ratechecker).

See also [additional documentation for the `ratechecker` app](ratechecker).

## Testing
You can run Python unit tests and see code coverage by running:
## Running Tests

If you have [Tox](https://tox.readthedocs.io/en/latest/) installed (recommended),
you can run the specs for this project with the `tox` command.

If not, this command will run the specs on the python version your local
environment has installed: `./manage.py test`.

If you run the tests via Tox, it will automatically display spec coverage information.
To get test coverage information outside of Tox, install [Coverage.py](https://coverage.readthedocs.io/en/coverage-4.5.1a/)
and run these commands:

```
./pytest.sh
coverage erase
coverage run manage.py test
coverage report
```

## Contributions
Expand Down
2 changes: 1 addition & 1 deletion countylimits/data_collection/county_data_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def get_current_log():
changelog_response = requests.get(CENSUS_CHANGELOG)
changelog_response.raise_for_status()
soup = bs(changelog_response.text, 'lxml')
soup = bs(changelog_response.text, 'html.parser')
return soup.find("div", {"id": CHANGELOG_ID}).text


Expand Down
123 changes: 50 additions & 73 deletions countylimits/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,51 @@
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

def forwards(self, orm):
# Adding model 'State'
db.create_table(u'countylimits_state', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('state_fips', self.gf('django.db.models.fields.CharField')(max_length=2)),
('state_abbr', self.gf('localflavor.us.models.USStateField')(max_length=2)),
))
db.send_create_signal(u'countylimits', ['State'])

# Adding model 'County'
db.create_table(u'countylimits_county', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('county_fips', self.gf('django.db.models.fields.CharField')(max_length=3)),
('county_name', self.gf('django.db.models.fields.CharField')(max_length=100)),
('state', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['countylimits.State'])),
))
db.send_create_signal(u'countylimits', ['County'])

# Adding model 'CountyLimit'
db.create_table(u'countylimits_countylimit', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('fha_limit', self.gf('django.db.models.fields.DecimalField')(max_digits=12, decimal_places=2)),
('gse_limit', self.gf('django.db.models.fields.DecimalField')(max_digits=12, decimal_places=2)),
('va_limit', self.gf('django.db.models.fields.DecimalField')(max_digits=12, decimal_places=2)),
('county', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['countylimits.County'], unique=True)),
))
db.send_create_signal(u'countylimits', ['CountyLimit'])


def backwards(self, orm):
# Deleting model 'State'
db.delete_table(u'countylimits_state')

# Deleting model 'County'
db.delete_table(u'countylimits_county')

# Deleting model 'CountyLimit'
db.delete_table(u'countylimits_countylimit')


models = {
u'countylimits.county': {
'Meta': {'object_name': 'County'},
'county_fips': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
'county_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'state': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['countylimits.State']"})
},
u'countylimits.countylimit': {
'Meta': {'object_name': 'CountyLimit'},
'county': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['countylimits.County']", 'unique': 'True'}),
'fha_limit': ('django.db.models.fields.DecimalField', [], {'max_digits': '12', 'decimal_places': '2'}),
'gse_limit': ('django.db.models.fields.DecimalField', [], {'max_digits': '12', 'decimal_places': '2'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'va_limit': ('django.db.models.fields.DecimalField', [], {'max_digits': '12', 'decimal_places': '2'})
},
u'countylimits.state': {
'Meta': {'object_name': 'State'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'state_abbr': ('localflavor.us.models.USStateField', [], {'max_length': '2'}),
'state_fips': ('django.db.models.fields.CharField', [], {'max_length': '2'})
}
}

complete_apps = ['countylimits']
from __future__ import unicode_literals

from django.db import migrations, models
import localflavor.us.models


class Migration(migrations.Migration):

dependencies = [
]

operations = [
migrations.CreateModel(
name='County',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('county_fips', models.CharField(help_text=b"A three-digit FIPS code for the state's county", max_length=3)),
('county_name', models.CharField(help_text=b'The county name', max_length=100)),
],
options={
'ordering': ['county_fips'],
},
),
migrations.CreateModel(
name='CountyLimit',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('fha_limit', models.DecimalField(help_text=b'Federal Housing Administration loan lending limit for the county', max_digits=12, decimal_places=2)),
('gse_limit', models.DecimalField(help_text=b'Loan limit for mortgages acquired by the Government-Sponsored Enterprises', max_digits=12, decimal_places=2)),
('va_limit', models.DecimalField(help_text=b'The Department of Veterans Affairs loan guaranty program limit', max_digits=12, decimal_places=2)),
('county', models.OneToOneField(to='countylimits.County')),
],
),
migrations.CreateModel(
name='State',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('state_fips', models.CharField(help_text=b'A two-digit FIPS code for the state', max_length=2)),
('state_abbr', localflavor.us.models.USStateField(help_text=b'A two-letter state abbreviation', max_length=2)),
],
options={
'ordering': ['state_fips'],
},
),
migrations.AddField(
model_name='county',
name='state',
field=models.ForeignKey(to='countylimits.State'),
),
]
54 changes: 0 additions & 54 deletions docs/mysql.md

This file was deleted.

1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pages:
- Introduction: index.md
- Usage:
- API endpoints: api.md
- Using MySQL: mysql.md

theme: mkDOCter
extra:
Expand Down
2 changes: 1 addition & 1 deletion oahapi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

urlpatterns = [
url(r'^oah-api/rates/', include('ratechecker.urls')),
url(r'^oah-api/county/$', include('countylimits.urls')),
url(r'^oah-api/county/', include('countylimits.urls')),
]
6 changes: 0 additions & 6 deletions pytest.sh

This file was deleted.

Loading

0 comments on commit 267c457

Please sign in to comment.