Skip to content

Commit bfb9153

Browse files
committed
Merge branch 'master' into refactor-views-search-analytics
2 parents 41d4768 + a42f5d4 commit bfb9153

File tree

18 files changed

+196
-272
lines changed

18 files changed

+196
-272
lines changed

CHANGELOG.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
Version 3.7.5
2+
-------------
3+
4+
:Date: September 26, 2019
5+
6+
* `@davidfischer <http://github.com/davidfischer>`__: Remove if storage blocks (`#6191 <https://github.com/readthedocs/readthedocs.org/pull/6191>`__)
7+
* `@davidfischer <http://github.com/davidfischer>`__: Update security docs (`#6179 <https://github.com/readthedocs/readthedocs.org/pull/6179>`__)
8+
* `@davidfischer <http://github.com/davidfischer>`__: Add the private spamfighting module to INSTALLED_APPS (`#6177 <https://github.com/readthedocs/readthedocs.org/pull/6177>`__)
9+
* `@davidfischer <http://github.com/davidfischer>`__: Document connected account permissions (`#6172 <https://github.com/readthedocs/readthedocs.org/pull/6172>`__)
10+
* `@stsewd <http://github.com/stsewd>`__: Require login for old redirect (`#6170 <https://github.com/readthedocs/readthedocs.org/pull/6170>`__)
11+
* `@humitos <http://github.com/humitos>`__: Remove old and unused code (`#6167 <https://github.com/readthedocs/readthedocs.org/pull/6167>`__)
12+
* `@stsewd <http://github.com/stsewd>`__: Clean up views (`#6166 <https://github.com/readthedocs/readthedocs.org/pull/6166>`__)
13+
* `@stsewd <http://github.com/stsewd>`__: Update docs for sharing (`#6164 <https://github.com/readthedocs/readthedocs.org/pull/6164>`__)
14+
* `@pyup-bot <http://github.com/pyup-bot>`__: pyup: Scheduled weekly dependency update for week 36 (`#6158 <https://github.com/readthedocs/readthedocs.org/pull/6158>`__)
15+
* `@saadmk11 <http://github.com/saadmk11>`__: Remove PR Builder Project Idea from RTD GSoC Docs (`#6147 <https://github.com/readthedocs/readthedocs.org/pull/6147>`__)
16+
* `@ericholscher <http://github.com/ericholscher>`__: Serialize time in search queries properly (`#6142 <https://github.com/readthedocs/readthedocs.org/pull/6142>`__)
17+
* `@humitos <http://github.com/humitos>`__: Allow to extend DomainCreate view (`#6139 <https://github.com/readthedocs/readthedocs.org/pull/6139>`__)
18+
* `@saadmk11 <http://github.com/saadmk11>`__: Integration Re-sync Bug Fix (`#6124 <https://github.com/readthedocs/readthedocs.org/pull/6124>`__)
19+
* `@stsewd <http://github.com/stsewd>`__: Don't log BuildEnvironmentWarning as error (`#6112 <https://github.com/readthedocs/readthedocs.org/pull/6112>`__)
20+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Add Search Guide (`#6101 <https://github.com/readthedocs/readthedocs.org/pull/6101>`__)
21+
* `@saadmk11 <http://github.com/saadmk11>`__: Add PR Builder guide to docs (`#6093 <https://github.com/readthedocs/readthedocs.org/pull/6093>`__)
22+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Record search queries smartly (`#6088 <https://github.com/readthedocs/readthedocs.org/pull/6088>`__)
23+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Remove 'highlight' URL param from search results (`#6087 <https://github.com/readthedocs/readthedocs.org/pull/6087>`__)
24+
125
Version 3.7.4
226
-------------
327

docs/connected-accounts.rst

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Connecting Your Account
2-
-----------------------
2+
=======================
33

