Skip to content

Commit 6a0f5d9

Browse files
authored
Merge branch 'master' into patch-1
2 parents e4ddac9 + d14cea0 commit 6a0f5d9

File tree

20 files changed

+77
-83
lines changed

20 files changed

+77
-83
lines changed

docs/ethical-advertising.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ Fill out your information and we'll get in touch.
145145
<input type="text" name="_gotcha" style="display:none" />
146146
</form>
147147

148+
149+
150+
Community Ads
151+
-------------
152+
153+
There are a large number of projects that we care about in the software ecosystem. A large number of them operate like we have for the past 6 years, with almost no income. Our new Community Ads program will highlight some of these projects each month.
154+
155+
We'll show 10% of our ad inventory each month to support an open source project that we care about.
156+
`Send us an email <mailto:[email protected]>`_ to be considered for our Community Ads program.
157+
148158
.. _opt-out:
149159

150160
Opting Out

docs/user-defined-redirects.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,3 @@ This means that redirects will only happen in the case of a *404 File Not Found*
106106
In the future we might implement redirect logic in Javascript,
107107
but this first version is only implemented in the 404 handlers.
108108

109-
110-
.. Feature Requests
111-
112-

readthedocs/builds/syncers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from django.conf import settings
1616

1717
from readthedocs.core.utils.extend import SettingsOverrideObject
18+
from readthedocs.core.utils import safe_makedirs
1819

1920

