Skip to content

Commit b06f1a0

Browse files
added user link to dashboard download file (#11824)
https://openscience.atlassian.net/browse/ENG-11795
1 parent adbd4f3 commit b06f1a0

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

api/institutions/serializers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from urllib.parse import urljoin
2+
13
from django.db.models import Count, F
24

35
from rest_framework import serializers as ser
@@ -21,6 +23,7 @@
2123
from api.base.serializers import YearmonthField
2224
from api.nodes.serializers import CompoundIDField
2325
from api.base.exceptions import RelationshipPostMakesNoChanges
26+
from website import settings
2427

2528

2629
class InstitutionSerializer(JSONAPISerializer):
@@ -258,6 +261,7 @@ class Meta:
258261
month_last_login = YearmonthField(read_only=True)
259262
month_last_active = YearmonthField(read_only=True)
260263
account_creation_date = YearmonthField(read_only=True)
264+
link = ser.SerializerMethodField()
261265

262266
public_projects = ser.IntegerField(read_only=True, source='public_project_count')
263267
private_projects = ser.IntegerField(read_only=True, source='private_project_count')
@@ -277,6 +281,9 @@ class Meta:
277281
)
278282
contacts = ser.SerializerMethodField()
279283

284+
def get_link(self, obj):
285+
return urljoin(settings.DOMAIN, f'{obj.user_id}/')
286+
280287
def get_contacts(self, obj):
281288
user = OSFUser.load(obj._d_['user_id'])
282289
if not user:

api_tests/institutions/views/test_institution_user_metric_list.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import pytest
88

99
from api.base.settings.defaults import API_BASE, REPORT_FILENAME_FORMAT
10+
from website import settings
1011
from osf_tests.factories import (
1112
InstitutionFactory,
1213
AuthUserFactory,
@@ -204,6 +205,7 @@ def test_get_report_formats_csv_tsv(self, app, url, institutional_admin, institu
204205
'contacts',
205206
'department',
206207
'embargoed_registration_count',
208+
'link',
207209
'month_last_active',
208210
'month_last_login',
209211
'orcid_id',
@@ -213,14 +215,15 @@ def test_get_report_formats_csv_tsv(self, app, url, institutional_admin, institu
213215
'public_registration_count',
214216
'published_preprint_count',
215217
'storage_byte_count',
216-
'user_name'
218+
'user_name',
217219
],
218220
[
219221
'2024-08',
220222
'2018-02',
221223
'[]',
222224
'Center, \t Greatest Ever',
223225
'1',
226+
settings.DOMAIN + 'u_orcomma/',
224227
'2018-02',
225228
'2018-02',
226229
'4444-3333-2222-1111',
@@ -230,7 +233,7 @@ def test_get_report_formats_csv_tsv(self, app, url, institutional_admin, institu
230233
'2',
231234
'1',
232235
'736662999298',
233-
'Jason Kelce'
236+
'Jason Kelce',
234237
]
235238
]
236239

@@ -275,6 +278,7 @@ def test_csv_tsv_ignores_pagination(self, app, url, institutional_admin, institu
275278
'[]',
276279
'QBatman',
277280
'1',
281+
settings.DOMAIN + f'u_orcomma_{i}/',
278282
'2018-02',
279283
'2018-02',
280284
f'4444-3333-2222-111{i}',
@@ -318,6 +322,7 @@ def test_csv_tsv_ignores_pagination(self, app, url, institutional_admin, institu
318322
'contacts',
319323
'department',
320324
'embargoed_registration_count',
325+
'link',
321326
'month_last_active',
322327
'month_last_login',
323328
'orcid_id',
@@ -375,6 +380,7 @@ def test_get_report_format_table_json(self, app, url, institutional_admin, insti
375380
'contacts': [],
376381
'department': 'Safety "The Wolverine" Weapon X',
377382
'embargoed_registration_count': 1,
383+
'link': settings.DOMAIN + 'u_orcomma/',
378384
'month_last_active': '2018-02',
379385
'month_last_login': '2018-02',
380386
'orcid_id': '4444-3333-2222-1111',

0 commit comments

Comments
 (0)