Skip to content

Commit

Permalink
Merge branch 'master' into sustainability-api-jsonp
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfischer committed Mar 20, 2018
2 parents d16f365 + 673bfc7 commit 24ee5e5
Show file tree
Hide file tree
Showing 25 changed files with 150 additions and 113 deletions.
8 changes: 4 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
"no-shadow": "off",
"no-undef": "warn",
"no-underscore-dangle": "off",
"no-unused-vars": "off",
"no-unused-vars": "warn",
"no-use-before-define": "error",
"object-curly-spacing": "off",
"one-var": "error",
"padded-blocks": "off",
"quote-props": "off",
"quotes": "off",
"semi": "off",
"space-before-function-paren": "off",
"space-unary-ops": "off",
"semi": "error",
"space-before-function-paren": "error",
"space-unary-ops": "error",
"spaced-comment": "off",
"vars-on-top": "off",
}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ _build
bower_components/
contrib/supervisord.log
contrib/supervisord.pid
celerybeat-schedule.*
deploy/.vagrant
dist/*
local_settings.py
Expand Down
33 changes: 23 additions & 10 deletions docs/business/sharing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,39 @@ Sharing
.. note:: This feature only exists on our Business offering at `readthedocs.com <https://readthedocs.com/>`_.

You can share your project with users outside of your company.
This works by sending them a link,
which will allow them to view a specific project inside your company.
There are two way to do this:

* by sending them a *secret link*,
* by giving them a *password*.

These methods will allow them to view a specific project inside your company.

Enabling
~~~~~~~~

* Go into your *Project Admin* page and to the *Sharing* link.
* Under the *Add Token* heading, add a *Description* so you remember who you're sharing it with.
* Click *Share* to create.
* Copy the link that is generated, and give that to the person who you want to give access.
* Go into your *Project Admin* page and to the *Sharing* menu.
* 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.
* Click *Share!* to create.
* Get the info needed to share your documentation with other users:
* If you have selected secret link, copy the link that is generated
* In case of password, copy the link and password
* Give that information to the person who you want to give access.

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

Effects
~~~~~~~

Secret Link
***********

Once the person you send the link to clicks the link,
they will have access to view your project.
It will only work for the specific browser that they click the link from.

.. warning:: They will be able to share this token with other people,
so only share with people you trust.
We only let sharing links be activated **five** times to prevent abuse.
Password
********

Once the person you send the link to clicks on the link, they will see
a *Authorization required* page asking them for the password you
generated. When the user enters the password, they will have access to
view your project.
2 changes: 1 addition & 1 deletion docs/gsoc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ It will walk you through getting a basic environment for Read the Docs setup.

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

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

Want to get involved?
---------------------
Expand Down
10 changes: 5 additions & 5 deletions readthedocs/builds/static-src/builds/js/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var ko = require('knockout');
var $ = require('jquery');


function BuildCommand (data) {
function BuildCommand(data) {
var self = this;
self.id = ko.observable(data.id);
self.command = ko.observable(data.command);
Expand All @@ -25,7 +25,7 @@ function BuildCommand (data) {
});
}

function BuildDetailView (instance) {
function BuildDetailView(instance) {
var self = this;
var instance = instance || {};

Expand All @@ -46,7 +46,7 @@ function BuildDetailView (instance) {
var n;
for (n in commands_raw) {
var command = new BuildCommand(commands_raw[n]);
commands_display.push(command)
commands_display.push(command);
}
return commands_display;
});
Expand All @@ -58,7 +58,7 @@ function BuildDetailView (instance) {
self.legacy_output(true);
};

function poll_api () {
function poll_api() {
if (self.finished()) {
return;
}
Expand All @@ -75,7 +75,7 @@ function BuildDetailView (instance) {
var command = data.commands[n];
var match = ko.utils.arrayFirst(
self.commands(),
function(command_cmp) {
function (command_cmp) {
return (command_cmp.id === command.id);
}
);
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/core/static-src/core/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module.exports = function (selector, url) {
$(selector).autocomplete({
source: url,
minLength: 2,
open: function(event, ui) {
open: function (event, ui) {
var ac_top = $('.ui-autocomplete').css('top');
$('.ui-autocomplete').css({'width': '233px', 'top': ac_top + 10 });
}
});
}
};
4 changes: 2 additions & 2 deletions readthedocs/core/static-src/core/js/doc-embed/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
var exports = {
THEME_RTD: 'sphinx_rtd_theme',
THEME_ALABASTER: 'alabaster',
THEME_CELERY: 'sphinx_celery',
THEME_CELERY: 'sphinx_celery'
};

exports.PROMO_SUPPORTED_THEMES = [
exports.THEME_RTD,
exports.THEME_ALABASTER,
exports.THEME_CELERY,
exports.THEME_CELERY
];

exports.PROMO_TYPES = {
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/static-src/core/js/doc-embed/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function setupBookmarkCSRFToken() {
}

$.ajaxSetup({
beforeSend: function(xhr, settings) {
beforeSend: function (xhr, settings) {
if (!csrfSafeMethod(settings.type)) {
xhr.setRequestHeader("X-CSRFToken", $('a.bookmark[token]').attr('token'));
}
Expand Down
6 changes: 3 additions & 3 deletions readthedocs/core/static-src/core/js/doc-embed/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ function attach_elastic_search_query(data) {
xhrFields: {
withCredentials: true,
},
complete: function(resp, status_code) {
if (typeof(resp.responseJSON) === 'undefined' ||
typeof(resp.responseJSON.results) === 'undefined') {
complete: function (resp, status_code) {
if (typeof (resp.responseJSON) === 'undefined' ||
typeof (resp.responseJSON.results) === 'undefined') {
return search_def.reject();
}
return search_def.resolve(resp.responseJSON.results);
Expand Down
6 changes: 3 additions & 3 deletions readthedocs/core/static-src/core/js/doc-embed/sphinx.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function init() {
var rtd = rtddata.get();

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

// This needs to handle both old style legacy analytics for previously built docs
Expand All @@ -34,7 +34,7 @@ function init() {
// already enabled. See:
// https://github.com/snide/sphinx_rtd_theme/issues/250
$(document).ready(function () {
setTimeout(function() {
setTimeout(function () {
if (!theme.navBar) {
theme.enable();
}
Expand All @@ -46,7 +46,7 @@ function init() {
// scroll element, gracefully handle failover by adding it
// dynamically.
var navBar = jquery('div.wy-side-scroll:first');
if (! navBar.length) {
if (!navBar.length) {
var navInner = jquery('nav.wy-nav-side:first');
var navScroll = $('<div />')
.addClass('wy-side-scroll');
Expand Down
20 changes: 10 additions & 10 deletions readthedocs/core/static-src/core/js/doc-embed/sponsorship.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var rtd;
/*
* Creates a sidebar div where an ad could go
*/
function create_sidebar_placement () {
function create_sidebar_placement() {
var element_id = 'rtd-' + (Math.random() + 1).toString(36).substring(4);
var display_type = constants.PROMO_TYPES.LEFTNAV;
var selector = null;
Expand Down Expand Up @@ -36,7 +36,7 @@ function create_sidebar_placement () {
* Creates a sidebar div where an ad could go
* Returns the ID of the div or none if no footer ad is possible
*/
function create_footer_placement () {
function create_footer_placement() {
var element_id = 'rtd-' + (Math.random() + 1).toString(36).substring(4);
var display_type = constants.PROMO_TYPES.FOOTER;
var selector = null;
Expand All @@ -60,7 +60,7 @@ function create_footer_placement () {
return null;
}

function Promo (data) {
function Promo(data) {
this.id = data.id; // analytics id
this.div_id = data.div_id || '';
this.html = data.html || '';
Expand Down Expand Up @@ -110,7 +110,7 @@ Promo.prototype.post_promo_display = function () {
};

function init() {
var get_data = {format: "jsonp"};
var request_data = {format: "jsonp"};
var div_ids = [];
var display_types = [];
var placement_funcs = [create_footer_placement, create_sidebar_placement];
Expand All @@ -131,20 +131,20 @@ function init() {
}
}

get_data.div_ids = div_ids.join('|');
get_data.display_types = display_types.join('|');
get_data.project = rtd.project;
request_data.div_ids = div_ids.join('|');
request_data.display_types = display_types.join('|');
request_data.project = rtd.project;

if (typeof URL !== 'undefined' && typeof URLSearchParams !== 'undefined') {
// Force a specific promo to be displayed
params = new URL(window.location).searchParams;
if (params.get('force_promo')) {
get_data.force_promo = params.get('force_promo');
request_data.force_promo = params.get('force_promo');
}

// Force a promo from a specific campaign
if (params.get('force_campaign')) {
get_data.force_campaign = params.get('force_campaign');
request_data.force_campaign = params.get('force_campaign');
}
}

Expand All @@ -156,7 +156,7 @@ function init() {
withCredentials: true,
},
dataType: "jsonp",
data: get_data,
data: request_data,
success: function (data) {
var promo;
if (data && data.div_id && data.html) {
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/static-src/core/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ module.exports.handle_notification_dismiss = function () {
}
});
});
}
};
6 changes: 3 additions & 3 deletions readthedocs/core/static-src/core/js/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

var jquery = require('jquery');

function poll_task (data) {
function poll_task(data) {
var defer = jquery.Deferred();
var tries = 5;

function poll_task_loop () {
function poll_task_loop() {
jquery
.getJSON(data.url)
.success(function (task) {
Expand Down Expand Up @@ -40,7 +40,7 @@ function poll_task (data) {
return defer;
}

function trigger_task (config) {
function trigger_task(config) {
var defer = jquery.Deferred();
var url = config.url;
var token = config.token;
Expand Down
4 changes: 3 additions & 1 deletion readthedocs/core/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def wipe_version(request, project_slug, version_slug):
project__slug=project_slug,
slug=version_slug,
)
if request.user not in version.project.users.all():
# We need to check by ``for_admin_user`` here to allow members of the
# ``Admin`` team (which doesn't own the project) under the corporate site.
if version.project not in Project.objects.for_admin_user(user=request.user):
raise Http404('You must own this project to wipe it.')

if request.method == 'POST':
Expand Down
16 changes: 8 additions & 8 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
import socket
from datetime import datetime

from readthedocs.core.utils import slugify
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from docker import Client
from docker.utils import create_host_config
from docker import APIClient
from docker.errors import APIError as DockerAPIError, DockerException
from slumber.exceptions import HttpClientError

from readthedocs.builds.constants import BUILD_STATE_FINISHED
from readthedocs.builds.models import BuildCommandResultMixin
from readthedocs.core.utils import slugify
from readthedocs.projects.constants import LOG_TEMPLATE
from readthedocs.restapi.client import api as api_v2
from requests.exceptions import ConnectionError
Expand Down Expand Up @@ -723,10 +722,9 @@ def get_client(self):
"""Create Docker client connection."""
try:
if self.client is None:
self.client = Client(
self.client = APIClient(
base_url=self.docker_socket,
version=DOCKER_VERSION,
timeout=None
)
return self.client
except DockerException as e:
Expand Down Expand Up @@ -778,9 +776,12 @@ def get_container_host_config(self):
self.project.pip_cache_path: {
'bind': self.project.pip_cache_path,
'mode': 'rw',
}
},
})
return create_host_config(binds=binds)
return self.get_client().create_host_config(
binds=binds,
mem_limit=self.container_mem_limit,
)

@property
def container_id(self):
Expand Down Expand Up @@ -839,7 +840,6 @@ def create_container(self):
host_config=self.get_container_host_config(),
detach=True,
environment=self.environment,
mem_limit=self.container_mem_limit,
)
client.start(container=self.container_id)
except ConnectionError as e:
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/gold/static-src/gold/js/gold.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var jquery = require('jquery');
var payment = require('readthedocs/payments/static-src/payments/js/base');
var ko = require('knockout');

function GoldView (config) {
function GoldView(config) {
var self = this;
var config = config || {};

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

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

0 comments on commit 24ee5e5

Please sign in to comment.