2021
log = logging.getLogger(__name__)
@@ -127,8 +128,9 @@ def copy(cls, path, target, host, is_file=False, **__):
127128
sync_user = getattr(settings, 'SYNC_USER', getpass.getuser())
128129
if not is_file:
129130
path += "/"
130-
log.info("Local Copy %s to %s", path, target)
131-
os.makedirs(target)
131+
log.info("Remote Pull %s to %s", path, target)
132+
if not is_file and not os.path.exists(target):
133+
safe_makedirs(target)
132134
# Add a slash when copying directories
133135
sync_cmd = "rsync -e 'ssh -T' -av --delete {user}@{host}:{path} {target}".format(
134136
host=host,

readthedocs/core/signals.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
"""Signal handling for core app."""
22

33
from __future__ import absolute_import
4+
45
import logging
56

6-
from django.dispatch import Signal
77
from corsheaders import signals
8+
from django.dispatch import Signal
9+
from future.backports.urllib.parse import urlparse
810

911
from readthedocs.projects.models import Project, Domain
1012

11-
from future import standard_library
12-
standard_library.install_aliases()
13-
from urllib.parse import urlparse # noqa
1413

1514
log = logging.getLogger(__name__)
1615

readthedocs/core/templatetags/core_tags.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77
from builtins import str # pylint: disable=redefined-builtin
88
from django import template
99
from django.conf import settings
10-
from django.utils.safestring import mark_safe
1110
from django.utils.encoding import force_bytes, force_text
11+
from django.utils.safestring import mark_safe
12+
from future.backports.urllib.parse import urlencode
1213

13-
from readthedocs.projects.models import Project
1414
from readthedocs.core.resolver import resolve
15-
16-
from future import standard_library
17-
standard_library.install_aliases()
18-
import urllib.request, urllib.parse, urllib.error # noqa
15+
from readthedocs.projects.models import Project
1916

2017

2118
register = template.Library()
@@ -29,7 +26,7 @@ def gravatar(email, size=48):
2926
render an img tag with the hashed up bits needed for leetness
3027
omgwtfstillreading
3128
"""
32-
url = "http://www.gravatar.com/avatar.php?%s" % urllib.parse.urlencode({
29+
url = "http://www.gravatar.com/avatar.php?%s" % urlencode({
3330
'gravatar_id': hashlib.md5(email).hexdigest(),
3431
'size': str(size)
3532
})

readthedocs/core/utils/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@
1313
from django.utils.functional import allow_lazy
1414
from django.utils.safestring import SafeText, mark_safe
1515
from django.utils.text import slugify as slugify_base
16+
from future.backports.urllib.parse import urlparse
1617

18+
from ..tasks import send_email_task
1719
from readthedocs.builds.constants import LATEST
1820
from readthedocs.doc_builder.constants import DOCKER_LIMITS
19-
from ..tasks import send_email_task
20-
21-
from future import standard_library # pylint: disable=wrong-import-order
22-
standard_library.install_aliases()
23-
from urllib.parse import urlparse # noqa
2421

2522

2623
log = logging.getLogger(__name__)

readthedocs/doc_builder/backends/mkdocs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def append_conf(self, **__):
100100
if 'theme_dir' not in user_config and self.use_theme:
101101
user_config['theme_dir'] = TEMPLATE_DIR
102102

103-
yaml.dump(
103+
yaml.safe_dump(
104104
user_config,
105105
open(os.path.join(self.root_path, 'mkdocs.yml'), 'w')
106106
)
@@ -187,7 +187,7 @@ def build(self):
187187
)
188188
if user_config['theme_dir'] == TEMPLATE_DIR:
189189
del user_config['theme_dir']
190-
yaml.dump(
190+
yaml.safe_dump(
191191
user_config,
192192
open(os.path.join(self.root_path, 'mkdocs.yml'), 'w')
193193
)

readthedocs/doc_builder/python_environments.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,22 @@ def setup_base(self):
115115
def install_core_requirements(self):
116116
"""Install basic Read the Docs requirements into the virtualenv."""
117117
requirements = [
118-
'sphinx==1.5.3',
119118
'Pygments==2.2.0',
120119
'setuptools==28.8.0',
121120
'docutils==0.13.1',
122-
'mkdocs==0.15.0',
123121
'mock==1.0.1',
124122
'pillow==2.6.1',
125-
'readthedocs-sphinx-ext<0.6',
126-
'sphinx-rtd-theme<0.3',
127123
'alabaster>=0.7,<0.8,!=0.7.5',
128124
'commonmark==0.5.4',
129125
'recommonmark==0.4.0',
130126
]
131127

128+
if self.project.document_type == 'mkdocs':
129+
requirements.append('mkdocs==0.15.0')
130+
else:
131+
requirements.extend(['sphinx==1.5.3', 'sphinx-rtd-theme<0.3',
132+
'readthedocs-sphinx-ext<0.6'])
133+
132134
cmd = [
133135
'python',
134136
self.venv_bin(filename='pip'),
@@ -211,13 +213,21 @@ def install_core_requirements(self):
211213
"""Install basic Read the Docs requirements into the Conda env."""
212214
# Use conda for requirements it packages
213215
requirements = [
214-
'sphinx',
215216
'mock',
216217
'pillow',
217-
'sphinx_rtd_theme',
218-
'mkdocs',
219218
]
220219

220+
# Install pip-only things.
221+
pip_requirements = [
222+
'recommonmark',
223+
]
224+
225+
if self.project.documentation_type == 'mkdocs':
226+
pip_requirements.append('mkdocs')
227+
else:
228+
pip_requirements.append('readthedocs-sphinx-ext')
229+
requirements.extend(['sphinx', 'sphinx-rtd-theme'])
230+
221231
cmd = [
222232
'conda',
223233
'install',
@@ -230,12 +240,6 @@ def install_core_requirements(self):
230240
*cmd
231241
)
232242

233-
# Install pip-only things.
234-
pip_requirements = [
235-
'readthedocs-sphinx-ext',
236-
'recommonmark',
237-
]
238-
239243
pip_cmd = [
240244
'python',
241245
self.venv_bin(filename='pip'),

readthedocs/donate/signals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def is_gold_project(project):
163163

164164
def is_community_only(user, project):
165165
"""Return True is this project or user should only be shown community ads"""
166-
if user.is_authenticated() and user.profile.as_opt_out:
166+
if user.is_authenticated() and not user.profile.allow_ads:
167167
return True
168168
if not project.allow_promos:
169169
return True

readthedocs/oauth/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def attach_webhook(project, request=None):
5555
request,
5656
_('No accounts available to set webhook on. '
5757
'Please connect your {network} account.'.format(
58-
network=service.adapter().get_provider().name
58+
network=service.adapter(request).get_provider().name
5959
))
6060
)
6161
return False

readthedocs/projects/forms.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
from django.conf import settings
1010
from django.contrib.auth.models import User
1111
from django.template.loader import render_to_string
12-
from django.utils.translation import ugettext_lazy as _
1312
from django.utils.safestring import mark_safe
13+
from django.utils.translation import ugettext_lazy as _
14+
from future.backports.urllib.parse import urlparse
1415
from guardian.shortcuts import assign
1516
from textclassifier.validators import ClassifierValidator
1617

1718
from readthedocs.builds.constants import TAG
18-
from readthedocs.core.permissions import AdminPermission
1919
from readthedocs.core.utils import trigger_build, slugify
2020
from readthedocs.integrations.models import Integration
2121
from readthedocs.oauth.models import RemoteRepository
@@ -25,10 +25,6 @@
2525
Project, ProjectRelationship, EmailHook, WebHook, Domain)
2626
from readthedocs.redirects.models import Redirect
2727

28-
from future import standard_library
29-
standard_library.install_aliases()
30-
from urllib.parse import urlparse # noqa
31-
3228

3329
class ProjectForm(forms.ModelForm):
3430

readthedocs/projects/migrations/0010_migrate_domain_data.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import (absolute_import, print_function, unicode_literals)
33

4-
from future import standard_library
5-
standard_library.install_aliases()
6-
7-
import urllib.parse
8-
94
from django.db import models, migrations
5+
from future.backports.urllib.parse import urlparse
106

117
import readthedocs.core.validators
128

@@ -20,7 +16,7 @@ def migrate_url(apps, schema_editor):
2016
project=domain.project.slug))
2117
domain.delete()
2218
continue
23-
parsed = urllib.parse(domain.url)
19+
parsed = urlparse(domain.url)
2420
if parsed.scheme or parsed.netloc:
2521
domain_string = parsed.netloc
2622
else:

readthedocs/projects/models.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from django.db import models
1414
from django.utils.encoding import python_2_unicode_compatible
1515
from django.utils.translation import ugettext_lazy as _
16+
from future.backports.urllib.parse import urlparse # noqa
1617
from guardian.shortcuts import assign
1718
from taggit.managers import TaggableManager
1819

@@ -37,10 +38,6 @@
3738
from readthedocs.vcs_support.backends import backend_cls
3839
from readthedocs.vcs_support.utils import Lock, NonBlockingLock
3940

40-
from future import standard_library
41-
standard_library.install_aliases()
42-
from urllib.parse import urlparse # noqa
43-
4441

4542
log = logging.getLogger(__name__)
4643

readthedocs/projects/tasks.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,20 +918,32 @@ def clear_artifacts(version_pk):
918918
clear_html_artifacts(version)
919919

920920

921+
@task()
921922
def clear_pdf_artifacts(version):
923+
if isinstance(version, int):
924+
version = Version.objects.get(pk=version)
922925
remove_dir(version.project.get_production_media_path(
923926
type_='pdf', version_slug=version.slug))
924927

925928

929+
@task()
926930
def clear_epub_artifacts(version):
931+
if isinstance(version, int):
932+
version = Version.objects.get(pk=version)
927933
remove_dir(version.project.get_production_media_path(
928934
type_='epub', version_slug=version.slug))
929935

930936

937+
@task()
931938
def clear_htmlzip_artifacts(version):
939+
if isinstance(version, int):
940+
version = Version.objects.get(pk=version)
932941
remove_dir(version.project.get_production_media_path(
933942
type_='htmlzip', version_slug=version.slug))
934943

935944

945+
@task()
936946
def clear_html_artifacts(version):
947+
if isinstance(version, int):
948+
version = Version.objects.get(pk=version)
937949
remove_dir(version.project.rtd_build_path(version=version.slug))

readthedocs/rtd_tests/tests/test_post_commit_hooks.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
from __future__ import absolute_import
2-
from future import standard_library
3-
standard_library.install_aliases()
2+
43
import json
54
import logging
6-
from urllib.parse import urlencode
75

86
import mock
9-
from django_dynamic_fixture import get
107
from django.test import TestCase
8+
from django_dynamic_fixture import get
9+
from future.backports.urllib.parse import urlencode
1110

1211
from readthedocs.builds.models import Version
1312
from readthedocs.projects.models import Project
14-
from readthedocs.projects import tasks
13+
1514

1615
log = logging.getLogger(__name__)
1716

readthedocs/urls.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,8 @@
2626

2727
admin.autodiscover()
2828

29-
if 'readthedocs.donate' in settings.INSTALLED_APPS:
30-
handler404 = 'readthedocs.donate.views.promo_404'
31-
handler500 = 'readthedocs.donate.views.promo_500'
32-
else:
33-
handler404 = 'readthedocs.core.views.server_error_404'
34-
handler500 = 'readthedocs.core.views.server_error_500'
29+
handler404 = 'readthedocs.core.views.server_error_404'
30+
handler500 = 'readthedocs.core.views.server_error_500'
3531

3632
basic_urls = [
3733
url(r'^$', HomepageView.as_view(), name='homepage'),

readthedocs/vcs_support/backends/bzr.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
import re
77

88
from builtins import bytes, str # pylint: disable=redefined-builtin
9+
from six import StringIO
10+
911
from readthedocs.projects.exceptions import ProjectImportError
1012
from readthedocs.vcs_support.base import BaseVCS, VCSVersion
1113

12-
from future import standard_library
13-
standard_library.install_aliases()
14-
from io import StringIO # noqa
15-
1614

1715
class Backend(BaseVCS):
1816

readthedocs/vcs_support/backends/git.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22

33
from __future__ import absolute_import
44

5-
import re
6-
import logging
75
import csv
6+
import logging
87
import os
8+
import re
9+
10+
from builtins import str
11+
from six import StringIO
912

10-
from builtins import bytes, str # pylint: disable=redefined-builtin
1113
from readthedocs.projects.exceptions import ProjectImportError
1214
from readthedocs.vcs_support.base import BaseVCS, VCSVersion
1315

14-
from future import standard_library
15-
standard_library.install_aliases()
16-
from io import StringIO # noqa
17-
1816

1917
log = logging.getLogger(__name__)
2018

0 commit comments

Comments
 (0)