Skip to content

Commit ed0ac8b

Browse files
committed
Merge pull request #1 from leonardoo/dev
Update to django 1.7 and test
2 parents 8645648 + 9db4c36 commit ed0ac8b

File tree

29 files changed

+382
-264
lines changed

29 files changed

+382
-264
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.pyc
55
django_dropbox.egg-info/
66
dist/
7+
env/
78
venv/
89
bin/
910
lib/

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: python
2+
python: 2.7
3+
env:
4+
matrix:
5+
- TOX_ENV=py27-django14
6+
- TOX_ENV=py27-django15
7+
- TOX_ENV=py27-django16
8+
- TOX_ENV=py27-django17
9+
- TOX_ENV=py34-django15
10+
- TOX_ENV=py34-django16
11+
- TOX_ENV=py34-django17
12+
- TOX_ENV=coverage
13+
global:
14+
- secure: ZdqsHM92b1pPklUT6S4j7mbnIQINOE5+QKOFoXqgq/N4lDHX8XvHywWDfn6iigr0R9Nj9F5RmzPB/EyaSbPb/RM14y1BlHPL4Jqwu83+JAyS6QxZqt1cAgrnG++rpJCnTT6tZTsiXgyWo6RCxMTQFAXQsvye6br0w5rLxP7Ymyg=
15+
- secure: XLLNIUgl5VsSy1w6i34z0Vo2NHRQcX9e8TS4Mg4Iq1fDT9WjLGG8tN2Nu4CFzrOK6PjCBFMTHgt88UJiQ45dxAzIFl+ApysqB+E2Z42r3HggiDn2iHfu8S/csSxgcFoI5qjyqeW3tDEOZfxtMZ18hqAPVFBlZ7QwmSSl7TeHb8k=
16+
- secure: ULa2n0dqO1/Vf8QpBXVz47XQ963LXEvD59/TmoxXffusMV47aASSv4j+kXU2+RwvzTDWO5k1afd5esebwGUiv78l/x5Ta4QiDpX6uxxPTQk/CGHEuUTMru7d/CYf3xPAB5Vu/mexaPHmPAT4sO3I9Sef6LIsFSNsXp/LkmbT3NQ=
17+
- secure: gXWm2BJJ7FoGMc09uzPUMpEeFCJMQE3awvJ9nnx6n1I4D7GZPyE7Ukm+o4o8DsjO/nBQzAqkMNJi4J2E4H0FvHnLHif8ktE0JATf3jYAHhOZO4NaY5aikSliMvH2a+JkfNZsUbUbq8zzcZMpyNX2O4N0cIZc9tplQznHD8RMrJU=
18+
install:
19+
- pip install tox
20+
script:
21+
- tox -e $TOX_ENV

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# django-dropbox
2-
> Version 0.0.1
2+
> Version 0.0.5
33
44
# What
55

@@ -28,6 +28,8 @@ additionally you must need to set the next settings:
2828
DROPBOX_ACCESS_TOKEN = 'xxx'
2929
DROPBOX_ACCESS_TOKEN_SECRET = 'xxx'
3030

31+
ACCESS_TYPE = 'app_folder'
32+
3133
if you don't have `DROPBOX_CONSUMER_KEY` or `DROPBOX_CONSUMER_SECRET`
3234
you will need to create an Dropbox app at [Dropbox for Developers](https://www.dropbox.com/developers)
3335
then set `DROPBOX_CONSUMER_KEY` and `DROPBOX_CONSUMER_SECRET` settings in `settings.py`,
@@ -36,3 +38,22 @@ after that run:
3638
$ python manage.py get_dropbox_token
3739

3840
And follow up on screen instructions, finally set the `DROPBOX_ACCESS_TOKEN` and `DROPBOX_ACCESS_TOKEN_SECRET` in `settings.py`
41+
42+
43+
# Config in app
44+
45+
for use in your app project in the models, you have to add
46+
47+
from django_dropbox.storage import DropboxStorage
48+
49+
STORAGE = DropboxStorage()
50+
51+
and in the fields like
52+
53+
file_1 = models.FileField(upload_to="pathtoupload",storage=STORAGE)
54+
55+
or
56+
57+
logo = models.ImageField(upload_to='pathtoupload', storage=STORAGE)
58+
59+

django_dropbox/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
VERSION = (0, 0, 4)
1+
"""
2+
Django accounts management made easy.
23
3-
def get_version():
4-
return '%s.%s.%s' % VERSION
4+
"""
5+
default_app_config = 'django_dropbox.apps.DjangoDropboxConfig'
6+
7+
VERSION = (0, 0, 5)
58

6-
version = get_version()
9+
__version__ = '.'.join((str(each) for each in VERSION[:4]))
10+
11+
def get_version():
12+
"""
13+
Returns string with digit parts only as version.
14+
"""
15+
return '.'.join((str(each) for each in VERSION[:3]))

django_dropbox/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class DjangoDropboxConfig(AppConfig):
5+
name = 'django_dropbox'
6+
verbose_name = 'Django Dropbox'

django_dropbox/compat.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
from io import BytesIO, StringIO
3+
4+
from django.utils import six
5+
from django.utils.six.moves.urllib import parse as urlparse
6+
7+
try:
8+
from django.utils.deconstruct import deconstructible
9+
except ImportError: # Django 1.7+ migrations
10+
deconstructible = lambda klass, *args, **kwargs: klass
11+
12+
13+
def getFile(content=None):
14+
if not content:
15+
return BytesIO()
16+
17+
if six.PY3:
18+
stream_class = StringIO if isinstance(content, six.text_type) else BytesIO
19+
else:
20+
stream_class = BytesIO
21+
return stream_class(content)
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
from django.core.management.base import NoArgsCommand
23
from dropbox import rest, session
34
from django_dropbox.settings import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TYPE
@@ -9,12 +10,12 @@ def handle_noargs(self, *args, **options):
910
request_token = sess.obtain_request_token()
1011

1112
url = sess.build_authorize_url(request_token)
12-
print "Url:", url
13-
print "Please visit this website and press the 'Allow' button, then hit 'Enter' here."
13+
print("Url:", url)
14+
print("Please visit this website and press the 'Allow' button, then hit 'Enter' here.")
1415
raw_input()
1516

1617
# This will fail if the user didn't visit the above URL and hit 'Allow'
1718
access_token = sess.obtain_access_token(request_token)
1819

19-
print "DROPBOX_ACCESS_TOKEN = '%s'" % access_token.key
20-
print "DROPBOX_ACCESS_TOKEN_SECRET = '%s'" % access_token.secret
20+
print("DROPBOX_ACCESS_TOKEN = '%s'" % access_token.key)
21+
print("DROPBOX_ACCESS_TOKEN_SECRET = '%s'" % access_token.secret)
File renamed without changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import models, migrations
5+
import django_dropbox.storage
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='TestDropbox',
16+
fields=[
17+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
18+
('file_test', models.FileField(storage=django_dropbox.storage.DropboxStorage(location=b'/test/djangodropbox'), null=True, upload_to=b'.')),
19+
],
20+
options={
21+
},
22+
bases=(models.Model,),
23+
),
24+
]

0 commit comments

Comments
 (0)