Skip to content

Commit 9d2f35e

Browse files
committed
Merge branch 'release/0.107.0'
2 parents c1988ee + 15e4003 commit 9d2f35e

File tree

84 files changed

+792
-212
lines changed

Some content is hidden

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

84 files changed

+792
-212
lines changed

.docker-compose.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ CAS_SERVER_URL=http://192.168.168.167:8080
1414
MFR_SERVER_URL=http://localhost:7778
1515
#SHARE_URL=http://192.168.168.167:8000/
1616
BROKER_URL=amqp://guest:guest@192.168.168.167:5672/
17+
LIVE_RELOAD_DOMAIN=http://192.168.168.167:4200
1718
REDIS_URL=redis://192.168.168.167:6379/1

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ install:
105105
- cd $PROJECT_DIR
106106
- cp website/settings/local-travis.py website/settings/local.py
107107
- cp api/base/settings/local-travis.py api/base/settings/local.py
108+
- '[ -d $HOME/preprints ] || ( mkdir -p $HOME/preprints && touch $HOME/preprints/index.html )'
108109

109110
- travis_retry pip install --upgrade pip
110111
- travis_retry pip install invoke==0.13.0

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
Changelog
33
*********
44

5+
0.107.0 (2017-04-28)
6+
====================
7+
8+
- Upgrade to Django 1.11.
9+
- Remove BaseFileNode.wrapped() method.
10+
- Remove guid_string field from models.
11+
- Preprints: Add LawArxiv.
12+
- Admin: Add Date Registration Initiated to node view.
13+
- Admin: Add link between projects and registrations.
14+
515
0.106.0 (2017-04-21)
616
====================
717

addons/osfstorage/tests/test_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def test_delete_folder(self):
223223

224224
def test_delete_file(self):
225225
child = self.node_settings.get_root().append_file('Test')
226-
field_names = [f.name for f in child._meta.get_fields() if not f.is_relation and f.name not in ['id', 'guid_string', 'content_type_pk']]
226+
field_names = [f.name for f in child._meta.get_fields() if not f.is_relation and f.name not in ['id', 'content_type_pk']]
227227
child_data = {f: getattr(child, f) for f in field_names}
228228
child.delete()
229229

@@ -235,7 +235,7 @@ def test_delete_file(self):
235235
child_storage['materialized_path'] = child.materialized_path
236236
assert_equal(trashed.path, '/' + child._id)
237237
trashed_field_names = [f.name for f in child._meta.get_fields() if not f.is_relation and
238-
f.name not in ['id', 'guid_string', '_materialized_path', 'content_type_pk', '_path', 'deleted_on', 'deleted_by', 'type']]
238+
f.name not in ['id', '_materialized_path', 'content_type_pk', '_path', 'deleted_on', 'deleted_by', 'type']]
239239
for f, value in child_data.iteritems():
240240
if f in trashed_field_names:
241241
assert_equal(getattr(trashed, f), value)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11 on 2017-04-24 21:09
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('addons_wiki', '0003_auto_20170403_2228'),
12+
]
13+
14+
operations = [
15+
migrations.RemoveField(
16+
model_name='nodewikipage',
17+
name='guid_string',
18+
),
19+
]

admin/base/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ def reverse_qs(view, urlconf=None, args=None, kwargs=None, current_app=None, que
1212

1313

1414
def osf_staff_check(user):
15-
return user.is_authenticated() and user.is_staff
15+
return user.is_authenticated and user.is_staff

admin/nodes/serializers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ def serialize_node(node):
2424
'children': map(serialize_simple_node, node.nodes),
2525
'deleted': node.is_deleted,
2626
'pending_registration': node.is_pending_registration,
27+
'registered_date': node.registered_date,
2728
'creator': node.creator._id,
2829
'spam_status': node.spam_status,
2930
'spam_pro_tip': node.spam_pro_tip,
3031
'spam_data': json.dumps(node.spam_data, indent=4),
3132
'is_public': node.is_public,
33+
'registrations': [serialize_node(registration) for registration in node.registrations.all()],
34+
'registered_from': node.registered_from._id if node.registered_from else None
3235
}
3336

3437

