Skip to content

Commit 05f20b4

Browse files
authored
Merge branch 'master' into broadcast-fixes
2 parents c38a43c + a4cd571 commit 05f20b4

Some content is hidden

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

72 files changed

+386
-318
lines changed

.travis.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
language: python
22
python:
3-
- 3.6
3+
- 2.7
4+
- 3.6
45
sudo: false
5-
env:
6-
- TOX_ENV=py27
7-
- TOX_ENV=py36
8-
- TOX_ENV=docs
9-
- TOX_ENV=lint
10-
- 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
1116
cache:
1217
directories:
1318
- ~/.cache/pip
1419
- ~/.nvm/nvm.sh
1520
install:
16-
- pip install tox
17-
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
18-
- source ~/.nvm/nvm.sh
19-
- nvm install --lts
20-
- nvm use --lts
21-
- npm install
22-
- 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
2328
script:
24-
- tox -e $TOX_ENV
29+
- tox
2530
notifications:
2631
slack:
2732
rooms:

docs/alternate_domains.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Alternate Domains
22
=================
33

4-
Read the Docs supports a number of custom domains for your convenience. Shorter urls make everyone happy, and we like making people happy!
4+
Read the Docs supports a number of custom domains for your convenience. Shorter URLs make everyone happy, and we like making people happy!
55

66
Subdomain Support
77
------------------

docs/automatic-redirects.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For example::
1414
pip.readthedocs.io -> pip.readthedocs.io/en/latest/
1515
www.pip-installer.org -> www.pip-installer.org/en/latest
1616

17-
This only works for the root url, not for internal pages. It's designed to redirect people from http://pip.readthedocs.io/ to the default version of your documentation, since serving up a 404 here would be a pretty terrible user experience. (If your "develop" branch was designated as your default version, then it would redirect to http://pip.readthedocs.io/en/develop.) But, it's not a universal redirecting solution. So, for example, a link to an internal page like http://pip.readthedocs.io/usage.html doesn't redirect to http://pip.readthedocs.io/en/latest/usage.html.
17+
This only works for the root URL, not for internal pages. It's designed to redirect people from http://pip.readthedocs.io/ to the default version of your documentation, since serving up a 404 here would be a pretty terrible user experience. (If your "develop" branch was designated as your default version, then it would redirect to http://pip.readthedocs.io/en/develop.) But, it's not a universal redirecting solution. So, for example, a link to an internal page like http://pip.readthedocs.io/usage.html doesn't redirect to http://pip.readthedocs.io/en/latest/usage.html.
1818

1919
The reasoning behind this is that RTD organizes the URLs for docs so that multiple translations and multiple versions of your docs can be organized logically and consistently for all projects that RTD hosts. For the way that RTD views docs, http://pip.readthedocs.io/en/latest/ is the root directory for your default documentation in English, not http://pip.readthedocs.io/. Just like http://pip.readthedocs.io/en/develop/ is the root for your development documentation in English.
2020

docs/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Importing existing docs
164164
^^^^^^^^^^^^^^^^^^^^^^^
165165

166166
The other side of `readthedocs.org <http://readthedocs.org>`_ is hosting the
167-
docs you've already built. Simply provide us with the clone url to your repo,
167+
docs you've already built. Simply provide us with the clone URL to your repo,
168168
we'll pull your code, extract your docs, and build them! We make available
169169
a post-commit webhook that can be configured to update the docs on our site
170170
whenever you commit to your repo, effectively letting you 'set it and forget it'.

docs/team.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Members
3434

3535
* `Eric Holscher <https://github.com/ericholscher>`_ (Pacific Time)
3636
* `Anthony Johnson <https://github.com/agjohnson>`_ (Pacific Time)
37-
* `edunham <https://github.com/edunham>`_
37+
* `Manuel Kaufmann <https://github.com/humitos>`_ (Central Time)
3838
* Your Name Here
3939

4040
Feel free to ask any of us if you have questions or want to join!
@@ -64,6 +64,7 @@ Members
6464

6565
* `Eric Holscher <https://github.com/ericholscher>`_ (Pacific Time)
6666
* `Anthony Johnson <https://github.com/agjohnson>`_ (Pacific Time)
67+
* `Matt Robenolt <https://github.com/mattrobenolt>`_ (Pacific Time)
6768
* Your Name Here
6869

6970
Feel free to ask any of us if you have questions or want to join!

prospector-more.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
11
inherits: prospector
22

