Skip to content

Commit

Permalink
Merge pull request #116 from unt-libraries/django-111
Browse files Browse the repository at this point in the history
Django 111
  • Loading branch information
somexpert authored Sep 18, 2018
2 parents dbc2df8 + 07b492b commit 9e3d12b
Show file tree
Hide file tree
Showing 27 changed files with 133 additions and 96 deletions.
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
source = name
omit = */migrations/*
branch = true

[report]
show_missing = true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
dist/
build/
.tox
.pytest_cache
db.sqlite3
tests/__pycache__
.coverage
htmlcov/

docs/_build
docs/.doctrees
16 changes: 4 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,12 @@ env:
- DB_POSTGRES_USER=postgres
- DB_PASSWORD=''
matrix:
- TOX_ENV=py27-django17-mysql
- TOX_ENV=py27-django18-mysql
- TOX_ENV=py27-django19-mysql
- TOX_ENV=py27-djangomaster-mysql
- TOX_ENV=py27-django17-postgres
- TOX_ENV=py27-django18-postgres
- TOX_ENV=py27-django19-postgres
- TOX_ENV=py27-djangomaster-postgres
- TOX_ENV=py27-django110-mysql
- TOX_ENV=py27-django110-postgres
- TOX_ENV=py27-django111-mysql
- TOX_ENV=py27-django111-postgres
- TOX_ENV=flake8
- TOX_ENV=docs
matrix:
allow_failures:
- env: TOX_ENV=py27-djangomaster-mysql
- env: TOX_ENV=py27-djangomaster-postgres

install:
- pip install tox
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $ git clone https://github.com/unt-libraries/django-name.git
$ cd django-name
```

Warm up the MySQL database. This only needs to be done when the database container doesn't exist yet. This will take ~15 seconds once the image has been pulled.
Warm up the MySQL database. This only needs to be done when the database container doesn't exist yet. This will take about a minute once the image has been pulled.
```sh
$ docker-compose up -d mysql
```
Expand Down Expand Up @@ -83,9 +83,9 @@ To run the tests via Tox, use this command.
```sh
$ docker-compose run --rm web tox
```
The Tox configuration will test this app with Django 1.7 - 1.9.
The Tox configuration will test this app with Django 1.10 - 1.11.

To run the tests only with the development environment (i.e. with Django 1.8)
To run the tests only with the development environment (i.e. with Django 1.11)
```sh
$ docker-compose run --rm web ./runtests.py
```
Expand Down
6 changes: 3 additions & 3 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Start the app and run the migrations.
# start the app
$ docker-compose up -d
# run the migrations
# wait about 2 minutes to let the database finish initializing, then run the migrations
$ docker-compose run --rm web ./manage.py migrate
# optional: add a superuser in order to login to the admin interface
Expand Down Expand Up @@ -66,9 +66,9 @@ To run the tests via Tox, use this command.
$ docker-compose run --rm web tox
The Tox configuration will test this app with Django 1.7 - 1.9.
The Tox configuration will test this app with Django 1.10 - 1.11.

To run the tests only with the development environment (i.e. with Django 1.8).
To run the tests only with the development environment (i.e. with Django 1.11).

.. code-block:: sh
Expand Down
21 changes: 6 additions & 15 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Installation
Requirements
------------

- Django 1.7+
- Django 1.10 or 1.11
- Postgres or MySQL
- Django Admin - ``django.contrib.admin``
- Humanize - ``django.contrib.humanize``

.. note:: Django Name is intended to be installed within a Django project. If you are unfamiliar with Django, check out the docs_.

.. _docs: https://docs.djangoproject.com/en/1.8/
.. _docs: https://docs.djangoproject.com/en/1.11/

Installation
------------
Expand All @@ -32,18 +32,7 @@ Installation
'name',
)

3. Configure the context processors.

- For Django 1.7 ::

from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS

TEMPLATE_CONTEXT_PROCESSORS += (
'django.core.context_processors.request',
'name.context_processors.name'
)

- For Django 1.8+ ::
3. Configure the context processors. ::

TEMPLATES = [
{
Expand All @@ -68,9 +57,11 @@ Installation

4. Include the URLs. ::

from name import urls as name_urls

urlpatterns = [
# ...
url(r'^name/', include('name.urls', namespace='name'))
url(r'^name/', include(name_urls))
]


Expand Down
2 changes: 1 addition & 1 deletion name/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__title__ = 'Django Name'
__version__ = '1.1.1'
__version__ = '2.0.0'
1 change: 1 addition & 0 deletions name/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,6 @@ def get_formsets(self, request, obj=None):
}),
]


admin.site.register(Name, NameAdmin)
admin.site.register(Identifier_Type, Identifier_TypeAdmin)
1 change: 1 addition & 0 deletions name/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class LocationSerializer(serializers.ModelSerializer):

class Meta:
model = models.Location
fields = '__all__'


class NameStatisticsMonthSerializer(serializers.Serializer):
Expand Down
5 changes: 1 addition & 4 deletions name/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ class NameAtomFeedType(Atom1Feed):
add a georss:point element to any entry that has a current location
set.
"""
# Django still uses mime_type prior to version 1.9
# TODO: Remove the `mime_type` attribute after support for Django 1.8
# is dropped.
content_type = mime_type = 'application/xml'
content_type = 'application/xml'

GEO_RSS_NS = 'http://www.georss.org/georss'

Expand Down
23 changes: 23 additions & 0 deletions name/migrations/0003_auto_20180917_2221.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-09-17 22:21
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('name', '0002_change_choice_fields'),
]

operations = [
migrations.AlterModelOptions(
name='location',
options={'base_manager_name': 'objects', 'ordering': ['status']},
),
migrations.AlterModelOptions(
name='note',
options={'base_manager_name': 'objects'},
),
]
8 changes: 4 additions & 4 deletions name/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ def __unicode__(self):

class NoteManager(models.Manager):
"""Custom Model Manager for the Note model."""
use_for_related_fields = True

def public_notes(self):
return self.get_queryset().exclude(note_type=self.model.NONPUBLIC)

Expand All @@ -94,6 +92,9 @@ class Note(models.Model):

objects = NoteManager()

class Meta:
base_manager_name = 'objects'

def get_note_type_label(self):
"""Returns the label associated with an instance's
note_type.
Expand Down Expand Up @@ -527,8 +528,6 @@ class Meta:

class LocationManager(models.Manager):
"""Custom Manager for the Location model."""
use_for_related_fields = True

def _get_current_location(self):
"""Filters through a Name object's related locations and
returns the one marked as current.
Expand Down Expand Up @@ -579,6 +578,7 @@ class Location(models.Model):

class Meta:
ordering = ['status']
base_manager_name = 'objects'

def geo_point(self):
return '{lat} {lng}'.format(lat=self.latitude, lng=self.longitude)
Expand Down
1 change: 1 addition & 0 deletions name/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

admin.autodiscover()

app_name = 'name'
urlpatterns = [
url(r'^$', views.landing, name='landing'),
url(r'about/$', views.about, name='about'),
Expand Down
6 changes: 3 additions & 3 deletions requirements/requirements-base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Packages that are required by the app.
python-dateutil==2.4.2
markdown2==2.3.0
djangorestframework>=3.1,<3.3.0
python-dateutil==2.7.3
markdown2==2.3.5
djangorestframework==3.8
pynaco==0.1.0
3 changes: 1 addition & 2 deletions requirements/requirements-codestyle.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
flake8==2.3.0
pep8==1.5.7
flake8==3.5.0
5 changes: 2 additions & 3 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Packages that are only used in the dev environments.
Django==1.8
django-debug-toolbar==1.4
ipython==2.4.0
Django==1.11
django-debug-toolbar==1.9
mysql-python==1.2.5
10 changes: 5 additions & 5 deletions requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Tox to make it available in the Docker container.
tox==1.8.1
tox==3.3.0

# Pytest packages.
pytest-django==2.9.1
pytest==2.6.4
pytest-cov==1.8.1
pytest-django==3.4.2
pytest==3.8.0
pytest-cov==2.6.0

# Test packages.
mock==1.0.1
mock==2.0.0
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
readme = fd.read()

install_requires = [
'python-dateutil',
'markdown2',
'djangorestframework >= 3.1,<3.3.0',
'pynaco == 0.1.0'
'python-dateutil==2.7.3',
'markdown2==2.3.5',
'djangorestframework==3.8',
'pynaco==0.1.0'
]

setup(
Expand Down
Empty file removed tests/models.py
Empty file.
14 changes: 5 additions & 9 deletions tests/settings/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
local_path = lambda path: os.path.join(os.path.dirname(__file__), path)


APP_ROOT = os.path.abspath(
Expand All @@ -17,22 +16,19 @@
'django.contrib.admin',
'django.contrib.humanize',
'name',
'tests']
'tests',
]


ROOT_URLCONF = 'tests.urls'

from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
TEMPLATE_CONTEXT_PROCESSORS += (
'django.core.context_processors.request',
'name.context_processors.name')

MIDDLEWARE_CLASSES = (
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
'django.contrib.messages.middleware.MessageMiddleware',
]


# Minimal template settings for testing Django 1.8.
Expand Down
20 changes: 15 additions & 5 deletions tests/settings/dev.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
from .base import *
from .base import * # noqa

INSTALLED_APPS += ['debug_toolbar']

INTERNAL_IPS = (
'172.17.42.1',
)
ALLOWED_HOSTS = INTERNAL_IPS = [
'localhost',
'127.0.0.1',
'0.0.0.0',
]

# Required for viewing the debug toolbar in docker, since the IP address is unknown.
DEBUG_TOOLBAR_CONFIG = {
'SHOW_TOOLBAR_CALLBACK': lambda x: True,
}

INSTALLED_APPS += ['debug_toolbar'] # noqa

MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware'] # noqa

DATABASES = {
'default': {
Expand Down
8 changes: 4 additions & 4 deletions tests/settings/test_mysql.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from .base import *
from .base import * # noqa

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'name',
'USER': os.getenv('DB_MYSQL_USER', default="root"),
'PASSWORD': os.getenv('DB_PASSWORD', default="root"),
'HOST': os.getenv('DB_HOST', default='mysql'),
'USER': os.getenv('DB_MYSQL_USER', default='root'), # noqa
'PASSWORD': os.getenv('DB_PASSWORD', default='root'), # noqa
'HOST': os.getenv('DB_HOST', default='mysql'), # noqa
}
}
8 changes: 4 additions & 4 deletions tests/settings/test_postgres.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from .base import *
from .base import * # noqa

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'name',
'USER': os.getenv('DB_POSTGRES_USER', default='name'),
'PASSWORD': os.getenv('DB_PASSWORD', default='name'),
'HOST': os.getenv('DB_HOST', default='postgres'),
'USER': os.getenv('DB_POSTGRES_USER', default='name'), # noqa
'PASSWORD': os.getenv('DB_PASSWORD', default='name'), # noqa
'HOST': os.getenv('DB_HOST', default='postgres'), # noqa
}
}
Loading

0 comments on commit 9e3d12b

Please sign in to comment.