This repository has been archived by the owner on May 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from pmclanahan/django-1.8-drf-upgrade
Upgrade for Django 1.8
- Loading branch information
Showing
30 changed files
with
599 additions
and
1,421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include *.md LICENSE | ||
include runtests.py | ||
recursive-include tests *.py | ||
recursive-include requirements *.txt | ||
recursive-include rna/static *.js | ||
recursive-include rna/templates *.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
-r common.txt | ||
|
||
djangorestframework==2.3.7 | ||
djangorestframework==3.3.2 | ||
https://github.com/pmclanahan/django-synctool/archive/fix-dumpdata.tar.gz#egg=django-synctool==1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
South==0.8.2 | ||
Django==1.4.9 | ||
Django==1.8.9 | ||
django-extensions==1.2.0 | ||
django-pagedown==0.0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,24 @@ | ||
from optparse import make_option | ||
from django.conf import settings | ||
from django.core.management import BaseCommand | ||
|
||
from django.core.mail import mail_admins | ||
from django.core.management.base import BaseCommand, CommandError | ||
from django.core.exceptions import ObjectDoesNotExist | ||
from synctool.functions import sync_data | ||
|
||
from requests.exceptions import RequestException | ||
from rna.utils import get_last_modified_date | ||
|
||
from ... import clients | ||
|
||
DEFAULT_RNA_SYNC_URL = 'https://nucleus.mozilla.org/rna/sync/' | ||
|
||
class Command(BaseCommand): | ||
option_list = BaseCommand.option_list + ( | ||
make_option('--force', | ||
action='store_true', | ||
dest='force', | ||
default=False, | ||
help='Force complete sync, ignoring modified timestamps'), | ||
) | ||
|
||
def model_params(self, models, force=False): | ||
if force: | ||
return {} | ||
params = dict((m, {}) for m in models) | ||
for m in models: | ||
try: | ||
latest = m.objects.latest('modified') | ||
except ObjectDoesNotExist: | ||
pass | ||
else: | ||
params[m]['modified_after'] = latest.modified.isoformat() | ||
return params | ||
class Command(BaseCommand): | ||
def add_arguments(self, parser): | ||
parser.add_argument('-u', '--url', | ||
default=getattr(settings, 'RNA_SYNC_URL', DEFAULT_RNA_SYNC_URL), | ||
help='Full URL to RNA Sync endpoint') | ||
parser.add_argument('-c', '--clean', action='store_true', | ||
help='Delete all RNA data before sync.') | ||
|
||
def handle(self, *args, **options): | ||
rc = clients.RNAModelClient() | ||
model_params = self.model_params(rc.model_map.values(), | ||
force=options['force']) | ||
try: | ||
for url_name, model_class in rc.model_map.items(): | ||
params = model_params.get(model_class) | ||
rc.model_client(url_name).model(save=True, params=params) | ||
except RequestException as e: | ||
subject = 'Problem connecting to Nucleus' | ||
mail_admins(subject, str(e)) | ||
raise CommandError('%s: %s' % (subject, e)) | ||
sync_data(url=options['url'], | ||
clean=options['clean'], | ||
last_modified=get_last_modified_date(), | ||
api_token=None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
METHOD_OVERRIDE_HEADER = 'HTTP_X_HTTP_METHOD_OVERRIDE' | ||
|
||
|
||
class PatchOverrideMiddleware(object): | ||
def process_view(self, request, callback, callback_args, callback_kwargs): | ||
if request.method == 'POST' and request.META.get(METHOD_OVERRIDE_HEADER) == 'PATCH': | ||
request.method = 'PATCH' |
Oops, something went wrong.