3-
strictness: medium
3+
strictness: high
44

55
ignore-paths:
6-
- restapi/
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
737

838
pylint:
939
options:

readthedocs/api/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def is_authenticated(self, request, **kwargs):
162162

163163

164164
class EnhancedModelResource(ModelResource):
165-
def obj_get_list(self, request=None, *_, **kwargs):
165+
def obj_get_list(self, request=None, *_, **kwargs): # pylint: disable=arguments-differ
166166
"""
167167
A ORM-specific implementation of ``obj_get_list``.
168168

readthedocs/bookmarks/views.py

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
class BookmarkExistsView(View):
2626

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

3131
def get(self, request):
3232
return HttpResponse(
@@ -81,8 +81,8 @@ class BookmarkListView(ListView):
8181
model = Bookmark
8282

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

8787
def get_queryset(self):
8888
return Bookmark.objects.filter(user=self.request.user)
@@ -94,8 +94,8 @@ class BookmarkAddView(View):
9494

9595
@method_decorator(login_required)
9696
@method_decorator(csrf_exempt)
97-
def dispatch(self, *args, **kwargs):
98-
return super(BookmarkAddView, self).dispatch(*args, **kwargs)
97+
def dispatch(self, request, *args, **kwargs):
98+
return super(BookmarkAddView, self).dispatch(request, *args, **kwargs)
9999

100100
def get(self, request):
101101
return HttpResponse(
@@ -157,8 +157,8 @@ class BookmarkRemoveView(View):
157157

158158
@method_decorator(login_required)
159159
@method_decorator(csrf_exempt)
160-
def dispatch(self, *args, **kwargs):
161-
return super(BookmarkRemoveView, self).dispatch(*args, **kwargs)
160+
def dispatch(self, request, *args, **kwargs):
161+
return super(BookmarkRemoveView, self).dispatch(request, *args, **kwargs)
162162

163163
def get(self, request, *args, **kwargs):
164164
return render_to_response(
@@ -176,30 +176,29 @@ def post(self, request, *args, **kwargs):
176176
bookmark = get_object_or_404(Bookmark, pk=kwargs['bookmark_pk'])
177177
bookmark.delete()
178178
return HttpResponseRedirect(reverse('bookmark_list'))
179-
else:
180-
try:
181-
post_json = json.loads(request.body)
182-
project = Project.objects.get(slug=post_json['project'])
183-
version = project.versions.get(slug=post_json['version'])
184-
url = post_json['url']
185-
page = post_json['page']
186-
except KeyError:
187-
return HttpResponseBadRequest(
188-
json.dumps({'error': "Invalid parameters"})
189-
)
190-
191-
bookmark = get_object_or_404(
192-
Bookmark,
193-
user=request.user,
194-
url=url,
195-
project=project,
196-
version=version,
197-
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"})
198188
)
199-
bookmark.delete()
200189

201-
return HttpResponse(
202-
json.dumps({'removed': True}),
203-
status=200,
204-
content_type="application/json"
205-
)
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/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class Meta(object):
3333
model = Version
3434
fields = ['active', 'privacy_level', 'tags']
3535

36-
def save(self, *args, **kwargs):
37-
obj = super(VersionForm, self).save(*args, **kwargs)
36+
def save(self, commit=True):
37+
obj = super(VersionForm, self).save(commit=commit)
3838
if obj.active and not obj.built and not obj.uploaded:
3939
trigger_build(project=obj.project, version=obj)
4040
return obj

readthedocs/builds/models.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ def commit_name(self):
110110
if self.slug == LATEST:
111111
if self.project.default_branch:
112112
return self.project.default_branch
113-
else:
114-
return self.project.vcs_repo().fallback_branch
113+
return self.project.vcs_repo().fallback_branch
115114

116115
if self.slug == STABLE:
117116
if self.type == BRANCH:
@@ -148,7 +147,7 @@ def get_absolute_url(self):
148147
private = self.privacy_level == PRIVATE
149148
return self.project.get_docs_url(version_slug=self.slug, private=private)
150149

151-
def save(self, *args, **kwargs):
150+
def save(self, *args, **kwargs): # pylint: disable=arguments-differ
152151
"""Add permissions to the Version for all owners on save."""
153152
from readthedocs.projects import tasks
154153
obj = super(Version, self).save(*args, **kwargs)
@@ -161,7 +160,7 @@ def save(self, *args, **kwargs):
161160
broadcast(type='app', task=tasks.symlink_project, args=[self.project.pk])
162161
return obj
163162

164-
def delete(self, *args, **kwargs):
163+
def delete(self, *args, **kwargs): # pylint: disable=arguments-differ
165164
from readthedocs.projects import tasks
166165
log.info('Removing files for version %s', self.slug)
167166
broadcast(type='app', task=tasks.clear_artifacts, args=[self.pk])

readthedocs/builds/version_slug.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
"""
1818