44
If you are going to import repositories from GitHub, Bitbucket, or GitLab,
55
you should connect your Read the Docs account to your repository host first.
@@ -18,3 +18,69 @@ and select `Connected Services <https://readthedocs.org/accounts/social/connecti
1818
From here, you'll be able to connect to your GitHub, Bitbucket or GitLab
1919
account. This process will ask you to authorize a connection to Read the Docs,
2020
that allows us to read information about and clone your repositories.
21+
22+
23+
Permissions for connected accounts
24+
----------------------------------
25+
26+
Read the Docs does not generally ask for write permission to your repositories' code
27+
(with one exception detailed below)
28+
and since we only connect to public repositories we don't need special permissions to read them.
29+
However, we do need permissions for authorizing your account
30+
so that you can login to Read the Docs with your connected account credentials
31+
and to setup :doc:`webhooks`
32+
which allow us to build your documentation on every change to your repository.
33+
34+
35+
GitHub
36+
~~~~~~
37+
38+
Read the Docs requests the following permissions (more precisely, `OAuth scopes`_)
39+
when connecting your Read the Docs account to GitHub.
40+
41+
.. _OAuth scopes: https://developer.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/
42+
43+
Read access to your email address (``user:email``)
44+
We ask for this so you can create a Read the Docs account and login with your GitHub credentials.
45+
46+
Administering webhooks (``admin:repo_hook``)
47+
We ask for this so we can create webhooks on your repositories when you import them into Read the Docs.
48+
This allows us to build the docs when you push new commits.
49+
50+
Read access to your organizations (``read:org``)
51+
We ask for this so we know which organizations you have access to.
52+
This allows you to filter repositories by organization when importing repositories.
53+
54+
Repository status (``repo:status``)
55+
Repository statuses allow Read the Docs to report the status
56+
(eg. passed, failed, pending) of pull requests to GitHub.
57+
This is used for a feature currently in beta testing
58+
that builds documentation on each pull request similar to a continuous integration service.
59+
60+
.. note::
61+
62+
:doc:`Read the Docs for Business </commercial/index>`
63+
asks for one additional permission (``repo``) to allow access to private repositories
64+
and to allow us to setup SSH keys to clone your private repositories.
65+
Unfortunately, this is the permission for read/write control of the repository
66+
but there isn't a more granular permission
67+
that only allows setting up SSH keys for read access.
68+
69+
70+
Bitbucket
71+
~~~~~~~~~
72+
73+
For similar reasons to those above for GitHub, we request permissions for:
74+
75+
* Reading your account information including your email address
76+
* Read access to your team memberships
77+
* Read access to your repositories
78+
* Read and write access to webhooks
79+
80+
GitLab
81+
~~~~~~
82+
83+
Like the others, we request permissions for:
84+
85+
* Reading your account information (``read_user``)
86+
* API access (``api``) which is needed to create webhooks in GitLab

docs/faq.rst

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,14 @@ I get import errors on libraries that depend on C modules
8181
---------------------------------------------------------
8282

8383
.. note::
84-
Another use case for this is when you have a module with a C extension.
8584

86-
This happens because our build system doesn't have the dependencies for building your project. This happens with things like ``libevent``, ``mysql``, and other python packages that depend on C libraries. We can't support installing random C binaries on our system, so there is another way to fix these imports.
85+
Another use case for this is when you have a module with a C extension.
8786

88-
With Sphinx you can use the built-in `autodoc_mock_imports`_ for mocking. Alternatively you can use the mock library by putting the following snippet in your ``conf.py``::
89-
90-
import sys
91-
from unittest.mock import MagicMock
92-
93-
class Mock(MagicMock):
94-
@classmethod
95-
def __getattr__(cls, name):
96-
return MagicMock()
97-
98-
MOCK_MODULES = ['pygtk', 'gtk', 'gobject', 'argparse', 'numpy', 'pandas']
99-
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
100-
101-
You need to replace ``MOCK_MODULES`` with the modules that you want to mock out.
102-
103-
.. Tip:: The library ``unittest.mock`` was introduced on python 3.3. On earlier versions install the ``mock`` library
104-
from PyPI with (ie ``pip install mock``) and replace the above import::
105-
106-
from mock import Mock as MagicMock
87+
This happens because our build system doesn't have the dependencies for building your project.
88+
This happens with things like ``libevent``, ``mysql``, and other python packages that depend on C libraries.
89+
We can't support installing random C binaries on our system, so there is another way to fix these imports.
10790

91+
With Sphinx you can use the built-in `autodoc_mock_imports`_ for mocking.
10892
If such libraries are installed via ``setup.py``, you also will need to remove all the C-dependent libraries from your ``install_requires`` in the RTD environment.
10993

11094
.. _autodoc_mock_imports: http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_mock_imports

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "readthedocs",
3-
"version": "0.0.1",
3+
"version": "3.7.5",
44
"description": "Read the Docs build dependencies",
55
"author": "Anthony Johnson <[email protected]>",
66
"scripts": {

readthedocs/builds/storage.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
from pathlib import Path
33

4+
from django.conf import settings
45
from django.core.exceptions import SuspiciousFileOperation
56
from django.core.files.storage import FileSystemStorage
67
from storages.utils import safe_join, get_available_overwrite_name
@@ -107,7 +108,19 @@ def walk(self, top):
107108

108109
class BuildMediaFileSystemStorage(BuildMediaStorageMixin, FileSystemStorage):
109110

110-
"""Storage subclass that writes build artifacts under MEDIA_ROOT."""
111+
"""Storage subclass that writes build artifacts in PRODUCTION_MEDIA_ARTIFACTS or MEDIA_ROOT."""
112+
113+
def __init__(self, **kwargs):
114+
location = kwargs.pop('location', None)
115+
116+
if not location:
117+
# Mirrors the logic of getting the production media path
118+
if settings.DEFAULT_PRIVACY_LEVEL == 'public' or settings.DEBUG:
119+
location = settings.MEDIA_ROOT
120+
else:
121+
location = settings.PRODUCTION_MEDIA_ARTIFACTS
122+
123+
super().__init__(location)
111124

112125
def get_available_name(self, name, max_length=None):
113126
"""

readthedocs/builds/views.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def post(self, request, project_slug):
5555

5656
version_slug = request.POST.get('version_slug')
5757
version = get_object_or_404(
58-
Version.internal.all(),
59-
project=project,
58+
self._get_versions(project),
6059
slug=version_slug,
6160
)
6261

@@ -79,6 +78,12 @@ def post(self, request, project_slug):
7978
reverse('builds_detail', args=[project.slug, build.pk]),
8079
)
8180

81+
def _get_versions(self, project):
82+
return Version.internal.public(
83+
user=self.request.user,
84+
project=project,
85+
)
86+
8287

8388
class BuildList(BuildBase, BuildTriggerMixin, ListView):
8489

@@ -91,10 +96,7 @@ def get_context_data(self, **kwargs):
9196

9297
context['project'] = self.project
9398
context['active_builds'] = active_builds
94-
context['versions'] = Version.internal.public(
95-
user=self.request.user,
96-
project=self.project,
97-
)
99+
context['versions'] = self._get_versions(self.project)
98100
context['build_qs'] = self.get_queryset()
99101

100102
return context

readthedocs/core/static/core/js/readthedocs-doc-embed.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readthedocs/projects/models.py

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -783,15 +783,12 @@ def has_media(self, type_, version_slug=LATEST, version_type=None):
783783
if os.path.exists(path):
784784
return True
785785

786-
if settings.RTD_BUILD_MEDIA_STORAGE:
787-
storage = get_storage_class(settings.RTD_BUILD_MEDIA_STORAGE)()
788-
storage_path = self.get_storage_path(
789-
type_=type_, version_slug=version_slug,
790-
version_type=version_type
791-
)
792-
return storage.exists(storage_path)
793-
794-
return False
786+
storage = get_storage_class(settings.RTD_BUILD_MEDIA_STORAGE)()
787+
storage_path = self.get_storage_path(
788+
type_=type_, version_slug=version_slug,
789+
version_type=version_type
790+
)
791+
return storage.exists(storage_path)
795792

796793
def has_pdf(self, version_slug=LATEST, version_type=None):
797794
return self.has_media(
@@ -1282,33 +1279,27 @@ def get_processed_json(self):
12821279
https://github.com/rtfd/readthedocs.org/issues/5368
12831280
"""
12841281
file_path = None
1282+
storage = get_storage_class(settings.RTD_BUILD_MEDIA_STORAGE)()
12851283

1286-
if settings.RTD_BUILD_MEDIA_STORAGE:
1287-
storage = get_storage_class(settings.RTD_BUILD_MEDIA_STORAGE)()
1288-
1289-
fjson_paths = []
1290-
basename = os.path.splitext(self.path)[0]
1291-
fjson_paths.append(basename + '.fjson')
1292-
if basename.endswith('/index'):
1293-
new_basename = re.sub(r'\/index$', '', basename)
1294-
fjson_paths.append(new_basename + '.fjson')
1284+
fjson_paths = []
1285+
basename = os.path.splitext(self.path)[0]
1286+
fjson_paths.append(basename + '.fjson')
1287+
if basename.endswith('/index'):
1288+
new_basename = re.sub(r'\/index$', '', basename)
1289+
fjson_paths.append(new_basename + '.fjson')
12951290

1296-
storage_path = self.project.get_storage_path(
1297-
type_='json', version_slug=self.version.slug, include_file=False
1298-
)
1299-
try:
1300-
for fjson_path in fjson_paths:
1301-
file_path = storage.join(storage_path, fjson_path)
1302-
if storage.exists(file_path):
1303-
return process_file(file_path)
1304-
except Exception:
1305-
log.warning(
1306-
'Unhandled exception during search processing file: %s',
1307-
file_path,
1308-
)
1309-
else:
1291+
storage_path = self.project.get_storage_path(
1292+
type_='json', version_slug=self.version.slug, include_file=False
1293+
)
1294+
try:
1295+
for fjson_path in fjson_paths:
1296+
file_path = storage.join(storage_path, fjson_path)
1297+
if storage.exists(file_path):
1298+
return process_file(file_path)
1299+
except Exception:
13101300
log.warning(
1311-
'Skipping HTMLFile processing because of no storage backend'
1301+
'Unhandled exception during search processing file: %s',
1302+
file_path,
13121303
)
13131304

13141305
return {

readthedocs/projects/tasks.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ def store_build_artifacts(
777777
:param epub: whether to save ePub output
778778
"""
779779
if not settings.RTD_BUILD_MEDIA_STORAGE:
780+
# Note: this check can be removed once corporate build servers use storage
780781
log.warning(
781782
LOG_TEMPLATE,
782783
{
@@ -1381,10 +1382,6 @@ def _create_intersphinx_data(version, commit, build):
13811382
:param commit: Commit that updated path
13821383
:param build: Build id
13831384
"""
1384-
if not settings.RTD_BUILD_MEDIA_STORAGE:
1385-
log.warning('RTD_BUILD_MEDIA_STORAGE is missing - Not updating intersphinx data')
1386-
return
1387-
13881385
storage = get_storage_class(settings.RTD_BUILD_MEDIA_STORAGE)()
13891386

13901387
html_storage_path = version.project.get_storage_path(
@@ -1542,11 +1539,6 @@ def _create_imported_files(version, commit, build):
15421539
:returns: paths of changed files
15431540
:rtype: set
15441541
"""
1545-
1546-
if not settings.RTD_BUILD_MEDIA_STORAGE:
1547-
log.warning('RTD_BUILD_MEDIA_STORAGE is missing - Not updating imported files')
1548-
return
1549-
15501542
storage = get_storage_class(settings.RTD_BUILD_MEDIA_STORAGE)()
15511543

15521544
changed_files = set()
@@ -1842,10 +1834,6 @@ def remove_build_storage_paths(paths):
18421834
18431835
:param paths: list of paths in build media storage to delete
18441836
"""
1845-
if not settings.RTD_BUILD_MEDIA_STORAGE:
1846-
log.warning('RTD_BUILD_MEDIA_STORAGE is missing - Not removing paths from media storage')
1847-
return
1848-
18491837
storage = get_storage_class(settings.RTD_BUILD_MEDIA_STORAGE)()
18501838
for storage_path in paths:
18511839
log.info('Removing %s from media storage', storage_path)

readthedocs/projects/urls/private.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
ProjectAdvancedUpdate,
2727
ProjectAdvertisingUpdate,
2828
ProjectDashboard,
29+
ProjectDelete,
2930
ProjectUpdate,
3031
SearchAnalytics,
3132
)
@@ -69,7 +70,8 @@
6970
private.project_version_detail, name='project_version_detail',
7071
),
7172
url(
72-
r'^(?P<project_slug>[-\w]+)/delete/$', private.project_delete,
73+
r'^(?P<project_slug>[-\w]+)/delete/$',
74+
ProjectDelete.as_view(),
7375
name='projects_delete',
7476
),
7577
url(

0 commit comments

Comments
 (0)