Skip to content

Commit 309b983

Browse files
committed
Merge branch 'release/19.27.0'
2 parents 219491d + 73920a1 commit 309b983

File tree

149 files changed

+1160
-912
lines changed

Some content is hidden

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

149 files changed

+1160
-912
lines changed

CHANGELOG

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
We follow the CalVer (https://calver.org/) versioning scheme: YY.MINOR.MICRO.
44

5+
19.27.0 (2019-09-18)
6+
===================
7+
- Automatically map subjects when a preprint is moved to a different
8+
preprint provider in the admin app
9+
- Gitlab: return all repos to which the user has access
10+
- Upgrade Bower
11+
- Py3 backwards compatible changes
12+
513
19.26.0 (2019-09-11)
614
===================
715
- Create a custom through table for linking files and versions

README-docker-compose.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@
8181

8282
`$ cp ./docker-compose-dist.override.yml ./docker-compose.override.yml`
8383

84+
For local tasks, (dev only)
85+
`$ cp ./tasks/local-dist.py ./tasks/local.py`
86+
8487
2. OPTIONAL (uncomment the below lines if you will use remote debugging) Environment variables (incl. remote debugging)
8588
- e.g. .docker-compose.env
8689

addons/base/generic_views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Generic add-on view factories"""
22
# -*- coding: utf-8 -*-
3-
import httplib as http
3+
from rest_framework import status as http_status
44

55
from flask import request
66

@@ -28,12 +28,12 @@ def _import_auth(auth, node_addon, user_addon, **kwargs):
2828
)
2929

3030
if not user_addon.external_accounts.filter(id=external_account.id).exists():
31-
raise HTTPError(http.FORBIDDEN)
31+
raise HTTPError(http_status.HTTP_403_FORBIDDEN)
3232

3333
try:
3434
node_addon.set_auth(external_account, user_addon.owner)
3535
except PermissionsError:
36-
raise HTTPError(http.FORBIDDEN)
36+
raise HTTPError(http_status.HTTP_403_FORBIDDEN)
3737

3838
node_addon.save()
3939

@@ -60,7 +60,7 @@ def folder_list(addon_short_name, addon_full_name, get_folders):
6060
def _folder_list(node_addon, **kwargs):
6161
"""Returns a list of folders"""
6262
if not node_addon.has_auth:
63-
raise HTTPError(http.FORBIDDEN)
63+
raise HTTPError(http_status.HTTP_403_FORBIDDEN)
6464

6565
folder_id = request.args.get('folderId')
6666
return get_folders(node_addon, folder_id)

addons/base/tests/views.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import httplib as http
2-
import urlparse
1+
from rest_framework import status as http_status
2+
from future.moves.urllib.parse import urlparse, urljoin, parse_qs
33

44
import mock
55
import responses
@@ -25,11 +25,11 @@ def test_oauth_start(self):
2525
service_name=self.ADDON_SHORT_NAME
2626
)
2727
res = self.app.get(url, auth=self.user.auth)
28-
assert res.status_code == http.FOUND
29-
redirect_url = urlparse.urlparse(res.location)
30-
redirect_params = urlparse.parse_qs(redirect_url.query)
31-
provider_url = urlparse.urlparse(self.Provider().auth_url)
32-
provider_params = urlparse.parse_qs(provider_url.query)
28+
assert res.status_code == http_status.HTTP_302_FOUND
29+
redirect_url = urlparse(res.location)
30+
redirect_params = parse_qs(redirect_url.query)
31+
provider_url = urlparse(self.Provider().auth_url)
32+
provider_params = parse_qs(provider_url.query)
3333
for param, value in redirect_params.items():
3434
if param == 'state': # state may change between calls
3535
continue
@@ -43,7 +43,7 @@ def test_oauth_finish(self):
4343
with mock.patch.object(self.Provider, 'auth_callback') as mock_callback:
4444
mock_callback.return_value = True
4545
res = self.app.get(url, auth=self.user.auth)
46-
assert_equal(res.status_code, http.OK)
46+
assert_equal(res.status_code, http_status.HTTP_200_OK)
4747
name, args, kwargs = mock_callback.mock_calls[0]
4848
assert_equal(kwargs['user']._id, self.user._id)
4949

@@ -53,7 +53,7 @@ def test_delete_external_account(self):
5353
external_account_id=self.external_account._id
5454
)
5555
res = self.app.delete(url, auth=self.user.auth)
56-
assert_equal(res.status_code, http.OK)
56+
assert_equal(res.status_code, http_status.HTTP_200_OK)
5757
self.user.reload()
5858
for account in self.user.external_accounts.all():
5959
assert_not_equal(account._id, self.external_account._id)
@@ -66,7 +66,7 @@ def test_delete_external_account_not_owner(self):
6666
external_account_id=self.external_account._id
6767
)
6868
res = self.app.delete(url, auth=other_user.auth, expect_errors=True)
69-
assert_equal(res.status_code, http.FORBIDDEN)
69+
assert_equal(res.status_code, http_status.HTTP_403_FORBIDDEN)
7070

7171
class OAuthAddonConfigViewsTestCaseMixin(OAuthAddonTestCaseMixin):
7272

@@ -94,7 +94,7 @@ def test_import_auth(self):
9494
res = self.app.put_json(url, {
9595
'external_account_id': ea._id
9696
}, auth=self.user.auth)
97-
assert_equal(res.status_code, http.OK)
97+
assert_equal(res.status_code, http_status.HTTP_200_OK)
9898
assert_in('result', res.json)
9999
node_settings.reload()
100100
assert_equal(node_settings.external_account._id, ea._id)
@@ -113,7 +113,7 @@ def test_import_auth_invalid_account(self):
113113
res = self.app.put_json(url, {
114114
'external_account_id': ea._id
115115
}, auth=self.user.auth, expect_errors=True)
116-
assert_equal(res.status_code, http.FORBIDDEN)
116+
assert_equal(res.status_code, http_status.HTTP_403_FORBIDDEN)
117117

118118
def test_import_auth_cant_write_node(self):
119119
ea = self.ExternalAccountFactory()
@@ -130,15 +130,15 @@ def test_import_auth_cant_write_node(self):
130130
res = self.app.put_json(url, {
131131
'external_account_id': ea._id
132132
}, auth=user.auth, expect_errors=True)
133-
assert_equal(res.status_code, http.FORBIDDEN)
133+
assert_equal(res.status_code, http_status.HTTP_403_FORBIDDEN)
134134

135135
def test_set_config(self):
136136
self.node_settings.set_auth(self.external_account, self.user)
137137
url = self.project.api_url_for('{0}_set_config'.format(self.ADDON_SHORT_NAME))
138138
res = self.app.put_json(url, {
139139
'selected': self.folder
140140
}, auth=self.user.auth)
141-
assert_equal(res.status_code, http.OK)
141+
assert_equal(res.status_code, http_status.HTTP_200_OK)
142142
self.project.reload()
143143
assert_equal(
144144
self.project.logs.latest().action,
@@ -150,7 +150,7 @@ def test_get_config(self):
150150
url = self.project.api_url_for('{0}_get_config'.format(self.ADDON_SHORT_NAME))
151151
with mock.patch.object(type(self.Serializer()), 'credentials_are_valid', return_value=True):
152152
res = self.app.get(url, auth=self.user.auth)
153-
assert_equal(res.status_code, http.OK)
153+
assert_equal(res.status_code, http_status.HTTP_200_OK)
154154
assert_in('result', res.json)
155155
serialized = self.Serializer().serialize_settings(
156156
self.node_settings,
@@ -164,17 +164,17 @@ def test_get_config_unauthorized(self):
164164
user = AuthUserFactory()
165165
self.project.add_contributor(user, permissions=permissions.READ, auth=self.auth, save=True)
166166
res = self.app.get(url, auth=user.auth, expect_errors=True)
167-
assert_equal(res.status_code, http.FORBIDDEN)
167+
assert_equal(res.status_code, http_status.HTTP_403_FORBIDDEN)
168168

169169
def test_get_config_not_logged_in(self):
170170
url = self.project.api_url_for('{0}_get_config'.format(self.ADDON_SHORT_NAME))
171171
res = self.app.get(url, auth=None, expect_errors=True)
172-
assert_equal(res.status_code, http.FOUND)
172+
assert_equal(res.status_code, http_status.HTTP_302_FOUND)
173173

174174
def test_account_list_single(self):
175175
url = api_url_for('{0}_account_list'.format(self.ADDON_SHORT_NAME))
176176
res = self.app.get(url, auth=self.user.auth)
177-
assert_equal(res.status_code, http.OK)
177+
assert_equal(res.status_code, http_status.HTTP_200_OK)
178178
assert_in('accounts', res.json)
179179
assert_equal(len(res.json['accounts']), 1)
180180

@@ -185,14 +185,14 @@ def test_account_list_multiple(self):
185185

186186
url = api_url_for('{0}_account_list'.format(self.ADDON_SHORT_NAME))
187187
res = self.app.get(url, auth=self.user.auth)
188-
assert_equal(res.status_code, http.OK)
188+
assert_equal(res.status_code, http_status.HTTP_200_OK)
189189
assert_in('accounts', res.json)
190190
assert_equal(len(res.json['accounts']), 2)
191191

192192
def test_account_list_not_authorized(self):
193193
url = api_url_for('{0}_account_list'.format(self.ADDON_SHORT_NAME))
194194
res = self.app.get(url, auth=None, expect_errors=True)
195-
assert_equal(res.status_code, http.FOUND)
195+
assert_equal(res.status_code, http_status.HTTP_302_FOUND)
196196

197197
def test_folder_list(self):
198198
# Note: if your addon's folder_list view makes API calls
@@ -202,13 +202,13 @@ def test_folder_list(self):
202202
self.node_settings.save()
203203
url = self.project.api_url_for('{0}_folder_list'.format(self.ADDON_SHORT_NAME))
204204
res = self.app.get(url, auth=self.user.auth)
205-
assert_equal(res.status_code, http.OK)
205+
assert_equal(res.status_code, http_status.HTTP_200_OK)
206206
# TODO test result serialization?
207207

208208
def test_deauthorize_node(self):
209209
url = self.project.api_url_for('{0}_deauthorize_node'.format(self.ADDON_SHORT_NAME))
210210
res = self.app.delete(url, auth=self.user.auth)
211-
assert_equal(res.status_code, http.OK)
211+
assert_equal(res.status_code, http_status.HTTP_200_OK)
212212
self.node_settings.reload()
213213
assert_is_none(self.node_settings.external_account)
214214
assert_false(self.node_settings.has_auth)
@@ -256,7 +256,7 @@ def test_set_config(self):
256256
'external_list_id': self.folder.json['id'],
257257
'external_list_name': self.folder.name,
258258
}, auth=self.user.auth)
259-
assert_equal(res.status_code, http.OK)
259+
assert_equal(res.status_code, http_status.HTTP_200_OK)
260260
self.project.reload()
261261
assert_equal(
262262
self.project.logs.latest().action,
@@ -271,7 +271,7 @@ def test_get_config(self):
271271
self.node_settings.save()
272272
url = self.project.api_url_for('{0}_get_config'.format(self.ADDON_SHORT_NAME))
273273
res = self.app.get(url, auth=self.user.auth)
274-
assert_equal(res.status_code, http.OK)
274+
assert_equal(res.status_code, http_status.HTTP_200_OK)
275275
assert_in('result', res.json)
276276
result = res.json['result']
277277
serialized = self.Serializer(
@@ -287,7 +287,7 @@ def test_folder_list(self):
287287
self.node_settings.save()
288288
url = self.project.api_url_for('{0}_citation_list'.format(self.ADDON_SHORT_NAME))
289289
res = self.app.get(url, auth=self.user.auth)
290-
assert_equal(res.status_code, http.OK)
290+
assert_equal(res.status_code, http_status.HTTP_200_OK)
291291

292292
def test_check_credentials(self):
293293
with mock.patch.object(self.client, 'client', new_callable=mock.PropertyMock) as mock_client:
@@ -412,4 +412,4 @@ def test_citation_list_non_linked_or_child_non_authorizer(self):
412412
auth=non_authorizing_user.auth,
413413
expect_errors=True
414414
)
415-
assert_equal(res.status_code, http.FORBIDDEN)
415+
assert_equal(res.status_code, http_status.HTTP_403_FORBIDDEN)

0 commit comments

Comments
 (0)