Skip to content

Commit

Permalink
pep8, python3 support, Travis CI, update example project and setup.py…
Browse files Browse the repository at this point in the history
…, fix bootstrap template
  • Loading branch information
lampslave committed Nov 6, 2015
1 parent a0e1325 commit 31290a3
Show file tree
Hide file tree
Showing 19 changed files with 270 additions and 256 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ target/

# PyCharm
.idea/

*.db
*.sqlite3
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
env:
- DJANGO="Django>=1.7,<1.8" DB=sqlite
- DJANGO="Django>=1.8,<1.9" DB=sqlite
install:
- pip install -U $DJANGO
- pip install -U -r pipreq.txt --exists-action=w
script:
- python example_project/manage.py test
7 changes: 6 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
include LICENSE.txt
recursive-include pure_pagination/templates *
include MANIFEST.in
include README.rst
recursive-include pure_pagination/templates *
recursive-include example_project/example_project/templates *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
4 changes: 2 additions & 2 deletions example_project/core/names.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
names = [
names = [ # NOQA
'Aan',
'Aalia',
'Aaliah',
Expand Down Expand Up @@ -5605,4 +5605,4 @@
'Zuleika',
'Zulema',
'Zuriel',
'Zyta', ]
'Zyta', ]
8 changes: 3 additions & 5 deletions example_project/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

from core.names import names

def index(request):

def index(request):
how_many_names = request.GET.get('how_many_names', 60)
page_size = request.GET.get('page_size', 10)
page_num = request.GET.get('page', 1)
Expand All @@ -22,13 +22,11 @@ def index(request):

selected_names = []
total = len(names)
for i in xrange(how_many_names):
selected_names.append(names[randint(0, total-1)])
for i in range(how_many_names):
selected_names.append(names[randint(0, total - 1)])
p = Paginator(selected_names, page_size, request=request)

page = p.page(page_num)
return render_to_response('index.html', {
'page': page,
})


File renamed without changes.
103 changes: 103 additions & 0 deletions example_project/example_project/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
"""
Django settings for example_project project.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '!5j&vfc%!&%j*vz6+mp5b9jc6=$)-1xhw3t#1m3kcm%y^3@0o)'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'core',
'pure_pagination',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'example_project.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'example_project.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = False


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
23 changes: 23 additions & 0 deletions example_project/example_project/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""example_project URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from core.views import index

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^$', index, name="index"),
]
16 changes: 16 additions & 0 deletions example_project/example_project/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for example_project project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_project.settings")

application = get_wsgi_application()
18 changes: 7 additions & 11 deletions example_project/manage.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/usr/bin/env python
from django.core.management import execute_manager
import imp
try:
imp.find_module('settings') # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
sys.exit(1)

import settings
import os
import sys

if __name__ == "__main__":
execute_manager(settings)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_project.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
152 changes: 0 additions & 152 deletions example_project/settings.py

This file was deleted.

Loading

0 comments on commit 31290a3

Please sign in to comment.