Skip to content

Commit 2447dc1

Browse files
committed
Merge branch 'release/2.4.0'
2 parents 2fc9059 + 49c582c commit 2447dc1

339 files changed

Lines changed: 3831 additions & 58 deletions

File tree

Some content is hidden

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

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ COPY ./ /code/
5252

5353
RUN python manage.py collectstatic --noinput
5454

55+
ARG GIT_TAG=
5556
ARG GIT_COMMIT=
57+
ENV VERSION ${GIT_TAG}
5658
ENV GIT_COMMIT ${GIT_COMMIT}
5759

5860
CMD ["python", "manage.py", "--help"]

api/serializers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,14 @@ def get_token(self, obj):
125125
def is_superuser(self, obj):
126126
return obj.is_superuser
127127

128+
def get_favicon(self, obj):
129+
return obj.favicon.url if obj.favicon else None
130+
128131
class Meta:
129132
model = models.ShareUser
130133
fields = (
131134
'username', 'first_name', 'last_name', 'email', 'date_joined', 'last_login',
132-
'is_active', 'gravatar', 'locale', 'time_zone'
135+
'is_active', 'gravatar', 'locale', 'time_zone', 'favicon'
133136
)
134137

135138

@@ -146,7 +149,7 @@ def provider_name(self, obj):
146149

147150
class Meta:
148151
model = models.ShareUser
149-
fields = ('home_page', 'long_title', 'date_joined', 'gravatar')
152+
fields = ('home_page', 'long_title', 'date_joined', 'gravatar', 'favicon')
150153

151154

152155
class SiteBannerSerializer(ShareModelSerializer):

api/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def register_url(self, subclass, viewset):
9393
]
9494

