Skip to content

Commit 24ee5e5

Browse files
committed
Merge branch 'master' into sustainability-api-jsonp
2 parents d16f365 + 673bfc7 commit 24ee5e5

File tree

25 files changed

+150
-113
lines changed

25 files changed

+150
-113
lines changed

.eslintrc

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@
2626
"no-shadow": "off",
2727
"no-undef": "warn",
2828
"no-underscore-dangle": "off",
29-
"no-unused-vars": "off",
29+
"no-unused-vars": "warn",
3030
"no-use-before-define": "error",
3131
"object-curly-spacing": "off",
3232
"one-var": "error",
3333
"padded-blocks": "off",
3434
"quote-props": "off",
3535
"quotes": "off",
36-
"semi": "off",
37-
"space-before-function-paren": "off",
38-
"space-unary-ops": "off",
36+
"semi": "error",
37+
"space-before-function-paren": "error",
38+
"space-unary-ops": "error",
3939
"spaced-comment": "off",
4040
"vars-on-top": "off",
4141
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ _build
1717
bower_components/
1818
contrib/supervisord.log
1919
contrib/supervisord.pid
20+
celerybeat-schedule.*
2021
deploy/.vagrant
2122
dist/*
2223
local_settings.py

docs/business/sharing.rst

+23-10
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,39 @@ Sharing
44
.. note:: This feature only exists on our Business offering at `readthedocs.com <https://readthedocs.com/>`_.
55

66
You can share your project with users outside of your company.
7-
This works by sending them a link,
8-
which will allow them to view a specific project inside your company.
7+
There are two way to do this:
8+
9+
* by sending them a *secret link*,
10+
* by giving them a *password*.
11+
12+
These methods will allow them to view a specific project inside your company.
913

1014
Enabling
1115
~~~~~~~~
1216

13-
* Go into your *Project Admin* page and to the *Sharing* link.
14-
* Under the *Add Token* heading, add a *Description* so you remember who you're sharing it with.
15-
* Click *Share* to create.
16-
* Copy the link that is generated, and give that to the person who you want to give access.
17+
* Go into your *Project Admin* page and to the *Sharing* menu.
18+
* Under the *Share with someone new* heading, select the way you prefer (secret link or password), add an expiration date and a *Description* so you remember who you're sharing it with.
19+
* Click *Share!* to create.
20+
* Get the info needed to share your documentation with other users:
21+
* If you have selected secret link, copy the link that is generated
22+
* In case of password, copy the link and password
23+
* Give that information to the person who you want to give access.
1724

1825
.. note:: You can always revoke access in the same panel.
1926

2027
Effects
2128
~~~~~~~
2229

30+
Secret Link
31+
***********
32+
2333
Once the person you send the link to clicks the link,
2434
they will have access to view your project.
25-
It will only work for the specific browser that they click the link from.
2635

27-
.. warning:: They will be able to share this token with other people,
28-
so only share with people you trust.
29-
We only let sharing links be activated **five** times to prevent abuse.
36+
Password
37+
********
38+
39+
Once the person you send the link to clicks on the link, they will see
40+
a *Authorization required* page asking them for the password you
41+
generated. When the user enters the password, they will have access to
42+
view your project.

docs/gsoc.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ It will walk you through getting a basic environment for Read the Docs setup.
4444

4545
Then you can look through our :doc:`contribute` doc for information on how to get started contributing to RTD.
4646

47-
People who has a history of submitting pull requests will be prioritized in our Summer of Code selection process.
47+
People who have a history of submitting pull requests will be prioritized in our Summer of Code selection process.
4848

4949
Want to get involved?
5050
---------------------

readthedocs/builds/static-src/builds/js/detail.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var ko = require('knockout');
44
var $ = require('jquery');
55

66

7-
function BuildCommand (data) {
7+
function BuildCommand(data) {
88
var self = this;
99
self.id = ko.observable(data.id);
1010
self.command = ko.observable(data.command);
@@ -25,7 +25,7 @@ function BuildCommand (data) {
2525
});
2626
}
2727

28-
function BuildDetailView (instance) {
28+
function BuildDetailView(instance) {
2929
var self = this;
3030
var instance = instance || {};
3131

@@ -46,7 +46,7 @@ function BuildDetailView (instance) {
4646
var n;
4747
for (n in commands_raw) {
4848
var command = new BuildCommand(commands_raw[n]);
49-
commands_display.push(command)
49+
commands_display.push(command);
5050
}
5151
return commands_display;
5252
});
@@ -58,7 +58,7 @@ function BuildDetailView (instance) {
5858
self.legacy_output(true);
5959
};
6060

61-
function poll_api () {
61+
function poll_api() {
6262
if (self.finished()) {
6363
return;
6464
}
@@ -75,7 +75,7 @@ function BuildDetailView (instance) {
7575
var command = data.commands[n];
7676
var match = ko.utils.arrayFirst(
7777
self.commands(),
78-
function(command_cmp) {
78+
function (command_cmp) {
7979
return (command_cmp.id === command.id);
8080
}
8181
);

readthedocs/core/static-src/core/js/autocomplete.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module.exports = function (selector, url) {
55
$(selector).autocomplete({
66
source: url,
77
minLength: 2,
8-
open: function(event, ui) {
8+
open: function (event, ui) {
99
var ac_top = $('.ui-autocomplete').css('top');
1010
$('.ui-autocomplete').css({'width': '233px', 'top': ac_top + 10 });
1111
}
1212
});
13-
}
13+
};

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
var exports = {
44
THEME_RTD: 'sphinx_rtd_theme',
55
THEME_ALABASTER: 'alabaster',
6-
THEME_CELERY: 'sphinx_celery',
6+
THEME_CELERY: 'sphinx_celery'
77
};
88

99
exports.PROMO_SUPPORTED_THEMES = [
1010
exports.THEME_RTD,
1111
exports.THEME_ALABASTER,
12-
exports.THEME_CELERY,
12+
exports.THEME_CELERY
1313
];
1414

1515
exports.PROMO_TYPES = {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function setupBookmarkCSRFToken() {
2828
}
2929

3030
$.ajaxSetup({
31-
beforeSend: function(xhr, settings) {
31+
beforeSend: function (xhr, settings) {
3232
if (!csrfSafeMethod(settings.type)) {
3333
xhr.setRequestHeader("X-CSRFToken", $('a.bookmark[token]').attr('token'));
3434
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ function attach_elastic_search_query(data) {
9494
xhrFields: {
9595
withCredentials: true,
9696
},
97-
complete: function(resp, status_code) {
98-
if (typeof(resp.responseJSON) === 'undefined' ||
99-
typeof(resp.responseJSON.results) === 'undefined') {
97+
complete: function (resp, status_code) {
98+
if (typeof (resp.responseJSON) === 'undefined' ||
99+
typeof (resp.responseJSON.results) === 'undefined') {
100100
return search_def.reject();
101101
}
102102
return search_def.resolve(resp.responseJSON.results);

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function init() {
1111
var rtd = rtddata.get();
1212

1313
/// Click tracking on flyout
14-
$(document).on('click', "[data-toggle='rst-current-version']", function() {
14+
$(document).on('click', "[data-toggle='rst-current-version']", function () {
1515
var flyout_state = $("[data-toggle='rst-versions']").hasClass('shift-up') ? 'was_open' : 'was_closed';
1616

1717
// This needs to handle both old style legacy analytics for previously built docs
@@ -34,7 +34,7 @@ function init() {
3434
// already enabled. See:
3535
// https://github.com/snide/sphinx_rtd_theme/issues/250
3636
$(document).ready(function () {
37-
setTimeout(function() {
37+
setTimeout(function () {
3838
if (!theme.navBar) {
3939
theme.enable();
4040
}
@@ -46,7 +46,7 @@ function init() {
4646
// scroll element, gracefully handle failover by adding it
4747
// dynamically.
4848
var navBar = jquery('div.wy-side-scroll:first');
49-
if (! navBar.length) {
49+
if (!navBar.length) {
5050
var navInner = jquery('nav.wy-nav-side:first');
5151
var navScroll = $('<div />')
5252
.addClass('wy-side-scroll');

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var rtd;
88
/*
99
* Creates a sidebar div where an ad could go
1010
*/
11-
function create_sidebar_placement () {
11+
function create_sidebar_placement() {
1212
var element_id = 'rtd-' + (Math.random() + 1).toString(36).substring(4);
1313
var display_type = constants.PROMO_TYPES.LEFTNAV;
1414
var selector = null;
@@ -36,7 +36,7 @@ function create_sidebar_placement () {
3636
* Creates a sidebar div where an ad could go
3737
* Returns the ID of the div or none if no footer ad is possible
3838
*/
39-
function create_footer_placement () {
39+
function create_footer_placement() {
4040
var element_id = 'rtd-' + (Math.random() + 1).toString(36).substring(4);
4141
var display_type = constants.PROMO_TYPES.FOOTER;
4242
var selector = null;
@@ -60,7 +60,7 @@ function create_footer_placement () {
6060
return null;
6161
}
6262

63-
function Promo (data) {
63+
function Promo(data) {
6464
this.id = data.id; // analytics id
6565
this.div_id = data.div_id || '';
6666
this.html = data.html || '';
@@ -110,7 +110,7 @@ Promo.prototype.post_promo_display = function () {
110110
};
111111

112112
function init() {
113-
var get_data = {format: "jsonp"};
113+
var request_data = {format: "jsonp"};
114114
var div_ids = [];
115115
var display_types = [];
116116
var placement_funcs = [create_footer_placement, create_sidebar_placement];
@@ -131,20 +131,20 @@ function init() {
131131
}
132132
}
133133

134-
get_data.div_ids = div_ids.join('|');
135-
get_data.display_types = display_types.join('|');
136-
get_data.project = rtd.project;
134+
request_data.div_ids = div_ids.join('|');
135+
request_data.display_types = display_types.join('|');
136+
request_data.project = rtd.project;
137137

138138
if (typeof URL !== 'undefined' && typeof URLSearchParams !== 'undefined') {
139139
// Force a specific promo to be displayed
140140
params = new URL(window.location).searchParams;
141141
if (params.get('force_promo')) {
142-
get_data.force_promo = params.get('force_promo');
142+
request_data.force_promo = params.get('force_promo');
143143
}
144144

145145
// Force a promo from a specific campaign
146146
if (params.get('force_campaign')) {
147-
get_data.force_campaign = params.get('force_campaign');
147+
request_data.force_campaign = params.get('force_campaign');
148148
}
149149
}
150150

@@ -156,7 +156,7 @@ function init() {
156156
withCredentials: true,
157157
},
158158
dataType: "jsonp",
159-
data: get_data,
159+
data: request_data,
160160
success: function (data) {
161161
var promo;
162162
if (data && data.div_id && data.html) {

readthedocs/core/static-src/core/js/site.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ module.exports.handle_notification_dismiss = function () {
1717
}
1818
});
1919
});
20-
}
20+
};

readthedocs/core/static-src/core/js/tasks.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
var jquery = require('jquery');
44

5-
function poll_task (data) {
5+
function poll_task(data) {
66
var defer = jquery.Deferred();
77
var tries = 5;
88

9-
function poll_task_loop () {
9+
function poll_task_loop() {
1010
jquery
1111
.getJSON(data.url)
1212
.success(function (task) {
@@ -40,7 +40,7 @@ function poll_task (data) {
4040
return defer;
4141
}
4242

43-
function trigger_task (config) {
43+
function trigger_task(config) {
4444
var defer = jquery.Deferred();
4545
var url = config.url;
4646
var token = config.token;

readthedocs/core/views/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def wipe_version(request, project_slug, version_slug):
7777
project__slug=project_slug,
7878
slug=version_slug,
7979
)
80-
if request.user not in version.project.users.all():
80+
# We need to check by ``for_admin_user`` here to allow members of the
81+
# ``Admin`` team (which doesn't own the project) under the corporate site.
82+
if version.project not in Project.objects.for_admin_user(user=request.user):
8183
raise Http404('You must own this project to wipe it.')
8284

8385
if request.method == 'POST':

readthedocs/doc_builder/environments.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
import socket
1515
from datetime import datetime
1616

17-
from readthedocs.core.utils import slugify
1817
from django.conf import settings
1918
from django.utils.translation import ugettext_lazy as _
20-
from docker import Client
21-
from docker.utils import create_host_config
19+
from docker import APIClient
2220
from docker.errors import APIError as DockerAPIError, DockerException
2321
from slumber.exceptions import HttpClientError
2422

2523
from readthedocs.builds.constants import BUILD_STATE_FINISHED
2624
from readthedocs.builds.models import BuildCommandResultMixin
25+
from readthedocs.core.utils import slugify
2726
from readthedocs.projects.constants import LOG_TEMPLATE
2827
from readthedocs.restapi.client import api as api_v2
2928
from requests.exceptions import ConnectionError
@@ -723,10 +722,9 @@ def get_client(self):
723722
"""Create Docker client connection."""
724723
try:
725724
if self.client is None:
726-
self.client = Client(
725+
self.client = APIClient(
727726
base_url=self.docker_socket,
728727
version=DOCKER_VERSION,
729-
timeout=None
730728
)
731729
return self.client
732730
except DockerException as e:
@@ -778,9 +776,12 @@ def get_container_host_config(self):
778776
self.project.pip_cache_path: {
779777
'bind': self.project.pip_cache_path,
780778
'mode': 'rw',
781-
}
779+
},
782780
})
783-
return create_host_config(binds=binds)
781+
return self.get_client().create_host_config(
782+
binds=binds,
783+
mem_limit=self.container_mem_limit,
784+
)
784785

785786
@property
786787
def container_id(self):
@@ -839,7 +840,6 @@ def create_container(self):
839840
host_config=self.get_container_host_config(),
840841
detach=True,
841842
environment=self.environment,
842-
mem_limit=self.container_mem_limit,
843843
)
844844
client.start(container=self.container_id)
845845
except ConnectionError as e:

readthedocs/gold/static-src/gold/js/gold.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var jquery = require('jquery');
44
var payment = require('readthedocs/payments/static-src/payments/js/base');
55
var ko = require('knockout');
66

7-
function GoldView (config) {
7+
function GoldView(config) {
88
var self = this;
99
var config = config || {};
1010

@@ -20,7 +20,7 @@ GoldView.init = function (config, obj) {
2020
var obj = obj || $('#payment-form')[0];
2121
ko.applyBindings(view, obj);
2222
return view;
23-
}
23+
};
2424

2525
GoldView.prototype.submit_form = function (card_digits, token) {
2626
this.form.find('#id_last_4_digits').val(card_digits);

0 commit comments

Comments
 (0)