Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Merge pull request #57 from pmclanahan/django-1.8-drf-upgrade
Browse files Browse the repository at this point in the history
Upgrade for Django 1.8
  • Loading branch information
jgmize committed Mar 14, 2016
2 parents 833c5ad + 5120dd4 commit 25ae9af
Show file tree
Hide file tree
Showing 30 changed files with 599 additions and 1,421 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ docs/_gh-pages
docs/_build
build.py
build
dist
django_mozilla_rna.egg-info
.DS_Store
*-min.css
*-all.css
Expand All @@ -29,3 +31,4 @@ Desktop.ini
test.db
htmlcov
/venv/

22 changes: 15 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
sudo: false
language: python
python:
- "2.6"
- "2.7"
- '2.7'
env:
- DJANGO_SETTINGS_MODULE=test_app.settings
- DJANGO_SETTINGS_MODULE=tests.settings
install:
- travis_retry pip install -r requirements/dev.txt
before_script:
- flake8 rna
script: make cover
install:
- pip install -r requirements/dev.txt --use-mirrors
after_success:
# Report coverage results to coveralls.io
- pip install coveralls --use-mirrors
- travis_retry pip install coveralls
- coveralls
notifications:
irc:
Expand All @@ -20,3 +19,12 @@ notifications:
on_success: change
on_failure: always
use_notice: true
deploy:
provider: pypi
distributions: sdist bdist_wheel
user: pmclanahan
password:
secure: DnYb9z64qLO70e+O8fHYb98HAPIm40Hwrx6uKSN/ha5AxTFUloRicH2l1URunJQlWVAKaewXyzkx2vUuBjuM7UpkHy/JzP4XR5ZVNbkalww6wqORtw629e2BiLMNA5eNB86uwpxtTPLv5+/n/YRcK+VAJpmWmMzbAq2NT3JxTOs=
on:
tags: true
repo: mozilla/rna
6 changes: 6 additions & 0 deletions MANIFEST.in
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
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ BASEDIR = $(CURDIR)
NAME = $(shell basename $(BASEDIR))
CMD_NAME = django-admin.py

export DJANGO_SETTINGS_MODULE = test_app.settings
export DJANGO_SETTINGS_MODULE = tests.settings
export PYTHONPATH := $(BASEDIR):$(PYTHONPATH)

help:
Expand All @@ -28,7 +28,7 @@ help:

cover:
@coverage erase
@coverage run `which $(CMD_NAME)` test
@coverage run runtests.py

cover_report: cover
@coverage report -m $(APP_DIR)/**.py
Expand All @@ -38,7 +38,7 @@ manage:
@$(CMD_NAME) $(filter-out $@, $(MAKECMDGOALS))

migrate:
$(CMD_NAME) migrate $(APP_DIR) $(filter-out $@, $(MAKECMDGOALS))
$(CMD_NAME) migrate $(filter-out $@, $(MAKECMDGOALS))

shell:
@$(CMD_NAME) shell
Expand All @@ -65,10 +65,10 @@ schema_initial:
@$(CMD_NAME) schemamigration $(APP_DIR) --initial

test:
@$(CMD_NAME) test $(filter-out $@, $(MAKECMDGOALS))
@./runtests.py $(filter-out $@, $(MAKECMDGOALS))

test_ipdb:
@$(CMD_NAME) test $(filter-out $@, $(MAKECMDGOALS)) --ipdb --ipdb-failures
@./runtests.py $(filter-out $@, $(MAKECMDGOALS)) --ipdb --ipdb-failures


.PHONY: cover cover_report manage migrate shell shell_plus serve serve_plus syncdb syncdb_migrate schema schema_initial test test_ipdb
3 changes: 2 additions & 1 deletion requirements/api.txt
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
3 changes: 1 addition & 2 deletions requirements/common.txt
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
2 changes: 2 additions & 0 deletions rna/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class NoteAdminForm(forms.ModelForm):

class Meta:
model = models.Note
fields = '__all__'


class NoteAdmin(admin.ModelAdmin):
Expand All @@ -35,6 +36,7 @@ class ReleaseAdminForm(forms.ModelForm):

class Meta:
model = models.Release
fields = '__all__'


class ReleaseAdmin(admin.ModelAdmin):
Expand Down
146 changes: 0 additions & 146 deletions rna/clients.py

This file was deleted.

3 changes: 1 addition & 2 deletions rna/fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django import forms

from rest_framework.compat import parse_datetime
from django.utils.dateparse import parse_datetime


class ISO8601DateTimeField(forms.DateTimeField):
Expand Down
53 changes: 16 additions & 37 deletions rna/management/commands/rnasync.py
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)
7 changes: 7 additions & 0 deletions rna/middleware.py
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'
Loading

0 comments on commit 25ae9af

Please sign in to comment.