diff --git a/.gitignore b/.gitignore index 6cc7dcb..011481f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.pyc django_dropbox.egg-info/ dist/ +env/ venv/ bin/ lib/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1f39a62 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +language: python +python: 2.7 +env: + matrix: + - TOX_ENV=py27-django14 + - TOX_ENV=py27-django15 + - TOX_ENV=py27-django16 + - TOX_ENV=py27-django17 + - TOX_ENV=py34-django15 + - TOX_ENV=py34-django16 + - TOX_ENV=py34-django17 + - TOX_ENV=coverage + global: + - secure: ZdqsHM92b1pPklUT6S4j7mbnIQINOE5+QKOFoXqgq/N4lDHX8XvHywWDfn6iigr0R9Nj9F5RmzPB/EyaSbPb/RM14y1BlHPL4Jqwu83+JAyS6QxZqt1cAgrnG++rpJCnTT6tZTsiXgyWo6RCxMTQFAXQsvye6br0w5rLxP7Ymyg= + - secure: XLLNIUgl5VsSy1w6i34z0Vo2NHRQcX9e8TS4Mg4Iq1fDT9WjLGG8tN2Nu4CFzrOK6PjCBFMTHgt88UJiQ45dxAzIFl+ApysqB+E2Z42r3HggiDn2iHfu8S/csSxgcFoI5qjyqeW3tDEOZfxtMZ18hqAPVFBlZ7QwmSSl7TeHb8k= + - secure: ULa2n0dqO1/Vf8QpBXVz47XQ963LXEvD59/TmoxXffusMV47aASSv4j+kXU2+RwvzTDWO5k1afd5esebwGUiv78l/x5Ta4QiDpX6uxxPTQk/CGHEuUTMru7d/CYf3xPAB5Vu/mexaPHmPAT4sO3I9Sef6LIsFSNsXp/LkmbT3NQ= + - secure: gXWm2BJJ7FoGMc09uzPUMpEeFCJMQE3awvJ9nnx6n1I4D7GZPyE7Ukm+o4o8DsjO/nBQzAqkMNJi4J2E4H0FvHnLHif8ktE0JATf3jYAHhOZO4NaY5aikSliMvH2a+JkfNZsUbUbq8zzcZMpyNX2O4N0cIZc9tplQznHD8RMrJU= +install: +- pip install tox +script: +- tox -e $TOX_ENV diff --git a/README.md b/README.md index 9c94682..2abc1ad 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # django-dropbox -> Version 0.0.1 +> Version 0.0.5 # What @@ -28,6 +28,8 @@ additionally you must need to set the next settings: DROPBOX_ACCESS_TOKEN = 'xxx' DROPBOX_ACCESS_TOKEN_SECRET = 'xxx' + ACCESS_TYPE = 'app_folder' + if you don't have `DROPBOX_CONSUMER_KEY` or `DROPBOX_CONSUMER_SECRET` you will need to create an Dropbox app at [Dropbox for Developers](https://www.dropbox.com/developers) then set `DROPBOX_CONSUMER_KEY` and `DROPBOX_CONSUMER_SECRET` settings in `settings.py`, @@ -36,3 +38,22 @@ after that run: $ python manage.py get_dropbox_token And follow up on screen instructions, finally set the `DROPBOX_ACCESS_TOKEN` and `DROPBOX_ACCESS_TOKEN_SECRET` in `settings.py` + + +# Config in app + +for use in your app project in the models, you have to add + +from django_dropbox.storage import DropboxStorage + +STORAGE = DropboxStorage() + +and in the fields like + +file_1 = models.FileField(upload_to="pathtoupload",storage=STORAGE) + +or + +logo = models.ImageField(upload_to='pathtoupload', storage=STORAGE) + + diff --git a/django_dropbox/__init__.py b/django_dropbox/__init__.py index 9ce0164..9a83e4a 100644 --- a/django_dropbox/__init__.py +++ b/django_dropbox/__init__.py @@ -1,6 +1,15 @@ -VERSION = (0, 0, 4) +""" +Django accounts management made easy. -def get_version(): - return '%s.%s.%s' % VERSION +""" +default_app_config = 'django_dropbox.apps.DjangoDropboxConfig' + +VERSION = (0, 0, 5) -version = get_version() \ No newline at end of file +__version__ = '.'.join((str(each) for each in VERSION[:4])) + +def get_version(): + """ + Returns string with digit parts only as version. + """ + return '.'.join((str(each) for each in VERSION[:3])) \ No newline at end of file diff --git a/django_dropbox/apps.py b/django_dropbox/apps.py new file mode 100644 index 0000000..f3def62 --- /dev/null +++ b/django_dropbox/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class DjangoDropboxConfig(AppConfig): + name = 'django_dropbox' + verbose_name = 'Django Dropbox' \ No newline at end of file diff --git a/django_dropbox/compat.py b/django_dropbox/compat.py new file mode 100644 index 0000000..2c1f02b --- /dev/null +++ b/django_dropbox/compat.py @@ -0,0 +1,21 @@ + +from io import BytesIO, StringIO + +from django.utils import six +from django.utils.six.moves.urllib import parse as urlparse + +try: + from django.utils.deconstruct import deconstructible +except ImportError: # Django 1.7+ migrations + deconstructible = lambda klass, *args, **kwargs: klass + + +def getFile(content=None): + if not content: + return BytesIO() + + if six.PY3: + stream_class = StringIO if isinstance(content, six.text_type) else BytesIO + else: + stream_class = BytesIO + return stream_class(content) diff --git a/django_dropbox/management/commands/get_dropbox_token.py b/django_dropbox/management/commands/get_dropbox_token.py index 21e1df4..1e566d5 100644 --- a/django_dropbox/management/commands/get_dropbox_token.py +++ b/django_dropbox/management/commands/get_dropbox_token.py @@ -1,3 +1,4 @@ +from __future__ import print_function from django.core.management.base import NoArgsCommand from dropbox import rest, session from django_dropbox.settings import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TYPE @@ -9,12 +10,12 @@ def handle_noargs(self, *args, **options): request_token = sess.obtain_request_token() url = sess.build_authorize_url(request_token) - print "Url:", url - print "Please visit this website and press the 'Allow' button, then hit 'Enter' here." + print("Url:", url) + print("Please visit this website and press the 'Allow' button, then hit 'Enter' here.") raw_input() # This will fail if the user didn't visit the above URL and hit 'Allow' access_token = sess.obtain_access_token(request_token) - print "DROPBOX_ACCESS_TOKEN = '%s'" % access_token.key - print "DROPBOX_ACCESS_TOKEN_SECRET = '%s'" % access_token.secret \ No newline at end of file + print("DROPBOX_ACCESS_TOKEN = '%s'" % access_token.key) + print("DROPBOX_ACCESS_TOKEN_SECRET = '%s'" % access_token.secret) \ No newline at end of file diff --git a/django_dropbox_project/__init__.py b/django_dropbox/runtests/__init__.py similarity index 100% rename from django_dropbox_project/__init__.py rename to django_dropbox/runtests/__init__.py diff --git a/django_dropbox_project/dropbox_testing/__init__.py b/django_dropbox/runtests/dbtest/__init__.py similarity index 100% rename from django_dropbox_project/dropbox_testing/__init__.py rename to django_dropbox/runtests/dbtest/__init__.py diff --git a/django_dropbox/runtests/dbtest/migrations/0001_initial.py b/django_dropbox/runtests/dbtest/migrations/0001_initial.py new file mode 100644 index 0000000..f528283 --- /dev/null +++ b/django_dropbox/runtests/dbtest/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django_dropbox.storage + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='TestDropbox', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('file_test', models.FileField(storage=django_dropbox.storage.DropboxStorage(location=b'/test/djangodropbox'), null=True, upload_to=b'.')), + ], + options={ + }, + bases=(models.Model,), + ), + ] diff --git a/django_dropbox/views.py b/django_dropbox/runtests/dbtest/migrations/__init__.py similarity index 100% rename from django_dropbox/views.py rename to django_dropbox/runtests/dbtest/migrations/__init__.py diff --git a/django_dropbox/runtests/dbtest/models.py b/django_dropbox/runtests/dbtest/models.py new file mode 100644 index 0000000..ca3016a --- /dev/null +++ b/django_dropbox/runtests/dbtest/models.py @@ -0,0 +1,19 @@ +import os +from django.db import models +from django.utils.encoding import python_2_unicode_compatible +from django_dropbox.storage import DropboxStorage +from django.utils.encoding import force_text + + +STORAGE = DropboxStorage(location="/test/djangodropbox") + + +@python_2_unicode_compatible +class TestDropbox(models.Model): + """ + Model for test django-dropbox storage + """ + file_test = models.FileField(upload_to=".",storage = STORAGE, null=True) + + def __str__(self): + return os.path.basename(self.file_test.name) diff --git a/django_dropbox/runtests/dbtest/tests/__init__.py b/django_dropbox/runtests/dbtest/tests/__init__.py new file mode 100644 index 0000000..1c720f0 --- /dev/null +++ b/django_dropbox/runtests/dbtest/tests/__init__.py @@ -0,0 +1,4 @@ +import django + +if django.VERSION < (1, 6): + from .test_models import * \ No newline at end of file diff --git a/django_dropbox/runtests/dbtest/tests/test_models.py b/django_dropbox/runtests/dbtest/tests/test_models.py new file mode 100644 index 0000000..a5a7615 --- /dev/null +++ b/django_dropbox/runtests/dbtest/tests/test_models.py @@ -0,0 +1,20 @@ +from django.core.files.base import ContentFile +from django.test import TestCase +from django_dropbox.storage import DropboxStorage +from django.utils import six +from django_dropbox.runtests.dbtest.models import TestDropbox + +class DropboxStorageTest(TestCase): + + def setUp(self): + self.file_name = "test.txt" + self.file_content = six.b("this is a test") + + def test_file_create_in_model(self): + """ + File must be create in model. + """ + model = TestDropbox() + model.file_test.save(self.file_name, ContentFile(self.file_content)) + self.assertEqual(model.__str__(),self.file_name) + model.file_test.delete() diff --git a/django_dropbox/runtests/runtests.py b/django_dropbox/runtests/runtests.py new file mode 100644 index 0000000..25abcb0 --- /dev/null +++ b/django_dropbox/runtests/runtests.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +os.environ['DJANGO_SETTINGS_MODULE'] = 'django_dropbox.runtests.test_settings' + +import django +from django.conf import settings +from django.test.utils import get_runner + +if __name__ == "__main__": + if django.VERSION >= (1, 7, 0): + # starting from 1.7.0 we need to run setup() in order to populate + # app config + django.setup() + if not settings.configured: + settings.configure(myapp_defaults, DEBUG=True) + + TestRunner = get_runner(settings) + test_runner = TestRunner() + failures = test_runner.run_tests(["django_dropbox"]) + sys.exit(failures) \ No newline at end of file diff --git a/django_dropbox/runtests/test_settings.py b/django_dropbox/runtests/test_settings.py new file mode 100644 index 0000000..ff4c377 --- /dev/null +++ b/django_dropbox/runtests/test_settings.py @@ -0,0 +1,122 @@ +import os +import sys + +import django + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +settings_dir = os.path.dirname(__file__) +PROJECT_ROOT = os.path.abspath(settings_dir) + +ADMINS = ( + # ('Your Name', 'your_email@example.com'), +) + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(PROJECT_ROOT, 'development.db'), + } +} + +# Internationalization +TIME_ZONE = 'America/Chicago' +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 + +# If you set this to False, Django will not use timezone-aware datetimes. +USE_TZ = True + + +# 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', +) + +# Make this unique, and don't share it with anybody. +SECRET_KEY = '12345' + +# 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', +) + +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', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.locale.LocaleMiddleware', +) + +#ROOT_URLCONF = 'urls' +#WSGI_APPLICATION = 'demo.wsgi.application' + +#TEMPLATE_DIRS = ( +# os.path.join(PROJECT_ROOT, 'templates/'), +#) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django.contrib.admin', + "django_dropbox", + "django_dropbox.runtests.dbtest", +) + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse' + } + }, + 'handlers': { + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' + } + }, + 'loggers': { + 'django.request': { + 'handlers': ['mail_admins'], + 'level': 'ERROR', + 'propagate': True, + }, + } +} + +# Needed for Storage + +DROPBOX_CONSUMER_KEY = '9lyr7cjqblxb2kv' +DROPBOX_CONSUMER_SECRET = '4saauuu6alx0iiz' +DROPBOX_ACCESS_TOKEN = 'vkf07symi6iadqba' +DROPBOX_ACCESS_TOKEN_SECRET = 'rz32iqtxsrfuwko' +#DROPBOX_CONSUMER_KEY = os.environ['DROPBOX_CONSUMER_KEY'] +#DROPBOX_CONSUMER_SECRET = os.environ['DROPBOX_CONSUMER_SECRET'] +#DROPBOX_ACCESS_TOKEN = os.environ['DROPBOX_ACCESS_TOKEN'] +#DROPBOX_ACCESS_TOKEN_SECRET = os.environ['DROPBOX_ACCESS_TOKEN_SECRET'] +ACCESS_TYPE = 'app_folder' \ No newline at end of file diff --git a/django_dropbox/storage.py b/django_dropbox/storage.py index 10a8d63..1070dde 100644 --- a/django_dropbox/storage.py +++ b/django_dropbox/storage.py @@ -1,22 +1,19 @@ import errno import os.path import re -import urlparse -import urllib import itertools import platform -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO -from dropbox.session import DropboxSession from dropbox.client import DropboxClient +from dropbox.session import DropboxSession from dropbox.rest import ErrorResponse + from django.core.cache import cache from django.core.files import File from django.core.files.storage import Storage -from django.utils.encoding import filepath_to_uri +from django.utils.encoding import filepath_to_uri, force_text + +from .compat import urlparse, getFile, deconstructible from .settings import (CONSUMER_KEY, CONSUMER_SECRET, @@ -25,7 +22,7 @@ ACCESS_TOKEN_SECRET, CACHE_TIMEOUT) - +@deconstructible class DropboxStorage(Storage): """ A storage class providing access to resources in a Dropbox Public folder. @@ -42,9 +39,8 @@ def __init__(self, location='/Public'): def _get_abs_path(self, name): # the path to save in dropbox name = os.path.join(self.location, name) - if platform.system() == "Windows": - name = name.replace("\\", "/") - return name + name = os.path.normpath(name) + return force_text(name.replace('\\', '/')) def _open(self, name, mode='rb'): name = self._get_abs_path(name) @@ -141,7 +137,7 @@ def __init__(self, name, storage, mode): self._storage = storage self._mode = mode self._is_dirty = False - self.file = StringIO() + self.file = getFile() self._is_read = False @property @@ -159,7 +155,7 @@ def read(self, num_bytes=None): def write(self, content): if 'w' not in self._mode: raise AttributeError("File was opened for read-only access.") - self.file = StringIO(content) + self.file = getFile(content) self._is_dirty = True self._is_read = True diff --git a/django_dropbox/tests.py b/django_dropbox/tests.py index eed3892..8ace239 100644 --- a/django_dropbox/tests.py +++ b/django_dropbox/tests.py @@ -2,6 +2,7 @@ from django.core.files.base import ContentFile from django.test import TestCase from django_dropbox.storage import DropboxStorage +from django.utils import six class DropboxStorageTest(TestCase): @@ -10,6 +11,28 @@ def setUp(self): self.storage = DropboxStorage(location=self.location) self.storage.base_url = '/test_media_url/' + def test_file_delete(self): + """ + File storage should delete file. + """ + self.assertFalse(self.storage.exists('storage_test_1')) + f = self.storage.save('storage_test_1', ContentFile('custom content')) + self.assertTrue(self.storage.exists('storage_test_1')) + self.storage.delete('storage_test_1') + self.assertFalse(self.storage.exists('storage_test_1')) + + + def test_file_delete(self): + """ + File storage should delete dir. + """ + self.assertFalse(self.storage.exists('storage_dir_1')) + self.storage.client.file_create_folder(self.location + '/storage_dir_1') + self.assertTrue(self.storage.exists('storage_dir_1')) + self.storage.delete('storage_dir_1') + self.assertFalse(self.storage.exists('storage_dir_1')) + + def test_file_access_options(self): """ Standard file access options are available, and work as expected. @@ -21,7 +44,7 @@ def test_file_access_options(self): self.assertTrue(self.storage.exists('storage_test')) f = self.storage.open('storage_test', 'r') - self.assertEqual(f.read(), 'storage contents') + self.assertEqual(f.read(), six.b('storage contents')) f.close() self.storage.delete('storage_test') @@ -42,8 +65,8 @@ def test_listdir(self): self.assertFalse(self.storage.exists('storage_test_2')) self.assertFalse(self.storage.exists('storage_dir_1')) - f = self.storage.save('storage_test_1', ContentFile('custom content')) - f = self.storage.save('storage_test_2', ContentFile('custom content')) + f = self.storage.save('storage_test_1', ContentFile(six.b('custom content'))) + f = self.storage.save('storage_test_2', ContentFile(six.b('custom content'))) self.storage.client.file_create_folder(self.location + '/storage_dir_1') dirs, files = self.storage.listdir(self.location) @@ -71,3 +94,4 @@ def test_file_size(self): self.storage.delete('storage_test_size') self.assertFalse(self.storage.exists('storage_test_size')) + diff --git a/django_dropbox_project/django_dropbox b/django_dropbox_project/django_dropbox deleted file mode 120000 index 918b6c5..0000000 --- a/django_dropbox_project/django_dropbox +++ /dev/null @@ -1 +0,0 @@ -../django_dropbox \ No newline at end of file diff --git a/django_dropbox_project/dropbox_testing/admin.py b/django_dropbox_project/dropbox_testing/admin.py deleted file mode 100644 index 5ffce59..0000000 --- a/django_dropbox_project/dropbox_testing/admin.py +++ /dev/null @@ -1,13 +0,0 @@ -from django.contrib import admin -from dropbox_testing.models import Person - -class PersonAdmin(admin.ModelAdmin): - list_display = ('image',) - - def image(self, obj): - if obj.photo: - return '' % obj.photo.url - return '' - image.allow_tags = True - -admin.site.register(Person, PersonAdmin) \ No newline at end of file diff --git a/django_dropbox_project/dropbox_testing/models.py b/django_dropbox_project/dropbox_testing/models.py deleted file mode 100644 index 0675dfa..0000000 --- a/django_dropbox_project/dropbox_testing/models.py +++ /dev/null @@ -1,8 +0,0 @@ -from django.db import models -from django_dropbox.storage import DropboxStorage - -STORAGE = DropboxStorage() - -class Person(models.Model): - photo = models.ImageField(upload_to='photos', storage=STORAGE, null=True, blank=True) - resume = models.FileField(upload_to='resumes', storage=STORAGE, null=True, blank=True) \ No newline at end of file diff --git a/django_dropbox_project/dropbox_testing/tests.py b/django_dropbox_project/dropbox_testing/tests.py deleted file mode 100644 index 501deb7..0000000 --- a/django_dropbox_project/dropbox_testing/tests.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -This file demonstrates writing tests using the unittest module. These will pass -when you run "manage.py test". - -Replace this with more appropriate tests for your application. -""" - -from django.test import TestCase - - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.assertEqual(1 + 1, 2) diff --git a/django_dropbox_project/dropbox_testing/views.py b/django_dropbox_project/dropbox_testing/views.py deleted file mode 100644 index 60f00ef..0000000 --- a/django_dropbox_project/dropbox_testing/views.py +++ /dev/null @@ -1 +0,0 @@ -# Create your views here. diff --git a/django_dropbox_project/manage.py b/django_dropbox_project/manage.py deleted file mode 100755 index 3e4eedc..0000000 --- a/django_dropbox_project/manage.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/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 - -if __name__ == "__main__": - execute_manager(settings) diff --git a/django_dropbox_project/settings.py b/django_dropbox_project/settings.py deleted file mode 100644 index 86c7f0a..0000000 --- a/django_dropbox_project/settings.py +++ /dev/null @@ -1,152 +0,0 @@ -# Django settings for django_dropbox_project project. - -DEBUG = True -TEMPLATE_DEBUG = DEBUG - -ADMINS = ( - # ('Your Name', 'your_email@example.com'), -) - -MANAGERS = ADMINS - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': 'db.sqlite', # Or path to database file if using sqlite3. - 'USER': '', # Not used with sqlite3. - 'PASSWORD': '', # Not used with sqlite3. - 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. - 'PORT': '', # Set to empty string for default. Not used with sqlite3. - } -} - -# 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 = 'America/Chicago' - -# 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 = '' - -# 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 = '' - -# 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 = '' - -# URL prefix for static files. -# Example: "http://media.lawrence.com/static/" -STATIC_URL = '/static/' - -# URL prefix for admin static files -- CSS, JavaScript and images. -# Make sure to use a trailing slash. -# Examples: "http://foo.com/static/admin/", "/static/admin/". -ADMIN_MEDIA_PREFIX = '/static/admin/' - -# 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. -) - -# 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', -) - -# Make this unique, and don't share it with anybody. -SECRET_KEY = 't_*)2-ihjb_+0-mv-m*hmca7fl&ag9g0(%$(hpdegao*^#%-di' - -# 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', -) - -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', -) - -ROOT_URLCONF = 'django_dropbox_project.urls' - -TEMPLATE_DIRS = ( - # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". - # Always use forward slashes, even on Windows. - # Don't forget to use absolute paths, not relative paths. -) - -INSTALLED_APPS = ( - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.sites', - 'django.contrib.messages', - 'django.contrib.staticfiles', - # Uncomment the next line to enable the admin: - 'django.contrib.admin', - # Uncomment the next line to enable admin documentation: - # 'django.contrib.admindocs', - 'django_dropbox', - 'dropbox_testing', -) - -# 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, - }, - } -} - -try: - from local_settings import * -except ImportError: - raise ImportError('You must add local_settings.py file') \ No newline at end of file diff --git a/django_dropbox_project/urls.py b/django_dropbox_project/urls.py deleted file mode 100644 index 2549167..0000000 --- a/django_dropbox_project/urls.py +++ /dev/null @@ -1,17 +0,0 @@ -from django.conf.urls.defaults import patterns, include, url - -# Uncomment the next two lines to enable the admin: -from django.contrib import admin -admin.autodiscover() - -urlpatterns = patterns('', - # Examples: - # url(r'^$', 'django_dropbox_project.views.home', name='home'), - # url(r'^django_dropbox_project/', include('django_dropbox_project.foo.urls')), - - # Uncomment the admin/doc line below to enable admin documentation: - # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - - # Uncomment the next line to enable the admin: - url(r'^admin/', include(admin.site.urls)), -) diff --git a/requirements.txt b/requirements.txt index 0c59687..752f658 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -dropbox>=2.0.0 \ No newline at end of file +dropbox>=2.0.0 +urllib3>=1.10.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 78ec8b0..a9a3c80 100644 --- a/setup.py +++ b/setup.py @@ -1,25 +1,19 @@ #!/usr/bin/env python import os -from django_dropbox import version -from setuptools import setup +from django_dropbox import get_version +from setuptools import setup, find_packages -def get_packages(): - # setuptools can't do the job :( - packages = [] - for root, dirnames, filenames in os.walk('django_dropbox'): - if '__init__.py' in filenames: - packages.append(".".join(os.path.split(root)).strip(".")) - return packages +requires = ['dropbox>=2.0.0', "urllib3>=1.10.1"] -requires = ['dropbox>=2.0.0'] - -setup(name='django-dropbox', - version=version, +setup( + name='django-dropbox', + version=get_version(), description='A Django App that contains a Django Storage which uses Dropbox.', - author=u'Andres Torres Marroquin', + author='Andres Torres Marroquin', author_email='andres.torres.marroquin@gmail.com', url='https://github.com/andres-torres-marroquin/django-dropbox', - packages=get_packages(), + packages=find_packages(), install_requires=requires, + license='BSD', ) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..ff676c2 --- /dev/null +++ b/tox.ini @@ -0,0 +1,34 @@ +[tox] +downloadcache = {toxworkdir}/cache/ + +envlist = + ; py27 has the widest django support + py27-django{14,15,16,17}, + ; py34 support was introduced in django1.5 + py34-django{15,16,17} + + +[testenv] +usedevelop = True +deps = + dropbox + django14: django==1.4.16 + django15: django==1.5.11 + django16: django==1.6.8 + django17: django==1.7.1 + coverage: django==1.7.1 + coverage: coverage==3.7.1 + coverage: coveralls + +basepython = + py34: python3.4 + py27: python2.7 + +commands={envpython} django_dropbox/runtests/runtests.py + +[testenv:coverage] +basepython = python2.7 + +commands= + coverage run --source django_dropbox django_dropbox/runtests/runtests.py + coveralls \ No newline at end of file