admin/templates/nodes/node.html

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,28 @@ <h3>Node Details</h3>
232232
<td>Registration</td>
233233
<td>
234234
{% if not node.is_registration %}
235-
{{ node.is_registration }}
235+
<table class="table table-bordered table-hover">
236+
<thead>
237+
<tr>
238+
<td>Registration</td>
239+
<td>Date Created</td>
240+
<td>Pending</td>
241+
<td>Withdrawn</td>
242+
<td>Embargo</td>
243+
</tr>
244+
</thead>
245+
<tbody>
246+
{% for registration in node.registrations %}
247+
<tr>
248+
<td><a href="{{ registration.id | reverse_node }}">{{ registration.id }}</a></td>
249+
<td>{{ registration.date_created | date }}</td>
250+
<td>{{ registration.pending_registration }}</td>
251+
<td>{{ registration.withdrawn }}</td>
252+
<td>{{ registration.embargo }}</td>
253+
</tr>
254+
{% endfor %}
255+
</tbody>
256+
</table>
236257
{% else %}
237258
<table class="table table-bordered table-hover">
238259
<thead>
@@ -246,6 +267,10 @@ <h3>Node Details</h3>
246267
<td>Date Created</td>
247268
<td>{{ node.date_created | date }}</td>
248269
</tr>
270+
<tr>
271+
<td>Datetime Registered (UTC)</td>
272+
<td>{{ node.registered_date | date:"F j, Y P" }}</td>
273+
</tr>
249274
<tr>
250275
<td>Pending</td>
251276
<td>{{ node.pending_registration }}</td>
@@ -258,6 +283,10 @@ <h3>Node Details</h3>
258283
<td>Embargo</td>
259284
<td>{{ node.embargo }}</td>
260285
</tr>
286+
<tr>
287+
<td>Registered From</td>
288+
<td><a href="{% url 'nodes:node' node.registered_from %}">{{ node.registered_from }}</a></td>
289+
</tr>
261290
</tbody>
262291
</table>
263292
{% endif %}

api/base/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def origin_not_found_in_white_lists(self, origin, url):
8585
not_found = super(CorsMiddleware, self).origin_not_found_in_white_lists(origin, url)
8686
if not_found:
8787
# Check if origin is in the dynamic Institutions whitelist
88-
if url.netloc.lower() in api_settings.INSTITUTION_ORIGINS_WHITELIST:
88+
if url.netloc.lower() in api_settings.ORIGINS_WHITELIST:
8989
return
9090
# Check if a cross-origin request using the Authorization header
9191
elif not self._context.request.COOKIES:

api/base/pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def get_paginated_response(self, data):
183183
node_id = kwargs.get('node_id', None)
184184
node = Node.load(node_id)
185185
user = self.request.user
186-
if target_id and not user.is_anonymous() and node.is_contributor(user):
186+
if target_id and not user.is_anonymous and node.is_contributor(user):
187187
root_target = Guid.load(target_id)
188188
if root_target:
189189
page = getattr(root_target.referent, 'root_target_page', None)

api/base/settings/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@
2424
for setting in ('JWE_SECRET', 'JWT_SECRET', 'BYPASS_THROTTLE_TOKEN'):
2525
assert getattr(local, setting, None) and getattr(local, setting, None) != getattr(defaults, setting, None), '{} must be specified in local.py when DEV_MODE is False'.format(setting)
2626

