Skip to content

Commit a4cd571

Browse files
committed
Merge branch 'gthank-master'
2 parents 4cddf5b + 85f4b71 commit a4cd571

File tree

275 files changed

+1032
-576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+1032
-576
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ public_*
4040
private_*
4141
.rope_project/
4242
readthedocs/htmlcov
43+
tags

.travis.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
language: python
22
python:
3-
- 2.7
3+
- 2.7
4+
- 3.6
45
sudo: false
5-
env:
6-
- TOX_ENV=py27
7-
- TOX_ENV=docs
8-
- TOX_ENV=lint
9-
- TOX_ENV=eslint
6+
matrix:
7+
include:
8+
- python: 2.7
9+
env: TOXENV=docs
10+
- python: 2.7
11+
env: TOXENV=lint
12+
- python: 2.7
13+
env: TOXENV=eslint
14+
script:
15+
- tox
1016
cache:
1117
directories:
1218
- ~/.cache/pip
1319
- ~/.nvm/nvm.sh
1420
install:
15-
- pip install tox
16-
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
17-
- source ~/.nvm/nvm.sh
18-
- nvm install --lts
19-
- nvm use --lts
20-
- npm install
21-
- bower install
21+
- pip install tox-travis
22+
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
23+
- source ~/.nvm/nvm.sh
24+
- nvm install --lts
25+
- nvm use --lts
26+
- npm install
27+
- bower install
2228
script:
23-
- tox -e $TOX_ENV
29+
- tox
2430
notifications:
2531
slack:
2632
rooms:

prospector-more.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
inherits: prospector
22

3-
strictness: medium
3+
strictness: high
4+
5+
ignore-paths:
6+
- constants.py
7+
- urls.py
8+
- wsgi.py
9+
- acl
10+
- api
11+
- betterversion
12+
- bookmarks
13+
- builds
14+
- cdn
15+
- comments
16+
- core
17+
- djangome
18+
- doc_builder
19+
- donate
20+
- gold
21+
- integrations
22+
- locale
23+
- notifications
24+
- oauth
25+
- payments
26+
- privacy
27+
- profiles
28+
- projects
29+
- redirects
30+
- restapi
31+
- rtd_tests
32+
- search
33+
- settings
34+
- tastyapi
35+
- templates
36+
- vcs_support
437

538
pylint:
639
options:

readthedocs/api/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""API resources"""
2+
from __future__ import absolute_import
3+
from builtins import object
24
import logging
35
import json
46
import redis
@@ -95,7 +97,7 @@ def sync_versions(self, request, **kwargs):
9597
except Exception as e:
9698
return self.create_response(
9799
request,
98-
{'exception': e.message},
100+
{'exception': str(e)},
99101
response_class=HttpApplicationError,
100102
)
101103
return self.create_response(request, deleted_versions)

readthedocs/api/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Slumber API client"""
2+
from __future__ import absolute_import
23
import logging
34

45
from slumber import API

readthedocs/api/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Utility classes for api module"""
2+
from __future__ import absolute_import
3+
from builtins import object
24
import logging
35

46
from django.core.paginator import Paginator, InvalidPage
@@ -160,7 +162,7 @@ def is_authenticated(self, request, **kwargs):
160162

161163

162164
class EnhancedModelResource(ModelResource):
163-
def obj_get_list(self, request=None, *_, **kwargs):
165+
def obj_get_list(self, request=None, *_, **kwargs): # pylint: disable=arguments-differ
164166
"""
165167
A ORM-specific implementation of ``obj_get_list``.
166168

readthedocs/bookmarks/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Django admin interface for `~bookmarks.models.Bookmark`."""
22

3+
from __future__ import absolute_import
34
from django.contrib import admin
45
from readthedocs.bookmarks.models import Bookmark
56

readthedocs/bookmarks/migrations/0001_initial.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4+
from __future__ import absolute_import
45
from django.db import models, migrations
56
from django.conf import settings
67

readthedocs/bookmarks/models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
"""Models for the bookmarks app."""
22

3+
from __future__ import absolute_import
4+
from builtins import object
35
from django.db import models
46
from django.contrib.auth.models import User
7+
from django.utils.encoding import python_2_unicode_compatible
58
from django.utils.translation import ugettext_lazy as _, ugettext
69

710
from readthedocs.builds.models import Version
811
from readthedocs.projects.models import Project
912

1013

14+
@python_2_unicode_compatible
1115
class Bookmark(models.Model):
1216

1317
"""A user's bookmark of a ``Project``, ``Version``, and page."""
@@ -23,11 +27,11 @@ class Bookmark(models.Model):
2327
date = models.DateTimeField(_('Date'), auto_now_add=True)
2428
url = models.CharField(_('URL'), max_length=255, null=True, blank=True)
2529

26-
class Meta:
30+
class Meta(object):
2731
ordering = ['-date']
2832
unique_together = ('user', 'project', 'version', 'page')
2933

