Skip to content
This repository has been archived by the owner on Oct 16, 2018. It is now read-only.

Commit

Permalink
Merge branch 'feature/django-1.6' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
hedleyroos committed Apr 29, 2015
2 parents e4467c9 + 25430dd commit 3e9c590
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 144 deletions.
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
addons:
postgresql: "9.3"

language: python

python:
- "2.7"

env:
- DJANGO=Django==1.6.11

install:
- pip install -q $DJANGO --use-mirrors
- pip install -r post/tests/requirements.txt --use-mirrors

before_script:
- psql -U postgres -c "create database jmbo encoding 'UTF8'"

script: python setup.py test
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
next
----
#. Get tests to pass again.
#. Django 1.6 support.
#. Up minimum jmbo to 2.0.0.

0.0.8
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<div>
{% if object.image %}
<a href="{% url download-request object.slug %}">
<a href="{% url "download-request" object.slug %}">
<img src="{{ object.get_download_list_url }}" alt="{{ object.title }}" class="left"/>
</a>
{% endif %}
<div class="title">
<a href="{% url download-request object.slug %}">{{ object.title }}</a>
<a href="{% url "download-request" object.slug %}">{{ object.title }}</a>
</div>
<div class="meta">
{% if object.file %}
Expand Down
7 changes: 5 additions & 2 deletions downloads/tests.py → downloads/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from downloads.models import Download
from downloads.signals import download_requested

RES_DIR = os.path.join(os.path.dirname(__file__), 'res')
FILE_PATH = os.path.join(RES_DIR, 'test_file.py')


class DownloadsTestCase(TestCase):

Expand All @@ -30,7 +33,7 @@ def make_download(self, file_path=None, title='some_title'):
# Just grab this actual file as a test file
file_path = os.path.join(settings.PROJECT_ROOT, 'downloads',
__file__)
content_file = DjangoFile(open(file_path, 'r'), 'test_file.py')
content_file = DjangoFile(open(FILE_PATH, 'r'), 'test_file.py')
dl = Download.objects.create(file=content_file, title=title,
image=content_file, state='published')
# Must publish it to a site for it to become available
Expand Down Expand Up @@ -84,4 +87,4 @@ def test_serve_using_redirect(self):
r = self.client.get(reverse('download-request',
kwargs={'slug': dl.slug}))
self.assertEqual(r.status_code, 302)
self.assertEqual('/%s' % r['Location'].split('/', 3)[3], dl.file.url)
self.assertEqual(r['Location'].split('/', 4)[4], dl.file.url)
Binary file added downloads/tests/res/test_file.py
Binary file not shown.
6 changes: 3 additions & 3 deletions downloads/urls.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from django.conf.urls.defaults import patterns, url
from django.conf.urls import patterns, url

from downloads.views import object_list, download_request
from downloads.views import ObjectList, download_request


urlpatterns = patterns(
'',
# download url
url(
r'^$',
object_list,
ObjectList.as_view(),
name='downloads'
),
url(
Expand Down
6 changes: 2 additions & 4 deletions downloads/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.conf import settings
from django.utils.datastructures import SortedDict

from jmbo.generic.views import GenericObjectList
from jmbo.views import ObjectList as JmboObjectList

from category.models import Category

Expand Down Expand Up @@ -59,7 +59,7 @@ def download_request(request, slug):
return response


class ObjectList(GenericObjectList):
class ObjectList(JmboObjectList):

def get_extra_context(self, *args, **kwargs):
dls = list(Download.permitted.all())
Expand Down Expand Up @@ -119,5 +119,3 @@ def get_paginate_by(self, *args, **kwargs):

def get_template_name(self, *args, **kwargs):
return "downloads/download_list_category.html"

object_list = ObjectList()
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
url='http://github.com/praekelt/jmbo-downloads',
packages = find_packages(),
install_requires = [
'jmbo>=1.0'
'jmbo==2.0.0a2'
],
include_package_data=True,
tests_require=[
'django-setuptest>=0.1.2',
'jmbo>=1.0',
'django-setuptest>=0.1.6',
'psycopg2',
],
test_suite="setuptest.setuptest.SetupTestSuite",
classifiers=[
Expand Down
180 changes: 50 additions & 130 deletions test_settings.py
Original file line number Diff line number Diff line change
@@ -1,159 +1,79 @@
# Django settings for go project.
import os.path

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


def abspath(*args):
"""convert relative paths to absolute paths relative to PROJECT_ROOT"""
return os.path.join(PROJECT_ROOT, *args)

import os
from os.path import expanduser

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
('Foundation Developers', 'dev@praekeltfoundation.org'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
'NAME': 'downloads.db',
'USER': '',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'jmbo',
'USER': 'postgres',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'UTC'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = abspath('media')

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = abspath('static')

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
INSTALLED_APPS = (
'downloads',
'jmbo',
'photologue',
'category',
'likes',
'secretballot',

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
'pagination',
'publisher',
'sites_groups',

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.comments',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'south',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'oe)=p0z-r*pu7=%s!fd^sgcyx$=f0_tq=m@4%h1km*^d)3np5w'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
ROOT_URLCONF = 'downloads.urls'

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'likes.middleware.SecretBallotUserIpUseragentMiddleware',
'pagination.middleware.PaginationMiddleware',
)

ROOT_URLCONF = 'downloads.urls'

TEMPLATE_DIRS = (
abspath("downloads", "templates"),
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
)

INSTALLED_APPS = (
'downloads',
'jmbo',
'photologue',
'atlas',
'category',
'publisher',
'secretballot',
'atlas',
'south',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.gis',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'south'
)
USE_TZ = True

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
SITE_ID = 1

STATIC_URL = '/static/'

SOUTH_TESTS_MIGRATE = False

# Disable celery
CELERY_ALWAYS_EAGER = True
BROKER_BACKEND = 'memory'

PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))

def abspath(*args):
"""convert relative paths to absolute paths relative to PROJECT_ROOT"""
return os.path.join(PROJECT_ROOT, *args)

MEDIA_ROOT = abspath('media')

0 comments on commit 3e9c590

Please sign in to comment.