Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit d9a771d

Browse files
authored
Upgraded django, drf, and removed django-model-utils. (#149)
1 parent d1bcc5b commit d9a771d

3 files changed

Lines changed: 27 additions & 21 deletions

File tree

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""A command to set the API key for a user using when using TokenAuthentication."""
22

3-
from optparse import make_option
4-
53
from django.contrib.auth import get_user_model
64
from django.core.management.base import BaseCommand, CommandError
75

@@ -15,29 +13,35 @@ class Command(BaseCommand):
1513
"""A command to set the API key for a user using when using TokenAuthentication."""
1614

1715
help = 'Set the API key for the specified user.'
18-
args = '<username> <api_key>'
19-
option_list = BaseCommand.option_list + (
20-
make_option('--delete-key', action='store_true', default=False, help="Delete API key for user"),
21-
)
16+
17+
def add_arguments(self, parser):
18+
parser.add_argument('username', nargs='?')
19+
parser.add_argument('api_key', nargs='?')
20+
parser.add_argument(
21+
'--delete-key',
22+
action='store_true',
23+
default=False,
24+
help="Delete API key for user",
25+
)
2226

2327
def handle(self, *args, **options):
24-
if len(args) < 1:
28+
if options['username'] is None:
2529
raise CommandError("You must supply a username.")
2630

27-
username = args[0]
31+
username = options['username']
2832

2933
if options['delete_key']:
3034
delete_user_auth_token(username)
3135
print 'Removed API key for user: <{0}>'.format(username)
3236
else:
33-
if len(args) < 2:
37+
if options['api_key'] is None:
3438
raise CommandError("You must supply both a username and key.")
3539

3640
# pylint: disable=no-member
3741
user, _ = User.objects.get_or_create(username=username)
3842

3943
try:
40-
key = args[1]
44+
key = options['api_key']
4145
set_user_auth_token(user, key)
4246
except AttributeError:
4347
print "The key %s is in use by another user. Please select another key." % key

analyticsdataserver/router.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,25 @@
33

44
class AnalyticsApiRouter(object):
55
def db_for_read(self, model, **hints): # pylint: disable=unused-argument
6-
return self._get_database(model)
6+
# pylint: disable=protected-access
7+
return self._get_database(model._meta.app_label)
78

8-
def _get_database(self, model):
9-
if model._meta.app_label == 'v0': # pylint: disable=protected-access
9+
def _get_database(self, app_label):
10+
if app_label == 'v0':
1011
return getattr(settings, 'ANALYTICS_DATABASE', 'default')
1112

1213
return None
1314

1415
def db_for_write(self, model, **hints): # pylint: disable=unused-argument
15-
return self._get_database(model)
16+
# pylint: disable=protected-access
17+
return self._get_database(model._meta.app_label)
1618

1719
def allow_relation(self, obj1, obj2, **hints): # pylint: disable=unused-argument
18-
return self._get_database(obj1) == self._get_database(obj2)
20+
# pylint: disable=protected-access
21+
return self._get_database(obj1._meta.app_label) == self._get_database(obj2._meta.app_label)
1922

20-
def allow_migrate(self, database, model):
21-
dest_db = self._get_database(model)
23+
def allow_migrate(self, database, app_label, model_name=None, **hints): # pylint: disable=unused-argument
24+
dest_db = self._get_database(app_label)
2225
if dest_db is not None:
2326
return database == dest_db
2427
else:

requirements/base.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
boto==2.42.0 # MIT
2-
Django==1.9.9 # BSD License
2+
Django==1.10.4 # BSD License
33
django-countries==4.0 # MIT
4-
django-model-utils==2.5.2 # BSD
5-
djangorestframework==3.4.6 # BSD
4+
djangorestframework==3.5.3 # BSD
65
django-rest-swagger==0.3.8 # BSD
76
djangorestframework-csv==1.4.1 # BSD
8-
django-storages==1.4.1 # BSD
7+
django-storages==1.5.1 # BSD
98
elasticsearch-dsl==0.0.11 # Apache 2.0
109
ordered-set==2.0.1 # MIT
1110
tqdm==4.10.0 # MIT

0 commit comments

Comments
 (0)