1919
from __future__ import absolute_import
20-
from builtins import range
20+
2121
import math
2222
import re
2323
import string
2424
from operator import truediv
25+
2526
from django.db import models
2627
from django.utils.encoding import force_text
27-
from six.moves import range
28+
from builtins import range
2829

2930

3031
# Regex breakdown:

readthedocs/cdn/purge.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""Utility to purge MaxCDN files, if configured."""
22

33
from __future__ import absolute_import
4-
from builtins import range
4+
55
import logging
66

77
from django.conf import settings
8-
from six.moves import range
8+
from builtins import range
9+
910

1011
log = logging.getLogger(__name__)
1112

readthedocs/comments/models.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def from_hash(self, version_slug, page, node_hash, project_slug=None):
3636
if project_slug:
3737
snapshots = snapshots.filter(node__project__slug=project_slug)
3838

39-
if len(snapshots) == 0:
39+
if not snapshots.exists():
4040
raise DocumentNode.DoesNotExist(
4141
"No node exists on %s with a current hash of %s" % (
4242
page, node_hash))
4343

44-
if len(snapshots) == 1:
44+
if snapshots.count() == 1:
4545
# If we have found only one snapshot, we know we have the correct node.
4646
node = snapshots[0].node
4747
else:
@@ -89,22 +89,20 @@ def latest_commit(self):
8989
def visible_comments(self):
9090
if not self.project.comment_moderation:
9191
return self.comments.all()
92-
else:
93-
# non-optimal SQL warning.
94-
decisions = ModerationAction.objects.filter(
95-
comment__node=self,
96-
decision=1,
97-
date__gt=self.snapshots.latest().date
98-
)
99-
valid_comments = self.comments.filter(moderation_actions__in=decisions).distinct()
100-
return valid_comments
92+
# non-optimal SQL warning.
93+
decisions = ModerationAction.objects.filter(
94+
comment__node=self,
95+
decision=1,
96+
date__gt=self.snapshots.latest().date
97+
)
98+
valid_comments = self.comments.filter(moderation_actions__in=decisions).distinct()
99+
return valid_comments
101100

102101
def update_hash(self, new_hash, commit):
103102
latest_snapshot = self.snapshots.latest()
104103
if latest_snapshot.hash == new_hash and latest_snapshot.commit == commit:
105104
return latest_snapshot
106-
else:
107-
return self.snapshots.create(hash=new_hash, commit=commit)
105+
return self.snapshots.create(hash=new_hash, commit=commit)
108106

109107

110108
class DocumentNodeSerializer(serializers.ModelSerializer):
@@ -190,8 +188,7 @@ def has_been_approved_since_most_recent_node_change(self):
190188
# If we do have an approval action which is newer than the most recent change,
191189
# we'll return True or False commensurate with its "approved" attribute.
192190
return latest_moderation_action.approved()
193-
else:
194-
return False
191+
return False
195192

196193
def is_orphaned(self):
197194
raise NotImplementedError('TODO')

readthedocs/comments/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def get_queryset(self):
185185
return queryset
186186

187187
@method_decorator(login_required)
188-
def create(self, request):
188+
def create(self, request, *args, **kwargs):
189189
project = Project.objects.get(slug=request.data['project'])
190190
comment = project.add_comment(version_slug=request.data['version'],
191191
page=request.data['document_page'],

readthedocs/core/forms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ def __init__(self, *args, **kwargs):
3232
except AttributeError:
3333
pass
3434

35-
def save(self, *args, **kwargs):
35+
def save(self, commit=True):
3636
first_name = self.cleaned_data.pop('first_name', None)
3737
last_name = self.cleaned_data.pop('last_name', None)
38-
profile = super(UserProfileForm, self).save(*args, **kwargs)
39-
if kwargs.get('commit', True):
38+
profile = super(UserProfileForm, self).save(commit=commit)
39+
if commit:
4040
user = profile.user
4141
user.first_name = first_name
4242
user.last_name = last_name

0 commit comments

Comments
 (0)