Skip to content

Commit 0cf5786

Browse files
committed
Merge branch 'master' of https://github.com/gthank/readthedocs.org into gthank-master
2 parents 0f6361b + 027f734 commit 0cf5786

File tree

273 files changed

+777
-355
lines changed

Some content is hidden

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

273 files changed

+777
-355
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
language: python
22
python:
3-
- 2.7
3+
- 3.6
44
sudo: false
55
env:
66
- TOX_ENV=py27
7+
- TOX_ENV=py36
78
- TOX_ENV=docs
89
- TOX_ENV=lint
910
- TOX_ENV=eslint

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: 2 additions & 0 deletions
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

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: 1 addition & 0 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

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: 4 additions & 2 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,7 +29,7 @@ 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

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

readthedocs/builds/models.py

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

3+
from __future__ import absolute_import
4+
from builtins import object
35
import logging
46
import re
57
import os.path
@@ -8,6 +10,7 @@
810
from django.core.urlresolvers import reverse
911
from django.conf import settings
1012
from django.db import models
13+
from django.utils.encoding import python_2_unicode_compatible
1114
from django.utils.translation import ugettext_lazy as _, ugettext
1215

1316
from guardian.shortcuts import assign
@@ -33,6 +36,7 @@
3336
log = logging.getLogger(__name__)
3437

3538

39+
@python_2_unicode_compatible
3640
class Version(models.Model):
3741

3842
"""Version of a ``Project``."""
@@ -77,7 +81,7 @@ class Version(models.Model):
7781

7882
objects = VersionManager.from_queryset(VersionQuerySet)()
7983

80-
class Meta:
84+
class Meta(object):
8185
unique_together = [('project', 'slug')]
8286
ordering = ['-verbose_name']
8387
permissions = (
@@ -86,7 +90,7 @@ class Meta:
8690
('view_version', _('View Version')),
8791
)
8892

89-
def __unicode__(self):
93+
def __str__(self):
9094
return ugettext(u"Version %(version)s of %(project)s (%(pk)s)" % {
9195
'version': self.verbose_name,
9296
'project': self.project,
@@ -299,6 +303,7 @@ def get_bitbucket_url(self, docroot, filename, source_suffix='.rst'):
299303
)
300304

301305

306+
@python_2_unicode_compatible
302307
class VersionAlias(models.Model):
303308

304309
"""Alias for a ``Version``."""
@@ -310,14 +315,15 @@ class VersionAlias(models.Model):
310315
blank=True)
311316
largest = models.BooleanField(_('Largest'), default=False)
312317

313-
def __unicode__(self):
318+
def __str__(self):
314319
return ugettext(u"Alias for %(project)s: %(from)s -> %(to)s" % {
315320
'project': self.project,
316321
'from': self.from_slug,
317322
'to': self.to_slug,
318323
})
319324

320325

326+
@python_2_unicode_compatible
321327
class Build(models.Model):
322328

323329
"""Build data."""
@@ -348,14 +354,14 @@ class Build(models.Model):
348354

349355
objects = BuildQuerySet.as_manager()
350356

351-
class Meta:
357+
class Meta(object):
352358
ordering = ['-date']
353359
get_latest_by = 'date'
354360
index_together = [
355361
['version', 'state', 'type']
356362
]
357363

358-
def __unicode__(self):
364+
def __str__(self):
359365
return ugettext(u"Build %(project)s for %(usernames)s (%(pk)s)" % {
360366
'project': self.project,
361367
'usernames': ' '.join(self.project.users.all()
@@ -395,6 +401,7 @@ def failed(self):
395401
return not self.successful
396402

397403

404+
@python_2_unicode_compatible
398405
class BuildCommandResult(BuildCommandResultMixin, models.Model):
399406

400407
"""Build command for a ``Build``."""
@@ -410,13 +417,13 @@ class BuildCommandResult(BuildCommandResultMixin, models.Model):
410417
start_time = models.DateTimeField(_('Start time'))
411418
end_time = models.DateTimeField(_('End time'))
412419

413-
class Meta:
420+
class Meta(object):
414421
ordering = ['start_time']
415422
get_latest_by = 'start_time'
416423

417424
objects = RelatedBuildQuerySet.as_manager()
418425

419-
def __unicode__(self):
426+
def __str__(self):
420427
return (ugettext(u'Build command {pk} for build {build}')
421428
.format(pk=self.pk, build=self.build))
422429

readthedocs/builds/signals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Build signals"""
22

3+
from __future__ import absolute_import
34
import django.dispatch
45

56

readthedocs/builds/urls.py

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

3+
from __future__ import absolute_import
34
from django.conf.urls import url
45

56
from .views import builds_redirect_detail, builds_redirect_list

readthedocs/builds/utils.py

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

3+
from __future__ import absolute_import
34
import re
45

56

readthedocs/builds/version_slug.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
another number would be confusing.
1717
"""
1818

19+
from __future__ import absolute_import
20+
from builtins import range
1921
import math
2022
import re
2123
import string
2224
from operator import truediv
2325
from django.db import models
2426
from django.utils.encoding import force_text
27+
from six.moves import range
2528

2629

2730
# Regex breakdown:
@@ -89,15 +92,15 @@ def uniquifying_suffix(self, iteration):
8992
uniquifying_suffix(26) == '_ba'
9093
uniquifying_suffix(52) == '_ca'
9194
"""
92-
alphabet = string.lowercase
95+
alphabet = string.ascii_lowercase
9396
length = len(alphabet)
9497
if iteration == 0:
9598
power = 0
9699
else:
97100
power = int(math.log(iteration, length))
98101
current = iteration
99102
suffix = ''
100-
for exp in reversed(range(0, power + 1)):
103+
for exp in reversed(list(range(0, power + 1))):
101104
digit = int(truediv(current, length ** exp))
102105
suffix += alphabet[digit]
103106
current = current % length ** exp

readthedocs/builds/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Views for builds app."""
22

3+
from __future__ import absolute_import
4+
from builtins import object
35
import logging
46

57
from django.shortcuts import get_object_or_404

readthedocs/cdn/purge.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
"""Utility to purge MaxCDN files, if configured."""
22

3+
from __future__ import absolute_import
4+
from builtins import range
35
import logging
46

57
from django.conf import settings
8+
from six.moves import range
69

710
log = logging.getLogger(__name__)
811

@@ -14,7 +17,7 @@
1417

1518
def chunks(in_list, chunk_size):
1619
"""Yield successive n-sized chunks from l."""
17-
for i in xrange(0, len(in_list), chunk_size):
20+
for i in range(0, len(in_list), chunk_size):
1821
yield in_list[i:i + chunk_size]
1922

2023
if CDN_USERNAME and CDN_KEY and CDN_SECRET and CDN_SERVICE == 'maxcdn':

readthedocs/comments/admin.py

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

3+
from __future__ import absolute_import
34
from django.contrib import admin
45
from .models import DocumentNode, DocumentComment, NodeSnapshot
56

readthedocs/comments/backend.py

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

3+
from __future__ import absolute_import
34
import json
45

56
from django.core import serializers

readthedocs/comments/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

0 commit comments

Comments
 (0)