9595
urlpatterns = [
96+
url(r'status/?', views.ServerStatusView.as_view(), name='status'),
9697
url(r'rss/?', views.CreativeWorksRSS(), name='rss'),
9798
url(r'atom/?', views.CreativeWorksAtom(), name='atom'),
9899
url(r'graph/?', GraphQLView.as_view(graphiql=True)),

api/views/share.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
from rest_framework_json_api import serializers
66

77
from django import http
8+
from django.conf import settings
9+
from django.views.decorators.http import require_GET
810
from django.views.generic.base import RedirectView
911
from django.shortcuts import get_object_or_404
1012

1113
from api.filters import ShareObjectFilterSet
1214
from api import serializers as api_serializers
1315

1416
from share.util import IDObfuscator, InvalidID
17+
from share.models import ShareUser
1518

1619

1720
class VersionsViewSet(viewsets.ReadOnlyModelViewSet):
@@ -107,6 +110,16 @@ def get(self, request, *args, **kwargs):
107110
return Response(ser.data)
108111

109112

113+
@require_GET
114+
def user_favicon_view(request, username):
115+
user = get_object_or_404(ShareUser, username=username)
116+
if not user.favicon:
117+
raise http.Http404('Favicon for user {} does not exist'.format(user.username))
118+
response = http.FileResponse(user.favicon)
119+
response['Content-Type'] = 'image/x-icon'
120+
return response
121+
122+
110123
class HttpSmartResponseRedirect(http.HttpResponseRedirect):
111124
status_code = 307
112125

@@ -127,3 +140,15 @@ def get(self, request, *args, **kwargs):
127140
return HttpSmartResponsePermanentRedirect(url)
128141
return HttpSmartResponseRedirect(url)
129142
return http.HttpResponseGone()
143+
144+
145+
class ServerStatusView(views.APIView):
146+
def get(self, request):
147+
return Response({
148+
'id': '1',
149+
'type': 'Status',
150+
'attributes': {
151+
'status': 'up',
152+
'version': settings.VERSION,
153+
}
154+
})

docs/harvesters_and_normalizers.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ Adding a new provider
149149
- See :ref:`Best practices for writing a non-OAI Harvester <writing-harvesters>`
150150
- Writing the normalizer
151151
- See :ref:`Best practices for writing a non-OAI Normalizer <writing-normalizers>`
152-
- Adding the migration
153-
- Finally, run ``./manage.py makeprovidermigrations`` in the terminal
154-
- Include only the relevant migration in the PR
155152
- Adding a provider's favicon
156153
- visit ``www.domain.com/favicon.ico`` and download the ``favicon.ico`` file
157-
- place ``favicon.ico`` in ``providers/domain/provider_name/static/domain.provider_name/img/``
154+
- place ``favicon.ico`` in the ``providers/`` specific folder
155+
- Adding the migration
156+
- Finally, run ``./manage.py makeprovidermigrations`` in the terminal
157+
- Include only the relevant migrations in the PR
158158

159159
.. _OAI-PMH: http://www.openarchives.org/OAI/openarchivesprotocol.html
160160

project/settings.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
import os
14+
import subprocess
1415

1516
from django.utils.log import DEFAULT_LOGGING
1617

@@ -35,6 +36,14 @@
3536
# SECURITY WARNING: don't run with debug turned on in production!
3637
DEBUG = bool(os.environ.get('DEBUG', True))
3738

39+
if 'VERSION' not in os.environ and DEBUG:
40+
try:
41+
VERSION = subprocess.check_output(['git', 'describe']).decode().strip()
42+
except subprocess.CalledProcessError:
43+
VERSION = 'UNKNOWN'
44+
else:
45+
VERSION = os.environ.get('VERSION') or 'UNKNOWN'
46+
3847
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(' ')
3948

4049
AUTH_USER_MODEL = 'share.ShareUser'
@@ -95,6 +104,7 @@
95104
'providers.com.peerj',
96105
'providers.com.peerj.preprints',
97106
'providers.com.peerj.xml',
107+
'providers.com.researchregistry',
98108
'providers.com.springer',
99109
'providers.edu.ageconsearch',
100110
'providers.edu.asu',
@@ -190,6 +200,7 @@
190200
'providers.gov.scitech',
191201
'providers.gov.usgs',
192202
'providers.info.spdataverse',
203+
'providers.info.ssoar',
193204
'providers.io.osf',
194205
'providers.io.osf.preprints',
195206
'providers.io.osf.registrations',
@@ -605,6 +616,8 @@
605616
DATAVERSE_API_KEY = os.environ.get('DATAVERSE_API_KEY')
606617
PLOS_API_KEY = os.environ.get('PLOS_API_KEY')
607618
SPRINGER_API_KEY = os.environ.get('SPRINGER_API_KEY')
619+
RESEARCHREGISTRY_APPLICATION_ID = os.environ.get('RESEARCHREGISTRY_APPLICATION_ID', '54a1ac1032e4beb07e04ac2c')
620+
RESEARCHREGISTRY_API_KEY = os.environ.get('RESEARCHREGISTRY_API_KEY', 'renderer')
608621

609622
import djcelery # noqa
610623
djcelery.setup_loader()

project/urls.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from osf_oauth2_adapter import views as osf_oauth2_adapter_views
2424

25-
from api.views import APIVersionRedirectView
25+
from api.views import APIVersionRedirectView, user_favicon_view
2626

2727
urlpatterns = [
2828
url(r'^admin/', admin.site.urls),
@@ -38,7 +38,8 @@
3838
url(r'^favicon.ico$', RedirectView.as_view(
3939
url=staticfiles_storage.url('favicon.ico'),
4040
permanent=False
41-
), name="favicon"),
41+
), name='favicon'),
42+
url(r'^favicons/(?P<username>[^/]+).ico$', user_favicon_view, name='user_favicon'),
4243
]
4344

4445
if settings.DEBUG:
File renamed without changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.9.7 on 2017-02-01 21:23
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations
6+
import share.robot
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('au.uow', '0001_initial'),
13+
('share', '0018_store_favicons'),
14+
]
15+
16+
operations = [
17+
migrations.RunPython(
18+
code=share.robot.RobotFaviconMigration('au.uow'),
19+
),
20+
]
File renamed without changes.

0 commit comments

Comments
 (0)