30-
def __unicode__(self):
34+
def __str__(self):
3135
return ugettext(u"Bookmark %(url)s for %(user)s (%(pk)s)") % {
3236
'url': self.url,
3337
'user': self.user,

readthedocs/bookmarks/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""URL config for the bookmarks app."""
22

3+
from __future__ import absolute_import
34
from django.conf.urls import url
45
from readthedocs.bookmarks.views import BookmarkListView
56
from readthedocs.bookmarks.views import BookmarkAddView, BookmarkRemoveView

readthedocs/bookmarks/views.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Views for the bookmarks app."""
22

3+
from __future__ import absolute_import
34
from django.contrib.auth.decorators import login_required
45
from django.http import HttpResponse, HttpResponseRedirect
56
from django.http import HttpResponseBadRequest
@@ -24,8 +25,8 @@
2425
class BookmarkExistsView(View):
2526

2627
@method_decorator(csrf_exempt)
27-
def dispatch(self, *args, **kwargs):
28-
return super(BookmarkExistsView, self).dispatch(*args, **kwargs)
28+
def dispatch(self, request, *args, **kwargs):
29+
return super(BookmarkExistsView, self).dispatch(request, *args, **kwargs)
2930

3031
def get(self, request):
3132
return HttpResponse(
@@ -80,8 +81,8 @@ class BookmarkListView(ListView):
8081
model = Bookmark
8182

8283
@method_decorator(login_required)
83-
def dispatch(self, *args, **kwargs):
84-
return super(BookmarkListView, self).dispatch(*args, **kwargs)
84+
def dispatch(self, request, *args, **kwargs):
85+
return super(BookmarkListView, self).dispatch(request, *args, **kwargs)
8586

8687
def get_queryset(self):
8788
return Bookmark.objects.filter(user=self.request.user)
@@ -93,8 +94,8 @@ class BookmarkAddView(View):
9394

9495
@method_decorator(login_required)
9596
@method_decorator(csrf_exempt)
96-
def dispatch(self, *args, **kwargs):
97-
return super(BookmarkAddView, self).dispatch(*args, **kwargs)
97+
def dispatch(self, request, *args, **kwargs):
98+
return super(BookmarkAddView, self).dispatch(request, *args, **kwargs)
9899

99100
def get(self, request):
100101
return HttpResponse(
@@ -156,8 +157,8 @@ class BookmarkRemoveView(View):
156157

157158
@method_decorator(login_required)
158159
@method_decorator(csrf_exempt)
159-
def dispatch(self, *args, **kwargs):
160-
return super(BookmarkRemoveView, self).dispatch(*args, **kwargs)
160+
def dispatch(self, request, *args, **kwargs):
161+
return super(BookmarkRemoveView, self).dispatch(request, *args, **kwargs)
161162

162163
def get(self, request, *args, **kwargs):
163164
return render_to_response(
@@ -175,30 +176,29 @@ def post(self, request, *args, **kwargs):
175176
bookmark = get_object_or_404(Bookmark, pk=kwargs['bookmark_pk'])
176177
bookmark.delete()
177178
return HttpResponseRedirect(reverse('bookmark_list'))
178-
else:
179-
try:
180-
post_json = json.loads(request.body)
181-
project = Project.objects.get(slug=post_json['project'])
182-
version = project.versions.get(slug=post_json['version'])
183-
url = post_json['url']
184-
page = post_json['page']
185-
except KeyError:
186-
return HttpResponseBadRequest(
187-
json.dumps({'error': "Invalid parameters"})
188-
)
189-
190-
bookmark = get_object_or_404(
191-
Bookmark,
192-
user=request.user,
193-
url=url,
194-
project=project,
195-
version=version,
196-
page=page
179+
try:
180+
post_json = json.loads(request.body)
181+
project = Project.objects.get(slug=post_json['project'])
182+
version = project.versions.get(slug=post_json['version'])
183+
url = post_json['url']
184+
page = post_json['page']
185+
except KeyError:
186+
return HttpResponseBadRequest(
187+
json.dumps({'error': "Invalid parameters"})
197188
)
198-
bookmark.delete()
199189

200-
return HttpResponse(
201-
json.dumps({'removed': True}),
202-
status=200,
203-
content_type="application/json"
204-
)
190+
bookmark = get_object_or_404(
191+
Bookmark,
192+
user=request.user,
193+
url=url,
194+
project=project,
195+
version=version,
196+
page=page
197+
)
198+
bookmark.delete()
199+
200+
return HttpResponse(
201+
json.dumps({'removed': True}),
202+
status=200,
203+
content_type="application/json"
204+
)

readthedocs/builds/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Django admin interface for `~builds.models.Build` and related models."""
22

3+
from __future__ import absolute_import
34
from django.contrib import admin
45
from readthedocs.builds.models import Build, VersionAlias, Version, BuildCommandResult
56
from guardian.admin import GuardedModelAdmin

readthedocs/builds/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Constants for the builds app."""
22

3+
from __future__ import absolute_import
34
from django.utils.translation import ugettext_lazy as _
45

56
BUILD_STATE_TRIGGERED = 'triggered'

readthedocs/builds/forms.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Django forms for the builds app."""
22

3+
from __future__ import absolute_import
4+
from builtins import object
35
from django import forms
46

57
from readthedocs.builds.models import VersionAlias, Version
@@ -9,7 +11,7 @@
911

1012
class AliasForm(forms.ModelForm):
1113

12-
class Meta:
14+
class Meta(object):
1315
model = VersionAlias
1416
fields = (
1517
'project',
@@ -27,12 +29,12 @@ def __init__(self, instance=None, *args, **kwargs):
2729

2830
class VersionForm(forms.ModelForm):
2931

30-
class Meta:
32+
class Meta(object):
3133
model = Version
3234
fields = ['active', 'privacy_level', 'tags']
3335

34-
def save(self, *args, **kwargs):
35-
obj = super(VersionForm, self).save(*args, **kwargs)
36+
def save(self, commit=True):
37+
obj = super(VersionForm, self).save(commit=commit)
3638
if obj.active and not obj.built and not obj.uploaded:
3739
trigger_build(project=obj.project, version=obj)
3840
return obj

readthedocs/builds/migrations/0001_initial.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4+
from __future__ import absolute_import
45
from django.db import models, migrations
56
import readthedocs.builds.version_slug
67
import taggit.managers

readthedocs/builds/migrations/0002_build_command_initial.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4+
from __future__ import absolute_import
45
from django.db import models, migrations
56
import readthedocs.builds.models
67

0 commit comments

Comments
 (0)