27-
def load_institutions():
28-
global INSTITUTION_ORIGINS_WHITELIST
29-
from osf import models
30-
INSTITUTION_ORIGINS_WHITELIST = tuple(domain.lower() for domain in itertools.chain(*[
27+
def load_origins_whitelist():
28+
global ORIGINS_WHITELIST
29+
from osf.models import Institution, PreprintProvider
30+
31+
institution_origins = tuple(domain.lower() for domain in itertools.chain(*[
3132
institution.domains
32-
for institution in models.Institution.find()
33+
for institution in Institution.find()
3334
]))
35+
36+
preprintprovider_origins = tuple(preprintprovider.domain.lower() for preprintprovider in PreprintProvider.objects.exclude(domain=''))
37+
38+
ORIGINS_WHITELIST = institution_origins + preprintprovider_origins

api/base/settings/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
# use cookies.
187187
CORS_ALLOW_CREDENTIALS = True
188188
# Set dynamically on app init
189-
INSTITUTION_ORIGINS_WHITELIST = ()
189+
ORIGINS_WHITELIST = ()
190190

191191
MIDDLEWARE_CLASSES = (
192192
'api.base.middleware.DjangoGlobalMiddleware',

api/base/settings/local-dist.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
DEBUG_TOOLBAR_CONFIG = {
1818
'SHOW_TOOLBAR_CALLBACK': lambda(_): True
1919
}
20+
ALLOWED_HOSTS.append('localhost')
2021

2122
REST_FRAMEWORK['ALLOWED_VERSIONS'] = (
2223
'2.0',

api/base/settings/local-travis.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@
2323
'test-user': '2/hour',
2424
'test-anon': '1/hour',
2525
}
26+
27+
ALLOWED_HOSTS.append('localhost')

api/base/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
# These values are copied from rest_framework.fields.BooleanField
2222
# BooleanField cannot be imported here without raising an
2323
# ImproperlyConfigured error
24-
TRUTHY = set(('t', 'T', 'true', 'True', 'TRUE', '1', 1, True))
25-
FALSY = set(('f', 'F', 'false', 'False', 'FALSE', '0', 0, 0.0, False))
24+
TRUTHY = set(('t', 'T', 'true', 'True', 'TRUE', '1', 1, True, 'on', 'ON', 'On'))
25+
FALSY = set(('f', 'F', 'false', 'False', 'FALSE', '0', 0, 0.0, False, 'off', 'OFF', 'Off'))
2626

2727
UPDATE_METHODS = ['PUT', 'PATCH']
2828

@@ -59,7 +59,7 @@ def get_user_auth(request):
5959
"""
6060
user = request.user
6161
private_key = request.query_params.get('view_only', None)
62-
if user.is_anonymous():
62+
if user.is_anonymous:
6363
auth = Auth(None, private_key=private_key)
6464
else:
6565
auth = Auth(user, private_key=private_key)
@@ -161,7 +161,7 @@ def default_node_list_query():
161161

162162
def default_node_permission_query(user):
163163
permission_query = Q('is_public', 'eq', True)
164-
if not user.is_anonymous():
164+
if not user.is_anonymous:
165165
permission_query = (permission_query | Q('contributors', 'eq', user.pk))
166166

167167
return permission_query

api/base/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ def root(request, format=None, **kwargs):
732732
s3 Amazon S3
733733
734734
"""
735-
if request.user and not request.user.is_anonymous():
735+
if request.user and not request.user.is_anonymous:
736736
user = request.user
737737
current_user = UserSerializer(user, context={'request': request}).data
738738
else:

api/base/wsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ def __getattr__(self, attr):
5858
############# /monkeys ####################
5959

6060
init_app(set_backends=True, routes=False, attach_request_handlers=False)
61-
api_settings.load_institutions()
61+
api_settings.load_origins_whitelist()
6262

6363
application = get_wsgi_application()

api/collections/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def get_default_odm_query(self):
138138
Q('is_deleted', 'ne', True)
139139
)
140140
user = self.request.user
141-
if not user.is_anonymous():
141+
if not user.is_anonymous:
142142
permission_query = Q('creator', 'eq', user)
143143
else:
144144
permission_query = Q('is_public', 'eq', True)

api/comments/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_is_ham(self, obj):
6969

7070
def get_has_report(self, obj):
7171
user = self.context['request'].user
72-
if user.is_anonymous():
72+
if user.is_anonymous:
7373
return False
7474
return user._id in obj.reports and not obj.reports[user._id].get('retracted', True)
7575

@@ -80,7 +80,7 @@ def get_is_abuse(self, obj):
8080

8181
def get_can_edit(self, obj):
8282
user = self.context['request'].user
83-
if user.is_anonymous():
83+
if user.is_anonymous:
8484
return False
8585
return obj.user._id == user._id and obj.node.can_comment(Auth(user))
8686

api/files/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ def get_extra(self, obj):
234234

235235
def get_current_user_can_comment(self, obj):
236236
user = self.context['request'].user
237-
auth = Auth(user if not user.is_anonymous() else None)
237+
auth = Auth(user if not user.is_anonymous else None)
238238
return obj.node.can_comment(auth)
239239

240240
def get_unread_comments_count(self, obj):
241241
user = self.context['request'].user
242-
if user.is_anonymous():
242+
if user.is_anonymous:
243243
return 0
244244
return Comment.find_n_unread(user=user, node=obj.node, page='files', root_id=obj.get_guid()._id)
245245

api/files/views.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ def get_file(self, check_permissions=True):
4141
obj = utils.get_object_or_error(Guid, self.kwargs[self.file_lookup_url_kwarg]).referent
4242
if not isinstance(obj, StoredFileNode):
4343
raise NotFound
44-
obj = obj.wrapped()
4544

4645
if check_permissions:
4746
# May raise a permission denied
4847
self.check_object_permissions(self.request, obj)
49-
return obj.wrapped()
48+
return obj
5049

5150

5251
class FileDetail(JSONAPIBaseView, generics.RetrieveUpdateAPIView, FileMixin):

api/logs/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_node_title(self, obj):
3636
user = self.context['request'].user
3737
node_title = obj['node']['title']
3838
node = Node.load(obj['node']['_id'])
39-
if not user.is_authenticated():
39+
if not user.is_authenticated:
4040
if node.is_public:
4141
return node_title
4242
elif node.has_permission(user, osf_permissions.READ):

api/nodes/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class NodeSerializer(JSONAPISerializer):
322322

323323
def get_current_user_permissions(self, obj):
324324
user = self.context['request'].user
325-
if user.is_anonymous():
325+
if user.is_anonymous:
326326
return ['read']
327327
permissions = obj.get_permissions(user=user)
328328
if not permissions:
@@ -331,7 +331,7 @@ def get_current_user_permissions(self, obj):
331331

332332
def get_current_user_can_comment(self, obj):
333333
user = self.context['request'].user
334-
auth = Auth(user if not user.is_anonymous() else None)
334+
auth = Auth(user if not user.is_anonymous else None)
335335
return obj.can_comment(auth)
336336

337337
class Meta:

api/preprint_providers/serializers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class PreprintProviderSerializer(JSONAPISerializer):
1919
email_contact = ser.CharField(required=False, allow_null=True)
2020
email_support = ser.CharField(required=False, allow_null=True)
2121
example = ser.CharField(required=False, allow_null=True)
22+
domain = ser.CharField(required=False, allow_null=False)
23+
domain_redirect_enabled = ser.CharField(required=False, allow_null=False)
2224
social_twitter = ser.CharField(required=False, allow_null=True)
2325
social_facebook = ser.CharField(required=False, allow_null=True)
2426
social_instagram = ser.CharField(required=False, allow_null=True)

api/preprint_providers/views.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,22 @@ class PreprintProviderList(JSONAPIBaseView, generics.ListAPIView, ODMFilterMixin
3030
3131
OSF Preprint Providers have the "preprint_providers" `type`.
3232
33-
name type description
34-
=========================================================================
35-
name string name of the preprint provider
36-
logo_path string a path to the preprint provider's static logo
37-
banner_path string a path to the preprint provider's banner
38-
description string description of the preprint provider
33+
name type description
34+
=============================================================================================================
35+
name string name of the preprint provider
36+
logo_path string a path to the preprint provider's static logo
37+
banner_path string a path to the preprint provider's banner
38+
description string description of the preprint provider
39+
advisory_board string HTML for the advisory board/steering committee section
40+
email_contact string the contact email for the preprint provider
41+
email_support string the support email for the preprint provider
42+
subjects_acceptable [[string],boolean] the list of acceptable subjects for the preprint provider
43+
social_facebook string the preprint provider's Facebook account
44+
social_instagram string the preprint provider's Instagram account
45+
social_twitter string the preprint provider's Twitter account
46+
domain string the domain name of the preprint provider
47+
domain_redirect_enabled boolean whether or not redirects are enabled for the provider's domain
48+
example string an example guid for a preprint created for the preprint provider
3949
4050
##Relationships
4151
@@ -84,12 +94,22 @@ class PreprintProviderDetail(JSONAPIBaseView, generics.RetrieveAPIView):
8494
8595
OSF Preprint Providers have the "preprint_providers" `type`.
8696
87-
name type description
88-
=========================================================================
89-
name string name of the preprint provider
90-
logo_path string a path to the preprint provider's static logo
91-
banner_path string a path to the preprint provider's banner
92-
description string description of the preprint provider
97+
name type description
98+
=============================================================================================================
99+
name string name of the preprint provider
100+
logo_path string a path to the preprint provider's static logo
101+
banner_path string a path to the preprint provider's banner
102+
description string description of the preprint provider
103+
advisory_board string HTML for the advisory board/steering committee section
104+
email_contact string the contact email for the preprint provider
105+
email_support string the support email for the preprint provider
106+
subjects_acceptable [[string],boolean] the list of acceptable subjects for the preprint provider
107+
social_facebook string the preprint provider's Facebook account
108+
social_instagram string the preprint provider's Instagram account
109+
social_twitter string the preprint provider's Twitter account
110+
domain string the domain name of the preprint provider
111+
domain_redirect_enabled boolean whether or not redirects are enabled for the provider's domain
112+
example string an example guid for a preprint created for the preprint provider
93113
94114
##Relationships
95115

0 commit comments

Comments
 (0)