From 0a621a2cc3f5cecf6eba64552e04bca1324cdb5b Mon Sep 17 00:00:00 2001 From: huanphan-tma Date: Fri, 24 Feb 2023 18:31:42 +0700 Subject: [PATCH 01/37] =?UTF-8?q?refs=20(1)4.1.=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=B2=AC=E4=BB=BB=E8=80=85=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E5=88=B6=E5=BE=A1:=20Add=20source=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/institutions/authentication.py | 12 ++++++++++++ osf/models/user.py | 1 + 2 files changed, 13 insertions(+) diff --git a/api/institutions/authentication.py b/api/institutions/authentication.py index 63e00015493..5d9dd5a692e 100644 --- a/api/institutions/authentication.py +++ b/api/institutions/authentication.py @@ -408,6 +408,18 @@ def get_next(obj, *args): user.save() update_default_storage(user) + # Update DataSteward status after every time user login + if entitlement and 'GakuNinRDMDataSteward' in entitlement: + if not user.is_data_steward: + # Set user.is_data_steward to True + user.is_data_steward = True + user.save() + # TODO: (1)4.2.2 Force set ProjectAdmin to projects for user + else: + # Set user.is_data_steward to False + user.is_data_steward = False + user.save() + # update every login. (for mAP API v1) init_cloud_gateway_groups(user, provider) diff --git a/osf/models/user.py b/osf/models/user.py index 43fda60edd7..f49bf403f72 100644 --- a/osf/models/user.py +++ b/osf/models/user.py @@ -448,6 +448,7 @@ class OSFUser(DirtyFieldsMixin, GuidMixin, BaseModel, AbstractBaseUser, Permissi is_active = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) + is_data_steward = models.BooleanField(default=False) # ePPN, eduPersonTargetedID and isMemberOf from Shibboleth # for Cloud Gateway From 84a340b36283d2c819e13734afd16add39e7b52f Mon Sep 17 00:00:00 2001 From: huanphan-tma Date: Wed, 1 Mar 2023 16:47:24 +0700 Subject: [PATCH 02/37] =?UTF-8?q?refs=20(1)4.1.=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=B2=AC=E4=BB=BB=E8=80=85=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E5=88=B6=E5=BE=A1:=20Remove=20todo=20comment?= =?UTF-8?q?=20and=20add=20migration=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/institutions/authentication.py | 1 - .../0225_osfuser_is_data_steward.py | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 osf/migrations/0225_osfuser_is_data_steward.py diff --git a/api/institutions/authentication.py b/api/institutions/authentication.py index 5d9dd5a692e..3b417356a78 100644 --- a/api/institutions/authentication.py +++ b/api/institutions/authentication.py @@ -414,7 +414,6 @@ def get_next(obj, *args): # Set user.is_data_steward to True user.is_data_steward = True user.save() - # TODO: (1)4.2.2 Force set ProjectAdmin to projects for user else: # Set user.is_data_steward to False user.is_data_steward = False diff --git a/osf/migrations/0225_osfuser_is_data_steward.py b/osf/migrations/0225_osfuser_is_data_steward.py new file mode 100644 index 00000000000..c5cb6f5f593 --- /dev/null +++ b/osf/migrations/0225_osfuser_is_data_steward.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.28 on 2023-02-20 10:29 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osf', '0224_ensure_schema_and_reports'), + ] + + operations = [ + migrations.AddField( + model_name='osfuser', + name='is_data_steward', + field=models.BooleanField(default=False), + ), + ] From 28c56757e182e9926ef535492b8643b3568721a2 Mon Sep 17 00:00:00 2001 From: huanphan-tma Date: Mon, 20 Mar 2023 18:38:34 +0700 Subject: [PATCH 03/37] =?UTF-8?q?refs=20(1)4.1.=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=B2=AC=E4=BB=BB=E8=80=85=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E5=88=B6=E5=BE=A1:=20Add=20UT=20cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/test_institution_auth.py | 26 +++++++++++++++++++ osf_tests/test_user.py | 10 +++++++ 2 files changed, 36 insertions(+) diff --git a/api_tests/institutions/views/test_institution_auth.py b/api_tests/institutions/views/test_institution_auth.py index 53b2c516f35..61c9d8d6509 100644 --- a/api_tests/institutions/views/test_institution_auth.py +++ b/api_tests/institutions/views/test_institution_auth.py @@ -36,6 +36,7 @@ def make_payload( jaOrganizationalUnitName='', organizationalUnit='', organizationName='', + entitlement='', ): data = { @@ -58,6 +59,7 @@ def make_payload( 'jaOrganizationalUnitName': jaOrganizationalUnitName, 'organizationalUnitName': organizationalUnit, 'organizationName': organizationName, + 'entitlement': entitlement, } } } @@ -521,3 +523,27 @@ def test_authenticate_OrganizationalUnitName_is_valid( user = OSFUser.objects.filter(username='tmp_eppn_' + username).first() assert user assert user.jobs[0]['department'] == organizationnameunit + + def test_authenticate_datasteward_on(self, app, institution, url_auth_institution): + username = 'user_datasteward@osf.edu' + entitlement = 'GakuNinRDMDataSteward' + res = app.post( + url_auth_institution, + make_payload(institution, username, entitlement=entitlement) + ) + assert res.status_code == 204 + user = OSFUser.objects.filter(username=username).first() + assert user + assert user.is_data_steward is True + + def test_authenticate_datasteward_off(self, app, institution, url_auth_institution): + username = 'user_datasteward@osf.edu' + entitlement = '' + res = app.post( + url_auth_institution, + make_payload(institution, username, entitlement=entitlement) + ) + assert res.status_code == 204 + user = OSFUser.objects.filter(username=username).first() + assert user + assert user.is_data_steward is False diff --git a/osf_tests/test_user.py b/osf_tests/test_user.py index 1b26d11ced7..b7c36cff4f3 100644 --- a/osf_tests/test_user.py +++ b/osf_tests/test_user.py @@ -942,6 +942,16 @@ def test_is_full_account_required_info_exception(self, mock_idp_attr): mock_idp_attr.side_effect = AttributeError('exception') assert_equal(user_auth.is_full_account_required_info, True) + def test_is_data_steward_is_true(self): + user = UserFactory(is_data_steward=True) + user.save() + assert user.is_data_steward is True + + def test_is_data_steward_is_default_false(self): + user = UserFactory() + user.save() + assert user.is_data_steward is False + class TestProjectsInCommon: From cd30a0832dd4c6c02e1dc6dc70199a5e78f37591 Mon Sep 17 00:00:00 2001 From: huanphan-tma Date: Thu, 30 Mar 2023 11:44:38 +0700 Subject: [PATCH 04/37] =?UTF-8?q?refs=20(1)4.1.=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=B2=AC=E4=BB=BB=E8=80=85=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E5=88=B6=E5=BE=A1:=20Update=20UT=20cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api_tests/institutions/views/test_institution_auth.py | 4 ++-- osf_tests/test_user.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/api_tests/institutions/views/test_institution_auth.py b/api_tests/institutions/views/test_institution_auth.py index 61c9d8d6509..c6aa95ddae9 100644 --- a/api_tests/institutions/views/test_institution_auth.py +++ b/api_tests/institutions/views/test_institution_auth.py @@ -524,7 +524,7 @@ def test_authenticate_OrganizationalUnitName_is_valid( assert user assert user.jobs[0]['department'] == organizationnameunit - def test_authenticate_datasteward_on(self, app, institution, url_auth_institution): + def test_authenticate_turn_datasteward_on(self, app, institution, url_auth_institution): username = 'user_datasteward@osf.edu' entitlement = 'GakuNinRDMDataSteward' res = app.post( @@ -536,7 +536,7 @@ def test_authenticate_datasteward_on(self, app, institution, url_auth_institutio assert user assert user.is_data_steward is True - def test_authenticate_datasteward_off(self, app, institution, url_auth_institution): + def test_authenticate_turn_datasteward_off(self, app, institution, url_auth_institution): username = 'user_datasteward@osf.edu' entitlement = '' res = app.post( diff --git a/osf_tests/test_user.py b/osf_tests/test_user.py index b7c36cff4f3..feaf192d25c 100644 --- a/osf_tests/test_user.py +++ b/osf_tests/test_user.py @@ -942,14 +942,12 @@ def test_is_full_account_required_info_exception(self, mock_idp_attr): mock_idp_attr.side_effect = AttributeError('exception') assert_equal(user_auth.is_full_account_required_info, True) - def test_is_data_steward_is_true(self): + def test_is_data_steward_true(self): user = UserFactory(is_data_steward=True) - user.save() assert user.is_data_steward is True - def test_is_data_steward_is_default_false(self): + def test_is_data_steward_default_value_false(self): user = UserFactory() - user.save() assert user.is_data_steward is False From 2d0b8e1d66f856a15e4767fb7ce4e410d51f8995 Mon Sep 17 00:00:00 2001 From: huanphan-tma Date: Fri, 7 Apr 2023 14:15:47 +0700 Subject: [PATCH 05/37] =?UTF-8?q?refs=20(1)4.1.=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=B2=AC=E4=BB=BB=E8=80=85=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E5=88=B6=E5=BE=A1:=20Rename=20migration=20fi?= =?UTF-8?q?le=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...fuser_is_data_steward.py => 0226_osfuser_is_data_steward.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename osf/migrations/{0225_osfuser_is_data_steward.py => 0226_osfuser_is_data_steward.py} (84%) diff --git a/osf/migrations/0225_osfuser_is_data_steward.py b/osf/migrations/0226_osfuser_is_data_steward.py similarity index 84% rename from osf/migrations/0225_osfuser_is_data_steward.py rename to osf/migrations/0226_osfuser_is_data_steward.py index c5cb6f5f593..c1d5a48888b 100644 --- a/osf/migrations/0225_osfuser_is_data_steward.py +++ b/osf/migrations/0226_osfuser_is_data_steward.py @@ -8,7 +8,7 @@ class Migration(migrations.Migration): dependencies = [ - ('osf', '0224_ensure_schema_and_reports'), + ('osf', '0225_add_pattern_and_norm_to_registration_schema_block'), ] operations = [ From bcb00e8dce46c01aee090716d76daf18a9aeb2d0 Mon Sep 17 00:00:00 2001 From: huanphan-tma Date: Tue, 7 Mar 2023 15:59:28 +0700 Subject: [PATCH 06/37] =?UTF-8?q?refs=20(1)4.2.=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=B2=AC=E4=BB=BB=E8=80=85=E3=82=A2=E3=83=89?= =?UTF-8?q?=E3=82=AA=E3=83=B3=E5=AE=9F=E8=A3=85:=20Add=20source=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons.json | 3 +- addons/datasteward/__init__.py | 1 + addons/datasteward/apps.py | 30 +++ addons/datasteward/migrations/__init__.py | 0 addons/datasteward/models.py | 31 +++ addons/datasteward/routes.py | 21 ++ addons/datasteward/serializer.py | 19 ++ addons/datasteward/static/comicon.png | Bin 0 -> 2443 bytes addons/datasteward/static/datasteward.css | 7 + .../static/datastewardUserConfig.js | 222 ++++++++++++++++++ addons/datasteward/static/user-cfg.js | 12 + .../templates/datasteward_modal.mako | 118 ++++++++++ .../templates/datasteward_result_modal.mako | 46 ++++ .../templates/datasteward_user_settings.mako | 15 ++ addons/datasteward/views.py | 165 +++++++++++++ admin/base/settings/defaults.py | 4 +- admin/static/js/rdm_addons/rdm-addons-page.js | 16 +- api/institutions/authentication.py | 7 +- osf/migrations/0226_auto_20230222_1029.py | 25 ++ osf/models/contributor.py | 10 + osf/models/mixins.py | 4 +- website/profile/views.py | 14 +- .../en/LC_MESSAGES/js_messages.po | 12 + .../translations/en/LC_MESSAGES/messages.po | 156 ++++++++++++ .../ja/LC_MESSAGES/js_messages.po | 12 + .../translations/ja/LC_MESSAGES/messages.po | 156 ++++++++++++ website/translations/js_messages.pot | 12 + website/translations/messages.pot | 156 ++++++++++++ 28 files changed, 1264 insertions(+), 10 deletions(-) create mode 100644 addons/datasteward/__init__.py create mode 100644 addons/datasteward/apps.py create mode 100644 addons/datasteward/migrations/__init__.py create mode 100644 addons/datasteward/models.py create mode 100644 addons/datasteward/routes.py create mode 100644 addons/datasteward/serializer.py create mode 100644 addons/datasteward/static/comicon.png create mode 100644 addons/datasteward/static/datasteward.css create mode 100644 addons/datasteward/static/datastewardUserConfig.js create mode 100644 addons/datasteward/static/user-cfg.js create mode 100644 addons/datasteward/templates/datasteward_modal.mako create mode 100644 addons/datasteward/templates/datasteward_result_modal.mako create mode 100644 addons/datasteward/templates/datasteward_user_settings.mako create mode 100644 addons/datasteward/views.py create mode 100644 osf/migrations/0226_auto_20230222_1029.py diff --git a/addons.json b/addons.json index a4e1284e432..2d04017ee2f 100644 --- a/addons.json +++ b/addons.json @@ -31,7 +31,8 @@ "dropboxbusiness", "binderhub", "onedrivebusiness", - "metadata" + "metadata", + "datasteward" ], "addons_default": [ "osfstorage", diff --git a/addons/datasteward/__init__.py b/addons/datasteward/__init__.py new file mode 100644 index 00000000000..255b29f0e90 --- /dev/null +++ b/addons/datasteward/__init__.py @@ -0,0 +1 @@ +default_app_config = 'addons.datasteward.apps.DataStewardAddonAppConfig' diff --git a/addons/datasteward/apps.py b/addons/datasteward/apps.py new file mode 100644 index 00000000000..d1386f81dc9 --- /dev/null +++ b/addons/datasteward/apps.py @@ -0,0 +1,30 @@ +import os + +from addons.base.apps import BaseAddonAppConfig + +HERE = os.path.dirname(os.path.abspath(__file__)) +TEMPLATE_PATH = os.path.join( + HERE, + 'templates' +) + + +class DataStewardAddonAppConfig(BaseAddonAppConfig): + name = 'addons.datasteward' + label = 'addons_datasteward' + full_name = 'DataSteward' + short_name = 'datasteward' + owners = ['user'] + configs = ['accounts'] + user_settings_template = os.path.join(TEMPLATE_PATH, 'datasteward_user_settings.mako') + + actions = () + + @property + def routes(self): + from .routes import api_routes + return [api_routes] + + @property + def user_settings(self): + return self.get_model('UserSettings') diff --git a/addons/datasteward/migrations/__init__.py b/addons/datasteward/migrations/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/addons/datasteward/models.py b/addons/datasteward/models.py new file mode 100644 index 00000000000..7bd779ea609 --- /dev/null +++ b/addons/datasteward/models.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from addons.base.models import (BaseUserSettings, ) +from addons.datasteward.serializer import DataStewardSerializer +from django.db import models + +_provider = 'datasteward' + + +class DataStewardProvider(object): + """An alternative to `ExternalProvider` not tied to OAuth""" + name = 'DataSteward' + short_name = 'datasteward' + serializer = DataStewardSerializer + + def __init__(self, account=None): + super(DataStewardProvider, self).__init__() # this does exactly nothing... + # provide an unauthenticated session by default + self.account = account + + def __repr__(self): + return '<{name}: {status}>'.format( + name=self.__class__.__name__, + status=self.account.provider_id if self.account else 'anonymous' + ) + + +class UserSettings(BaseUserSettings): + oauth_provider = DataStewardProvider + serializer = DataStewardSerializer + + enabled = models.BooleanField(default=False) diff --git a/addons/datasteward/routes.py b/addons/datasteward/routes.py new file mode 100644 index 00000000000..41c043c6964 --- /dev/null +++ b/addons/datasteward/routes.py @@ -0,0 +1,21 @@ +from framework.routing import Rule, json_renderer + +from . import views + +api_routes = { + 'rules': [ + Rule( + '/settings/datasteward/', + 'get', + views.datasteward_user_config_get, + json_renderer, + ), + Rule( + '/settings/datasteward/', + 'post', + views.datasteward_user_config_post, + json_renderer, + ), + ], + 'prefix': '/api/v1' +} diff --git a/addons/datasteward/serializer.py b/addons/datasteward/serializer.py new file mode 100644 index 00000000000..7a35cabe80d --- /dev/null +++ b/addons/datasteward/serializer.py @@ -0,0 +1,19 @@ +from addons.base.serializer import AddonSerializer + + +class DataStewardSerializer(AddonSerializer): + addon_short_name = 'datasteward' + + REQUIRED_URLS = [] + + def addon_serialized_urls(self): + pass + + def serialized_urls(self): + pass + + def user_is_owner(self): + pass + + def credentials_owner(self): + pass diff --git a/addons/datasteward/static/comicon.png b/addons/datasteward/static/comicon.png new file mode 100644 index 0000000000000000000000000000000000000000..81ddf482840763dd0a071fb0b9e805f2ceae4136 GIT binary patch literal 2443 zcmb_e4OA0X77l1w&;=DvIkt9n9CX1WlbKBZX9*mdAc<=zg{(*`yG~{%WNMNLnSmty z*cPeS-GUXX)QU@Y70+t@TkYRj2-*S#3ffk!y5JVArCUI1TWhgOZC?VUy6f)t^lZ*~ znK$o!@80`;_r81Pne430=ot^p5Q#+5MuR>FJZFP3Co%&3pE;D=4jxf1Lq0DO&5R3- zFwu(*b48+v2-dtxSY=v4P@F?T(wv2ncpWZ)7Ku{Qye^Vj%LtH#DP)~m_-gYp7-DHH zoTo5hCYO$}v4&DNlUtf)rb^dR8X8VZg;Kl(FyLSW67o9iPM+{;;hChEN!WLn@6#s+7x>STclTIEG>hREi@~C4tEasS29>!N8lF zwh}q|Ws|=kH;hN$RwP*5S3~)8Wh7(97g~G;eAel^de3^VakG@;VC!k z5?Ia&1uT*lu2|5*AkrWOfwlf%*U3-n1QbI9JE&BG1xQV>b+|$i+=cX#uDgIV6~eiS z-S%LdG=(yD#=$rR9$=**qb?gKaJ-HC52i!gcR2uAFquL=?iq{25pux`86|-6q;~g2 z^JbrmL30?MD|S;%MhOTr0fqt!5D&Xq@J0so)56k#7A`{PW=Mh2gQ0~3NklLWg5zdP zNyu?Rp<0S*2n?HmnmC%Z`u-iNB5)}o$L@lH3ZhAY{GVW&BCMR-K>|{&gDhlFm$MLt zLQ)Yr&d#}kV-TI}&UK?sm+j`PtQ~CdIhhYZ#tfZOs!=KtTr$DTWFm}CULc(mW7KP5 zz*WMsG@+DRaJ9mMBWjXSAaXTLBNmL2A##OsJawK1=dC!y zU=%1(iq>F=+^Ufx7BvNAQ^-_uT285yw0i11&>P%H(*Bd}1ny~|J_rNL3!K|Gd6ROP zqRE+^g@PqPkkmw0d9s9|;mJkz9{hh?{1Zk!HU<>RomCM`wG5w1^#qLPtb&JhGwFpu ztEq00J#`r%Tq?n#Boj%o&cO9pG8G+VBb|i|=u;?+{$x5oE}j3C&JUIQ|D=Nk8q`Fh z(0|QgaPN+02G|FeK!*%WL#-LSgql0!1WLI<>nNR@bQclha~qS&wBW4fO=Oh1*}e)0KUY(Df@<+86iJJzLq8+Pqcm>dMSL{_JngZgV(Pw~EU)%_0=*Qs$oQ|L)Rw-Inp&;l`9K z;fdy7d;9|*XyZ0+%(o_l=N2ug%l@KjpY@16KE>~g9zc2ygkStN@5$4D=XW;^oi9&b z9cFuA-`V&-)0@Q=329`KZNu=4bm>s-Sww~I9Es%P_UySF)Bn~#I#r6kU5Q8kdH;dO z`_|Oy?a4iv-8oBJ-#E1QHSc(R?(M&Pv&?iUz9Z=u5u)d&8}}EC4cUkI(X_hN{(Y~e znOny2v4*jXt*^J%zO!KUV8pq$C3R>^$>MVVaPRs>#?2pdqN`orxWhZ!(x%_6eoHp3 zOmbsm@$c~MhSzp?Su3hHEnmN5tEqlN>HPN68CkWw`h^>|m^FxRPfbbZoDUajVr!cW zXO)f36|Jr@&!1{`4PAUD3AJ|h<)t;pqotju!Q-Y@x7JiQvr6}~TQ>(T^nFvl{q$4g ziA-0NqQR_a{N+e|bFJ@yWl>D#-q_x5<&Eeg<}<$T#s$mg7#GiKJX7z>m>v67Y|FGT z!55Bg|Els4w7W7Ly?dnjPxd$$CBm_WzIV=*_cq+; zNOoR-@6v}n(b&X$2zw!PR>q~#^kNNq-&PdD$V{K!t{?3lFLx6jN?(^((2b1?hp)C>Z!O^Z>&JD214kb( zyv&}{Jz-ceuV!PDS=za~`h?{a95?3$$F*0!9UXZ&%zJz0=f@IKSI#?r$a0_~GNFI$ R<-q5XF(XTV@S!!8-vj$cjyV7T literal 0 HcmV?d00001 diff --git a/addons/datasteward/static/datasteward.css b/addons/datasteward/static/datasteward.css new file mode 100644 index 00000000000..af21ee74095 --- /dev/null +++ b/addons/datasteward/static/datasteward.css @@ -0,0 +1,7 @@ +.datasteward-checkbox { + float: right; +} + +.datasteward-line-break { + white-space: break-spaces; +} diff --git a/addons/datasteward/static/datastewardUserConfig.js b/addons/datasteward/static/datastewardUserConfig.js new file mode 100644 index 00000000000..18804eb4542 --- /dev/null +++ b/addons/datasteward/static/datastewardUserConfig.js @@ -0,0 +1,222 @@ +/** +* Module that controls the DataSteward user settings. Includes Knockout view-model +* for syncing data. +*/ + +var ko = require('knockout'); +var $ = require('jquery'); +var Raven = require('raven-js'); +var bootbox = require('bootbox'); +require('js/osfToggleHeight'); + +var language = require('js/osfLanguage').Addons.dataverse; +var osfHelpers = require('js/osfHelpers'); +var addonSettings = require('js/addonSettings'); + +var $modal = $('#datastewardModal'); +var $resultModal = $('#datastewardResultModal'); +var _ = require('js/rdmGettext')._; + +function ViewModel(url) { + var self = this; + + self.properName = 'DataSteward'; + self.dialog_closed_by_user = ko.observable(false); + + // Whether the initial data has been loaded + self.addon_enabled = ko.observable(false); + self.loaded = ko.observable(false); + self.is_processing = ko.observable(false); + self.is_process_failed = ko.observable(false); + self.skipped_projects = ko.observable([]); + + // Flashed messages + self.message = ko.observable(''); + self.messageClass = ko.observable('text-info'); + + $modal.on("hidden.bs.modal", function () { + if (self.dialog_closed_by_user()) { + self.addon_enabled(!self.addon_enabled()); + self.dialog_closed_by_user(false); + } else { + self.is_processing(false); + $resultModal.modal('show'); + } + }); + + $resultModal.on("hidden.bs.modal", function () { + if (self.is_process_failed()) { + self.addon_enabled(!self.addon_enabled()); + self.is_process_failed(false); + } + self.skipped_projects([]); + }); + + /** Reset all fields from Dataverse host selection modal */ + self.clearModal = function() { + $modal.modal('hide'); + self.dialog_closed_by_user(true); + }; + + self.clearResultModal = function() { + $resultModal.modal('hide'); + } + + /** Enable add on **/ + self.enableAddon = function() { + self.is_processing(true); + var data = { + 'enabled': self.addon_enabled() + }; + $.ajax({ + url: url, + type: 'POST', + contentType: 'application/json', + data: JSON.stringify(data) + }).done(function (response) { + $modal.modal('hide'); + }).fail(function (xhr, textStatus, error) { + self.is_process_failed(true); + $modal.modal('hide'); + }); + }; + + /** Disable add on **/ + self.disableAddon = function() { + self.is_processing(true); + var data = { + 'enabled': self.addon_enabled() + }; + $.ajax({ + url: url, + type: 'POST', + contentType: 'application/json', + data: JSON.stringify(data) + }).done(function (response) { + var skipped_projects = response.skipped_projects; + self.skipped_projects(skipped_projects); + $modal.modal('hide'); + }).fail(function (xhr, textStatus, error) { + self.is_processing(false); + self.changeMessage(language.userSettingsError, 'text-danger'); + Raven.captureMessage('Could not disable DataSteward add-on', { + extra: { + url: url, + textStatus: textStatus, + error: error + } + }); + }); + }; + + /** Change the flashed status message */ + self.changeMessage = function(text, css, timeout) { + self.message(text); + var cssClass = css || 'text-info'; + self.messageClass(cssClass); + if (timeout) { + // Reset message after timeout period + setTimeout(function() { + self.message(''); + self.messageClass('text-info'); + }, timeout); + } + }; + + // Update observables with data from the server + self.fetch = function() { + $.ajax({ + url: url, + type: 'GET', + dataType: 'json' + }).done(function (response) { + var enabled = response.enabled; + self.addon_enabled(enabled); + self.loaded(true); + }).fail(function (xhr, textStatus, error) { + self.changeMessage(language.userSettingsError, 'text-danger'); + Raven.captureMessage('Could not GET DataSteward settings', { + extra: { + url: url, + textStatus: textStatus, + error: error + } + }); + }); + }; + + self.toggleCheckbox = function() { + $modal.modal('show'); + }; + + self.clickCSV = function () { + var skipped_projects = self.skipped_projects(); + if (!skipped_projects) { + return; + } + + var rows = skipped_projects.map(project => [ + project['guid'], + project['name'] + ]); + + exportToCsv('skipped_projects.csv', rows); + } + + function exportToCsv(filename, rows) { + var processRow = function (row) { + var finalVal = ''; + for (var j = 0; j < row.length; j++) { + var innerValue = row[j] === null ? '' : row[j].toString(); + if (row[j] instanceof Date) { + innerValue = row[j].toLocaleString(); + }; + var result = innerValue.replace(/"/g, '""'); + if (result.search(/("|,|\n)/g) >= 0) + result = '"' + result + '"'; + if (j > 0) + finalVal += ','; + finalVal += result; + } + return finalVal + '\n'; + }; + + var csvFile = ''; + for (var i = 0; i < rows.length; i++) { + csvFile += processRow(rows[i]); + } + + var blob = new Blob([csvFile], { type: 'text/csv;charset=utf-8;' }); + if (navigator.msSaveBlob) { // IE 10+ + navigator.msSaveBlob(blob, filename); + } else { + var link = document.createElement("a"); + if (link.download !== undefined) { // feature detection + // Browsers that support HTML5 download attribute + var url = URL.createObjectURL(blob); + link.setAttribute("href", url); + link.setAttribute("download", filename); + link.style.visibility = 'hidden'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + URL.revokeObjectURL(url); + } + } + } +} + +function DataStewardUserConfig(selector, url) { + // Initialization code + var self = this; + self.selector = selector; + self.url = url; + // On success, instantiate and bind the ViewModel + self.viewModel = new ViewModel(url); + osfHelpers.applyBindings(self.viewModel, self.selector); +} + +module.exports = { + DataStewardViewModel: ViewModel, + DataStewardUserConfig: DataStewardUserConfig // for backwards-compat +}; diff --git a/addons/datasteward/static/user-cfg.js b/addons/datasteward/static/user-cfg.js new file mode 100644 index 00000000000..abb2f269b54 --- /dev/null +++ b/addons/datasteward/static/user-cfg.js @@ -0,0 +1,12 @@ +require('./datasteward.css'); +var $osf = require('js/osfHelpers'); +var DataStewardViewModel = require('./datastewardUserConfig.js').DataStewardViewModel; + +// Endpoint for DataSteward user settings +var url = '/api/v1/settings/datasteward/'; + +var datastewardViewModel = new DataStewardViewModel(url); +$osf.applyBindings(datastewardViewModel, '#datastewardAddonScope'); + +// Load initial DataSteward data +datastewardViewModel.fetch(); diff --git a/addons/datasteward/templates/datasteward_modal.mako b/addons/datasteward/templates/datasteward_modal.mako new file mode 100644 index 00000000000..4627d4f5674 --- /dev/null +++ b/addons/datasteward/templates/datasteward_modal.mako @@ -0,0 +1,118 @@ +## -*- coding: utf-8 -*- + diff --git a/addons/datasteward/templates/datasteward_result_modal.mako b/addons/datasteward/templates/datasteward_result_modal.mako new file mode 100644 index 00000000000..45250df496e --- /dev/null +++ b/addons/datasteward/templates/datasteward_result_modal.mako @@ -0,0 +1,46 @@ +## -*- coding: utf-8 -*- + diff --git a/addons/datasteward/templates/datasteward_user_settings.mako b/addons/datasteward/templates/datasteward_user_settings.mako new file mode 100644 index 00000000000..693cf8fc88a --- /dev/null +++ b/addons/datasteward/templates/datasteward_user_settings.mako @@ -0,0 +1,15 @@ +
+ + <%include file="datasteward_modal.mako"/> + <%include file="datasteward_result_modal.mako"/> + +

+ + ${ addon_full_name } + + + +

+
diff --git a/addons/datasteward/views.py b/addons/datasteward/views.py new file mode 100644 index 00000000000..83b60103141 --- /dev/null +++ b/addons/datasteward/views.py @@ -0,0 +1,165 @@ +"""Views for the node settings page.""" +# -*- coding: utf-8 -*- +from rest_framework import status as http_status + +from framework.auth.decorators import must_be_logged_in +from flask import request + +from addons.base import generic_views +from addons.datasteward.serializer import DataStewardSerializer +from django.core.exceptions import ObjectDoesNotExist +from django.db import transaction, DatabaseError, IntegrityError +from osf.utils.permissions import ADMIN +from osf.exceptions import NodeStateError + +import logging + +logger = logging.getLogger(__name__) + +SHORT_NAME = 'datasteward' +FULL_NAME = 'DataSteward' +OSF_NODE = 'osf.node' + +datasteward_get_config = generic_views.get_config( + SHORT_NAME, + DataStewardSerializer +) + + +@must_be_logged_in +def datasteward_user_config_get(auth, **kwargs): + """View for getting a JSON representation of DataSteward user settings""" + addon_user_settings = auth.user.get_addon(SHORT_NAME) + + return { + 'enabled': addon_user_settings.enabled if addon_user_settings else False, + }, http_status.HTTP_200_OK + + +@must_be_logged_in +def datasteward_user_config_post(auth, **kwargs): + data = request.get_json() + enabled = data.get('enabled', None) + if enabled is None or not isinstance(enabled, bool): + # If request's 'enabled' field is not valid then return HTTP 400 + return {}, http_status.HTTP_400_BAD_REQUEST + + if not auth.user.is_data_steward: + # If user is not a DataSteward then return HTTP 403 + return {}, http_status.HTTP_403_FORBIDDEN + + addon_user_settings = auth.user.get_addon(SHORT_NAME) + if not addon_user_settings: + # Failsafe: If user does not have DataSteward add-on settings then return HTTP 403 + return {}, http_status.HTTP_403_FORBIDDEN + + # Update add-on user settings + addon_user_settings.enabled = enabled + addon_user_settings.save() + + if enabled: + # 4.2.2: Enable DataSteward addon process + result = enable_datasteward_addon(auth) + + if not result: + return {}, http_status.HTTP_500_INTERNAL_SERVER_ERROR + + return {}, http_status.HTTP_200_OK + else: + # 4.2.4: Disable DataSteward addon process + skipped_projects = disable_datasteward_addon(auth) + + if skipped_projects is None: + return {}, http_status.HTTP_500_INTERNAL_SERVER_ERROR + + response_body = [{'guid': project._id, 'name': project.title} for project in skipped_projects] + + return {'skipped_projects': response_body}, http_status.HTTP_200_OK + + +def enable_datasteward_addon(auth, is_from_auth=False, **kwargs): + # Check if user has any affiliated institutions + user = auth.user + institutions = user.affiliated_institutions.all() + if not institutions: + return False + + # Get projects from institutions + with transaction.atomic(): + for institution in institutions: + # Get projects from institution + projects = institution.nodes.filter(type=OSF_NODE, is_deleted=False) + for project in projects: + try: + if not project.is_contributor(user): + # If user is not project's contributor then add user to contributor list + result = project.add_contributor(user, permissions=ADMIN, visible=True, send_email=None, + auth=auth, log=True, save=False) + if result: + contributor = project.contributor_class.objects.get(user=user, node=project) + contributor.is_data_steward = True + contributor.save() + else: + # Otherwise, promote user's permission to Project Administrator + contributor = project.contributor_class.objects.get(user=user, node=project) + if not contributor.is_data_steward: + # If user is not already a data steward then set data steward role to user and save old permission for later recovery + contributor.is_data_steward = True + contributor.data_steward_old_permission = contributor.permission + project.update_contributor(user, permission=ADMIN, visible=True, auth=auth, save=False, admin_check=False) + contributor.save() + except (DatabaseError, IntegrityError) as e: + # If error occurred while manipulating DB then ignore it + logger.warning(e) + except Exception as e: + # If currently running on "Configure add-on accounts" screen then throws error + # Otherwise, ignore it + if not is_from_auth: + raise e + + return True + + +def disable_datasteward_addon(auth, **kwargs): + # Check if user has any affiliated institutions + user = auth.user + institutions = user.affiliated_institutions.all() + if not institutions: + return None + + # Get projects from institutions + skipped_projects = [] + for institution in institutions: + # Get projects from institution + projects = institution.nodes.filter(type=OSF_NODE, is_deleted=False) + for project in projects: + try: + # If user is not contributor of project then skip + if not project.is_contributor(user): + continue + + contributor = project.contributor_class.objects.get(user=user, node=project) + + # If user is not data steward of project then skip + if not contributor.is_data_steward: + continue + + if contributor.data_steward_old_permission is not None: + # If user had contributor's permission in project then restore that permission + project.update_contributor(user, permission=contributor.data_steward_old_permission, visible=True, + auth=auth, save=False, admin_check=False) + contributor.is_data_steward = False + contributor.data_steward_old_permission = None + contributor.save() + else: + # Otherwise, remove user from project's contributor list + result = project.remove_contributor(user, auth=auth) + if not result: + skipped_projects.append(project) + except (DatabaseError, IntegrityError, NodeStateError, ObjectDoesNotExist) as e: + # If DatabaseError, IntegrityError, NodeStateError or ObjectDoesNotExist are raised + # Log warning, add project to skipped project list + logger.warning(e) + skipped_projects.append(project) + + return skipped_projects diff --git a/admin/base/settings/defaults.py b/admin/base/settings/defaults.py index 781fab031dd..27529cc9bd9 100644 --- a/admin/base/settings/defaults.py +++ b/admin/base/settings/defaults.py @@ -139,6 +139,7 @@ 'addons.ociinstitutions', 'addons.onedrivebusiness', 'addons.metadata', + 'addons.datasteward', ) MIGRATION_MODULES = { @@ -185,7 +186,8 @@ 'nextcloud', 'gitlab', 'onedrive', - 'iqbrims' + 'iqbrims', + 'datasteward' ] USE_TZ = True diff --git a/admin/static/js/rdm_addons/rdm-addons-page.js b/admin/static/js/rdm_addons/rdm-addons-page.js index d6d8fa70db7..8cb529aec12 100644 --- a/admin/static/js/rdm_addons/rdm-addons-page.js +++ b/admin/static/js/rdm_addons/rdm-addons-page.js @@ -60,12 +60,20 @@ $('.is_allowed input').on('change', function() { } else { var deletionKey = Math.random().toString(36).slice(-8); var id = addonName + "DeleteKey"; - bootbox.confirm({ - title: sprintf(_("Disallow %s?"),$osf.htmlEscape(addonFullName)), - message: sprintf(_("Are you sure you want to disallow the %1$s?
"),$osf.htmlEscape(addonFullName)) + + var message = sprintf(_("Are you sure you want to disallow the %1$s?
"),$osf.htmlEscape(addonFullName)) + sprintf(_("This will revoke access to %1$s for all projects using the accounts.

"),$osf.htmlEscape(addonFullName)) + sprintf(_("Type the following to continue: %1$s

"),$osf.htmlEscape(deletionKey)) + - "", + ""; + if (addonName === 'datasteward') { + message = sprintf(_("Are you sure you want to disallow the %1$s?
"),$osf.htmlEscape(addonFullName)) + + sprintf(_("This will not revoke access to %1$s for all projects using the accounts.
"),$osf.htmlEscape(addonFullName)) + + sprintf(_("But the accounts will not be able to see and change their %1$s settings until you reallow it.

"),$osf.htmlEscape(addonFullName)) + + sprintf(_("Type the following to continue: %1$s

"),$osf.htmlEscape(deletionKey)) + + "" + } + bootbox.confirm({ + title: sprintf(_("Disallow %s?"),$osf.htmlEscape(addonFullName)), + message: message, buttons: { cancel: { label: _('Cancel') diff --git a/api/institutions/authentication.py b/api/institutions/authentication.py index 3b417356a78..70cfc7a7e6c 100644 --- a/api/institutions/authentication.py +++ b/api/institutions/authentication.py @@ -12,10 +12,11 @@ from api.base.authentication import drf from api.base import exceptions, settings +from addons.datasteward.views import enable_datasteward_addon from framework import sentry from framework.auth import get_or_create_user -from framework.auth.core import get_user +from framework.auth.core import get_user, Auth from osf import features from osf.models import Institution, UserExtendedData @@ -414,6 +415,10 @@ def get_next(obj, *args): # Set user.is_data_steward to True user.is_data_steward = True user.save() + addon_user_settings = user.get_addon('datasteward') + if addon_user_settings and addon_user_settings.enabled: + auth = Auth(user=user) + enable_datasteward_addon(auth, is_from_auth=True) else: # Set user.is_data_steward to False user.is_data_steward = False diff --git a/osf/migrations/0226_auto_20230222_1029.py b/osf/migrations/0226_auto_20230222_1029.py new file mode 100644 index 00000000000..0c8215531ba --- /dev/null +++ b/osf/migrations/0226_auto_20230222_1029.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.28 on 2023-02-22 10:29 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osf', '0225_osfuser_is_data_steward'), + ] + + operations = [ + migrations.AddField( + model_name='contributor', + name='data_steward_old_permission', + field=models.CharField(choices=[('NULL', None), ('READ', 'read'), ('WRITE', 'write'), ('ADMIN', 'admin')], max_length=255, null=True), + ), + migrations.AddField( + model_name='contributor', + name='is_data_steward', + field=models.BooleanField(db_index=True, default=False), + ), + ] diff --git a/osf/models/contributor.py b/osf/models/contributor.py index 9149c82c57e..a1979354351 100644 --- a/osf/models/contributor.py +++ b/osf/models/contributor.py @@ -5,6 +5,14 @@ from osf.utils import permissions +CONTRIBUTOR_PERMISSION_CHOICES = ( + ("NULL", None), + ("READ", "read"), + ("WRITE", "write"), + ("ADMIN", "admin"), +) + + class AbstractBaseContributor(models.Model): objects = IncludeManager() @@ -33,6 +41,8 @@ def permission(self): class Contributor(AbstractBaseContributor): node = models.ForeignKey('AbstractNode', on_delete=models.CASCADE) + is_data_steward = models.BooleanField(default=False, db_index=True) + data_steward_old_permission = models.CharField(null=True, max_length=255, choices=CONTRIBUTOR_PERMISSION_CHOICES) @property def _id(self): diff --git a/osf/models/mixins.py b/osf/models/mixins.py index 5d81cca4a10..0c5fa247160 100644 --- a/osf/models/mixins.py +++ b/osf/models/mixins.py @@ -1586,7 +1586,7 @@ def copy_unclaimed_records(self, resource): contributor.save() # TODO: optimize me - def update_contributor(self, user, permission, visible, auth, save=False): + def update_contributor(self, user, permission, visible, auth, save=False, admin_check=True): """ TODO: this method should be updated as a replacement for the main loop of Node#manage_contributors. Right now there are redundancies, but to avoid major feature creep this will not be included as this time. @@ -1595,7 +1595,7 @@ def update_contributor(self, user, permission, visible, auth, save=False): """ OSFUser = apps.get_model('osf.OSFUser') - if not self.has_permission(auth.user, ADMIN): + if not self.has_permission(auth.user, ADMIN) and admin_check: raise PermissionsError('Only admins can modify contributor permissions') if permission: diff --git a/website/profile/views.py b/website/profile/views.py index ad77e41deb9..c010004fc29 100644 --- a/website/profile/views.py +++ b/website/profile/views.py @@ -39,6 +39,7 @@ from website.util import api_v2_url, web_url_for, paths from website.util.sanitize import escape_html from addons.base import utils as addon_utils +from addons.datasteward.models import UserSettings as DataStewardUserSettings from admin.rdm_addons.utils import validate_rdm_addons_allowed from api.waffle.utils import storage_i18n_flag_active @@ -415,6 +416,17 @@ def user_addons(auth, **kwargs): ret = { 'addon_settings': addon_utils.get_addons_by_config_type('accounts', user), } + + # Create DataSteward addon settings if user is data steward but does not have addon settings + if not user.has_addon('datasteward') and user.is_data_steward: + user.add_addon('datasteward') + + datasteward_user_settings = user.get_addon('datasteward') + + # DataSteward add-on check to be displayed + ret['addon_settings'] = [s for s in ret['addon_settings'] + if s['addon_short_name'] != 'datasteward' or user.is_data_steward or (datasteward_user_settings and datasteward_user_settings.enabled)] + # RDM from admin.rdm_addons import utils as rdm_utils rdm_utils.update_with_rdm_addon_settings(ret['addon_settings'], user) @@ -422,7 +434,7 @@ def user_addons(auth, **kwargs): ret['addon_settings'] = [addon for addon in ret['addon_settings'] if addon['is_allowed']] accounts_addons = [addon for addon in settings.ADDONS_AVAILABLE - if 'accounts' in addon.configs and allowed_addon_dict[addon.short_name]] + if 'accounts' in addon.configs and allowed_addon_dict.get(addon.short_name)] ret.update({ 'addon_enabled_settings': [addon.short_name for addon in accounts_addons], 'addons_js': collect_user_config_js(accounts_addons), diff --git a/website/translations/en/LC_MESSAGES/js_messages.po b/website/translations/en/LC_MESSAGES/js_messages.po index 46fa84f073d..6d87b600bcf 100644 --- a/website/translations/en/LC_MESSAGES/js_messages.po +++ b/website/translations/en/LC_MESSAGES/js_messages.po @@ -497,6 +497,18 @@ msgstr "" msgid "Type the following to continue: %1$s

" msgstr "" +#: admin/static/js/rdm_addons/rdm-addons-page.js:69 +msgid "" +"This will not revoke access to %1$s for all projects using the " +"accounts.
" +msgstr "" + +#: admin/static/js/rdm_addons/rdm-addons-page.js:70 +msgid "" +"But the accounts will not be able to see and change their %1$s settings " +"until you reallow it.

" +msgstr "" + #: admin/static/js/rdm_addons/rdm-addons-page.js:74 msgid "Disallow" msgstr "" diff --git a/website/translations/en/LC_MESSAGES/messages.po b/website/translations/en/LC_MESSAGES/messages.po index 72d58b3c166..0144776ffea 100644 --- a/website/translations/en/LC_MESSAGES/messages.po +++ b/website/translations/en/LC_MESSAGES/messages.po @@ -406,6 +406,162 @@ msgid "" "%(authOsfName)s to verify." msgstr "" +#: addons/datasteward/templates/datasteward_modal.mako:7 +msgid "Enable DataSteward add-on" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:14 +msgid "Before enabling DataSteward add-on, the following are the implementation details and points to note:" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:16 +msgid "* You will be automatically added as a project administrator for all projects of your institution." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:17 +msgid " * If you have already been added in the project before enabling this add-on, you will be promoted to a project administrator." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:18 +msgid " * Project administrators added by this add-on have the same authority as project administrators added in the normal procedure." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:20 +msgid "* After enabling this add-on, newly created projects will not be automatically added as project administrators." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:21 +msgid " * If you log in again with GakuNinRDMDataSteward assigned to the IdP's eduPersonEntitlement attribute and with this add-on enabled, you will be automatically be added as a project administrator for unregistered projects." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:23 +msgid "* To enable this add-on, the value of GakuNinRDMDataSteward must be assigned to the IdP's eduPersonEntitlement attribute." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:24 +msgid " * This add-on will not be disabled simply by removing GakuNinRDMDataSteward from the eduPersonEntitlement attribute." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:25 +msgid " * In order to disable this add-on (remove project as a project administrator), it is necessary to disable this add-on separately." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:27 +msgid "* Each data steward must enable this add-on by themselves." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:28 +msgid " * The number of project administrators participating in the project will increase by the number of different data stewards." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:30 +msgid "* If the number of target projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:32 +msgid "Do you want to enable DataSteward add-on?" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:46 +msgid "User add-on enable" +msgstr "Enable" + +#: addons/datasteward/templates/datasteward_modal.mako:56 +msgid "Enabling DataSteward add-on, please do not close this window or go back on your browser." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:66 +msgid "Disable DataSteward add-on" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:73 +msgid "Before disabling DataSteward add-on, the following are implementation details and points to note:" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:75 +msgid "* Disabling this add-on will remove you from the project that was automatically added as a project administrator when this add-on was enabled." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:76 +msgid " * If your permission is elevated to a project administrator when this add-on is enabled, the permission before this add-on is activated will be restored." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:78 +msgid "* When disabling this add-on, if there is only one administrator for the project, the revert process will be skipped." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:79 +msgid " * For skipped projects, the result can be downloaded in the disable add-on result dialog." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:80 +msgid " * Please manually update the project contributors based on the skipped results." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:82 +msgid "* After disabling this add-on, in order to enable it again, the value of GakuNinRDMDataSteward must be assigned to the eduPersonEntitlement attribute of the IdP." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:84 +msgid "* If you want to revert project registration for all data stewards, each data steward must disable this add-on." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:86 +msgid "* If the number of affected projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:88 +msgid "Do you want to disable DataSteward add-on?" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:102 +msgid "User add-on disable" +msgstr "Disable" + +#: addons/datasteward/templates/datasteward_modal.mako:112 +msgid "Disabling DataSteward add-on, please do not close this window or go back on your browser." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:6 +msgid "DataSteward add-on enabled" +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:7 +msgid "DataSteward add-on disabled" +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:15 +msgid "DataSteward add-on enable process is completed." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:18 +msgid "DataSteward add-on enable process has failed." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:22 +msgid "DataSteward add-on disable process is completed." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:24 +msgid "No projects failed to unregister when disabling add-on." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:27 +msgid "There were %(count)s projects that could not be unregistered when disabling add-on." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:29 +msgid "For more details, download the CSV from the link below and refer to it." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:30 +msgid "Please note that you will not be able to refer to this download once the dialog is closed." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:32 +msgid "Disable result CSV download" +msgstr "" + #: addons/dataverse/templates/dataverse_credentials_modal.mako:6 msgid "Connect a Dataverse Account" msgstr "" diff --git a/website/translations/ja/LC_MESSAGES/js_messages.po b/website/translations/ja/LC_MESSAGES/js_messages.po index 81fa3a10751..0b421dab635 100644 --- a/website/translations/ja/LC_MESSAGES/js_messages.po +++ b/website/translations/ja/LC_MESSAGES/js_messages.po @@ -501,6 +501,18 @@ msgstr "これにより、アカウントを使用するすべてのプロジェ msgid "Type the following to continue: %1$s

" msgstr "次を入力して続行します。%1$s

" +#: admin/static/js/rdm_addons/rdm-addons-page.js:69 +msgid "" +"This will not revoke access to %1$s for all projects using the " +"accounts.
" +msgstr "これにより、アカウントを使用するすべてのプロジェクトの%1$sへのアクセスが取り消されるわけではありません。
" + +#: admin/static/js/rdm_addons/rdm-addons-page.js:70 +msgid "" +"But the accounts will not be able to see and change their %1$s settings " +"until you reallow it.

" +msgstr "ただし、許可するまで、アカウントは%1$s設定を表示および変更できません。

" + #: admin/static/js/rdm_addons/rdm-addons-page.js:74 msgid "Disallow" msgstr "禁止" diff --git a/website/translations/ja/LC_MESSAGES/messages.po b/website/translations/ja/LC_MESSAGES/messages.po index 8db03b62885..938e102676e 100644 --- a/website/translations/ja/LC_MESSAGES/messages.po +++ b/website/translations/ja/LC_MESSAGES/messages.po @@ -409,6 +409,162 @@ msgstr "" "現在、%(addonName)s 設定を取得できませんでした。%(addonName)sアドオンの認証情報が無効になる場合があります。 " "%(authOsfName)sに連絡して確認してください。" +#: addons/datasteward/templates/datasteward_modal.mako:7 +msgid "Enable DataSteward add-on" +msgstr "データ管理責任者アドオン 有効化" + +#: addons/datasteward/templates/datasteward_modal.mako:14 +msgid "Before enabling DataSteward add-on, the following are the implementation details and points to note:" +msgstr "データ管理責任者アドオンを有効化します。\n以下に有効化時の実施内容と、注意点を記載します。" + +#: addons/datasteward/templates/datasteward_modal.mako:16 +msgid "* You will be automatically added as a project administrator for all projects of your institution." +msgstr "* 所属する機関の全てのプロジェクトに対し、プロジェクト管理者として自動で登録されます。" + +#: addons/datasteward/templates/datasteward_modal.mako:17 +msgid " * If you have already been added in the project before enabling this add-on, you will be promoted to a project administrator." +msgstr " * 本アドオン有効化前に、既にプロジェクトに登録済みの場合、プロジェクト管理者に権限昇格されます。" + +#: addons/datasteward/templates/datasteward_modal.mako:18 +msgid " * Project administrators added by this add-on have the same authority as project administrators added in the normal procedure." +msgstr " * 本アドオンによって登録されたプロジェクト管理者は、通常手順で追加されたプロジェクト管理者と同じ権限となります。" + +#: addons/datasteward/templates/datasteward_modal.mako:20 +msgid "* After enabling this add-on, newly created projects will not be automatically added as project administrators." +msgstr "* 本アドオン有効化後、新規に作成されたプロジェクトには、自動ではプロジェクト管理者として登録されません。" + +#: addons/datasteward/templates/datasteward_modal.mako:21 +msgid " * If you log in again with GakuNinRDMDataSteward assigned to the IdP's eduPersonEntitlement attribute and with this add-on enabled, you will be automatically be added as a project administrator for unregistered projects." +msgstr " * IdPのeduPersonEntitlement属性にGakuNinRDMDataStewardが付与されている状態かつ、本アドオンを有効化した状態で再ログインをすると、未登録のプロジェクトにプロジェクト管理者として自動で登録されます。" + +#: addons/datasteward/templates/datasteward_modal.mako:23 +msgid "* To enable this add-on, the value of GakuNinRDMDataSteward must be assigned to the IdP's eduPersonEntitlement attribute." +msgstr "* 本アドオンの有効化には、IdPのeduPersonEntitlement属性にGakuNinRDMDataStewardの値が付与されている必要があります。" + +#: addons/datasteward/templates/datasteward_modal.mako:24 +msgid " * This add-on will not be disabled simply by removing GakuNinRDMDataSteward from the eduPersonEntitlement attribute." +msgstr " * なお、eduPersonEntitlement属性からGakuNinRDMDataStewardを外しただけでは、本アドオンは無効化されません。" + +#: addons/datasteward/templates/datasteward_modal.mako:25 +msgid " * In order to disable this add-on (remove project as a project administrator), it is necessary to disable this add-on separately." +msgstr " * 本アドオンを無効化(プロジェクト管理者の登録解除)をするためには、別途本アドオンの無効化が必要です。" + +#: addons/datasteward/templates/datasteward_modal.mako:27 +msgid "* Each data steward must enable this add-on by themselves." +msgstr "* 「データ管理責任者」それぞれが、本アドオンを有効化する必要があります。" + +#: addons/datasteward/templates/datasteward_modal.mako:28 +msgid " * The number of project administrators participating in the project will increase by the number of different data stewards." +msgstr " * 異なる「データ管理責任者」の人数分、プロジェクトに参加するプロジェクト管理者が増えます。" + +#: addons/datasteward/templates/datasteward_modal.mako:30 +msgid "* If the number of target projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgstr "* 対象プロジェクト数が多い場合、有効化の処理時に時間がかかる(最大30秒程度)ため、別の画面への移動や画面を閉じることをせず、処理が終わるまで待機してください。" + +#: addons/datasteward/templates/datasteward_modal.mako:32 +msgid "Do you want to enable DataSteward add-on?" +msgstr "データ管理責任者アドオンを有効化しますか?" + +#: addons/datasteward/templates/datasteward_modal.mako:46 +msgid "User add-on enable" +msgstr "有効化" + +#: addons/datasteward/templates/datasteward_modal.mako:56 +msgid "Enabling DataSteward add-on, please do not close this window or go back on your browser." +msgstr "データ管理責任者アドオンを有効にします。 このウィンドウを閉じたり、ブラウザに戻ったりしないでください。" + +#: addons/datasteward/templates/datasteward_modal.mako:66 +msgid "Disable DataSteward add-on" +msgstr "データ管理責任者アドオン 無効化" + +#: addons/datasteward/templates/datasteward_modal.mako:73 +msgid "Before disabling DataSteward add-on, the following are implementation details and points to note:" +msgstr "データ管理責任者アドオンを無効化します。\n以下に無効化時の実施内容と、注意点を記載します。" + +#: addons/datasteward/templates/datasteward_modal.mako:75 +msgid "* Disabling this add-on will remove you from the project that was automatically added as a project administrator when this add-on was enabled." +msgstr "* 本アドオン有効化時にプロジェクト管理者として自動で登録されたプロジェクトから、登録解除します。" + +#: addons/datasteward/templates/datasteward_modal.mako:76 +msgid " * If your permission is elevated to a project administrator when this add-on is enabled, the permission before this add-on is activated will be restored." +msgstr " * 本アドオン有効化時にプロジェクト管理者に権限昇格された場合、本アドオン有効化前の権限に戻します。" + +#: addons/datasteward/templates/datasteward_modal.mako:78 +msgid "* When disabling this add-on, if there is only one administrator for the project, the revert process will be skipped." +msgstr "* 本アドオン無効化時、プロジェクトに対する管理者が一人のみの場合、登録解除処理はスキップされます。" + +#: addons/datasteward/templates/datasteward_modal.mako:79 +msgid " * For skipped projects, the result can be downloaded in the disable add-on result dialog." +msgstr " * スキップされたプロジェクトは、アドオン無効化結果ポップアップにて結果がダウンロードできます。" + +#: addons/datasteward/templates/datasteward_modal.mako:80 +msgid " * Please manually update the project contributors based on the skipped results." +msgstr " * スキップされた結果を元に、手動でプロジェクトへの参加者の更新をしてください。" + +#: addons/datasteward/templates/datasteward_modal.mako:82 +msgid "* After disabling this add-on, in order to enable it again, the value of GakuNinRDMDataSteward must be assigned to the eduPersonEntitlement attribute of the IdP." +msgstr "* 本アドオン無効化後、再度有効化するためには、IdPのeduPersonEntitlement属性にGakuNinRDMDataStewardの値が付与されている必要があります。" + +#: addons/datasteward/templates/datasteward_modal.mako:84 +msgid "* If you want to revert project registration for all data stewards, each data steward must disable this add-on." +msgstr "* 「データ管理責任者」全ての登録を解除したい場合、「データ管理責任者」それぞれが、本アドオンを無効化する必要があります。" + +#: addons/datasteward/templates/datasteward_modal.mako:86 +msgid "* If the number of affected projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgstr "* 対象プロジェクト数が多い場合、無効化の処理時に時間がかかる(最大30秒程度)ため、別の画面への移動や画面を閉じることをせず、処理が終わるまで待機してください。" + +#: addons/datasteward/templates/datasteward_modal.mako:88 +msgid "Do you want to disable DataSteward add-on?" +msgstr "データ管理責任者アドオンを無効化しますか?" + +#: addons/datasteward/templates/datasteward_modal.mako:102 +msgid "User add-on disable" +msgstr "無効化" + +#: addons/datasteward/templates/datasteward_modal.mako:112 +msgid "Disabling DataSteward add-on, please do not close this window or go back on your browser." +msgstr "データ管理責任者アドオンを無効にしています。このウィンドウを閉じたり、ブラウザに戻ったりしないでください。" + +#: addons/datasteward/templates/datasteward_result_modal.mako:6 +msgid "DataSteward add-on enabled" +msgstr "データ管理責任者アドオンが有効になっています" + +#: addons/datasteward/templates/datasteward_result_modal.mako:7 +msgid "DataSteward add-on disabled" +msgstr "データ管理責任者アドオンが無効になっています" + +#: addons/datasteward/templates/datasteward_result_modal.mako:15 +msgid "DataSteward add-on enable process is completed." +msgstr "データ管理責任者アドオンの有効化が完了しました。" + +#: addons/datasteward/templates/datasteward_result_modal.mako:18 +msgid "DataSteward add-on enable process has failed." +msgstr "データ管理責任者アドオンの有効化プロセスが失敗しました。" + +#: addons/datasteward/templates/datasteward_result_modal.mako:22 +msgid "DataSteward add-on disable process is completed." +msgstr "データ管理責任者アドオンの無効化が完了しました。" + +#: addons/datasteward/templates/datasteward_result_modal.mako:24 +msgid "No projects failed to unregister when disabling add-on." +msgstr "無効化時に登録解除ができなかったプロジェクトはありませんでした。" + +#: addons/datasteward/templates/datasteward_result_modal.mako:27 +msgid "There were %(count)s projects that could not be unregistered when disabling add-on." +msgstr "無効化時に登録解除ができなかったプロジェクトが%(count)s件ありました。" + +#: addons/datasteward/templates/datasteward_result_modal.mako:29 +msgid "For more details, download the CSV from the link below and refer to it." +msgstr "詳細は次のリンクからCSVをダウンロードして参照してください。" + +#: addons/datasteward/templates/datasteward_result_modal.mako:30 +msgid "Please note that you will not be able to refer to this download once the dialog is closed." +msgstr "本ダウンロードは、ポップアップを閉じると参照できなくなりますので注意してください。" + +#: addons/datasteward/templates/datasteward_result_modal.mako:32 +msgid "Disable result CSV download" +msgstr "無効化結果CSVダウンロード" + #: addons/dataverse/templates/dataverse_credentials_modal.mako:6 msgid "Connect a Dataverse Account" msgstr "Dataverseアカウントに接続する" diff --git a/website/translations/js_messages.pot b/website/translations/js_messages.pot index 00ed1664898..269da835125 100644 --- a/website/translations/js_messages.pot +++ b/website/translations/js_messages.pot @@ -496,6 +496,18 @@ msgstr "" msgid "Type the following to continue: %1$s

" msgstr "" +#: admin/static/js/rdm_addons/rdm-addons-page.js:69 +msgid "" +"This will not revoke access to %1$s for all projects using the " +"accounts.
" +msgstr "" + +#: admin/static/js/rdm_addons/rdm-addons-page.js:70 +msgid "" +"But the accounts will not be able to see and change their %1$s settings " +"until you reallow it.

" +msgstr "" + #: admin/static/js/rdm_addons/rdm-addons-page.js:74 msgid "Disallow" msgstr "" diff --git a/website/translations/messages.pot b/website/translations/messages.pot index c6c3822be54..db72b55d006 100644 --- a/website/translations/messages.pot +++ b/website/translations/messages.pot @@ -404,6 +404,162 @@ msgid "" "%(authOsfName)s to verify." msgstr "" +#: addons/datasteward/templates/datasteward_modal.mako:7 +msgid "Enable DataSteward add-on" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:14 +msgid "Before enabling DataSteward add-on, the following are the implementation details and points to note:" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:16 +msgid "* You will be automatically added as a project administrator for all projects of your institution." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:17 +msgid " * If you have already been added in the project before enabling this add-on, you will be promoted to a project administrator." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:18 +msgid " * Project administrators added by this add-on have the same authority as project administrators added in the normal procedure." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:20 +msgid "* After enabling this add-on, newly created projects will not be automatically added as project administrators." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:21 +msgid " * If you log in again with GakuNinRDMDataSteward assigned to the IdP's eduPersonEntitlement attribute and with this add-on enabled, you will be automatically be added as a project administrator for unregistered projects." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:23 +msgid "* To enable this add-on, the value of GakuNinRDMDataSteward must be assigned to the IdP's eduPersonEntitlement attribute." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:24 +msgid " * This add-on will not be disabled simply by removing GakuNinRDMDataSteward from the eduPersonEntitlement attribute." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:25 +msgid " * In order to disable this add-on (remove project as a project administrator), it is necessary to disable this add-on separately." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:27 +msgid "* Each data steward must enable this add-on by themselves." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:28 +msgid " * The number of project administrators participating in the project will increase by the number of different data stewards." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:30 +msgid "* If the number of target projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:32 +msgid "Do you want to enable DataSteward add-on?" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:46 +msgid "User add-on enable" +msgstr "Enable" + +#: addons/datasteward/templates/datasteward_modal.mako:56 +msgid "Enabling DataSteward add-on, please do not close this window or go back on your browser." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:66 +msgid "Disable DataSteward add-on" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:73 +msgid "Before disabling DataSteward add-on, the following are implementation details and points to note:" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:75 +msgid "* Disabling this add-on will remove you from the project that was automatically added as a project administrator when this add-on was enabled." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:76 +msgid " * If your permission is elevated to a project administrator when this add-on is enabled, the permission before this add-on is activated will be restored." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:78 +msgid "* When disabling this add-on, if there is only one administrator for the project, the revert process will be skipped." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:79 +msgid " * For skipped projects, the result can be downloaded in the disable add-on result dialog." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:80 +msgid " * Please manually update the project contributors based on the skipped results." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:82 +msgid "* After disabling this add-on, in order to enable it again, the value of GakuNinRDMDataSteward must be assigned to the eduPersonEntitlement attribute of the IdP." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:84 +msgid "* If you want to revert project registration for all data stewards, each data steward must disable this add-on." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:86 +msgid "* If the number of affected projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:88 +msgid "Do you want to disable DataSteward add-on?" +msgstr "" + +#: addons/datasteward/templates/datasteward_modal.mako:102 +msgid "User add-on disable" +msgstr "Disable" + +#: addons/datasteward/templates/datasteward_modal.mako:112 +msgid "Disabling DataSteward add-on, please do not close this window or go back on your browser." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:6 +msgid "DataSteward add-on enabled" +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:7 +msgid "DataSteward add-on disabled" +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:15 +msgid "DataSteward add-on enable process is completed." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:18 +msgid "DataSteward add-on enable process has failed." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:22 +msgid "DataSteward add-on disable process is completed." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:24 +msgid "No projects failed to unregister when disabling add-on." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:27 +msgid "There were %(count)s projects that could not be unregistered when disabling add-on." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:29 +msgid "For more details, download the CSV from the link below and refer to it." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:30 +msgid "Please note that you will not be able to refer to this download once the dialog is closed." +msgstr "" + +#: addons/datasteward/templates/datasteward_result_modal.mako:32 +msgid "Disable result CSV download" +msgstr "" + #: addons/dataverse/templates/dataverse_credentials_modal.mako:6 msgid "Connect a Dataverse Account" msgstr "" From 5ec999e460e72ebe6efcda3a5fba6bd8472f573d Mon Sep 17 00:00:00 2001 From: huanphan-tma Date: Wed, 8 Mar 2023 18:26:20 +0700 Subject: [PATCH 07/37] =?UTF-8?q?refs=20(1)4.2.=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=B2=AC=E4=BB=BB=E8=80=85=E3=82=A2=E3=83=89?= =?UTF-8?q?=E3=82=AA=E3=83=B3=E5=AE=9F=E8=A3=85:=20Remove=20redundant=20co?= =?UTF-8?q?de=20and=20add=20missing=20texts=20and=20their=20translations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/datasteward/apps.py | 2 - addons/datasteward/migrations/0001_initial.py | 39 +++++++++++++++++++ addons/datasteward/models.py | 6 --- addons/datasteward/serializer.py | 19 --------- .../static/datastewardUserConfig.js | 12 +++--- .../templates/datasteward_result_modal.mako | 5 ++- .../templates/datasteward_user_settings.mako | 2 +- addons/datasteward/views.py | 31 +++++++-------- api/institutions/authentication.py | 2 + website/profile/views.py | 9 ++--- .../en/LC_MESSAGES/js_messages.po | 10 +++++ .../translations/en/LC_MESSAGES/messages.po | 24 +++++++----- .../ja/LC_MESSAGES/js_messages.po | 10 +++++ .../translations/ja/LC_MESSAGES/messages.po | 24 +++++++----- website/translations/js_messages.pot | 10 +++++ website/translations/messages.pot | 24 +++++++----- 16 files changed, 141 insertions(+), 88 deletions(-) create mode 100644 addons/datasteward/migrations/0001_initial.py delete mode 100644 addons/datasteward/serializer.py diff --git a/addons/datasteward/apps.py b/addons/datasteward/apps.py index d1386f81dc9..230ed0f5a1c 100644 --- a/addons/datasteward/apps.py +++ b/addons/datasteward/apps.py @@ -18,8 +18,6 @@ class DataStewardAddonAppConfig(BaseAddonAppConfig): configs = ['accounts'] user_settings_template = os.path.join(TEMPLATE_PATH, 'datasteward_user_settings.mako') - actions = () - @property def routes(self): from .routes import api_routes diff --git a/addons/datasteward/migrations/0001_initial.py b/addons/datasteward/migrations/0001_initial.py new file mode 100644 index 00000000000..4843e4b74c9 --- /dev/null +++ b/addons/datasteward/migrations/0001_initial.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.28 on 2023-02-23 03:25 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django_extensions.db.fields +import osf.models.base +import osf.utils.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='UserSettings', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')), + ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')), + ('_id', models.CharField(db_index=True, default=osf.models.base.generate_object_id, max_length=24, unique=True)), + ('is_deleted', models.BooleanField(default=False)), + ('deleted', osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True)), + ('enabled', models.BooleanField(default=False)), + ('owner', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='addons_datasteward_user_settings', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'abstract': False, + }, + bases=(models.Model, osf.models.base.QuerySetExplainMixin), + ), + ] diff --git a/addons/datasteward/models.py b/addons/datasteward/models.py index 7bd779ea609..4f8262bac7f 100644 --- a/addons/datasteward/models.py +++ b/addons/datasteward/models.py @@ -1,16 +1,11 @@ # -*- coding: utf-8 -*- from addons.base.models import (BaseUserSettings, ) -from addons.datasteward.serializer import DataStewardSerializer from django.db import models -_provider = 'datasteward' - class DataStewardProvider(object): - """An alternative to `ExternalProvider` not tied to OAuth""" name = 'DataSteward' short_name = 'datasteward' - serializer = DataStewardSerializer def __init__(self, account=None): super(DataStewardProvider, self).__init__() # this does exactly nothing... @@ -26,6 +21,5 @@ def __repr__(self): class UserSettings(BaseUserSettings): oauth_provider = DataStewardProvider - serializer = DataStewardSerializer enabled = models.BooleanField(default=False) diff --git a/addons/datasteward/serializer.py b/addons/datasteward/serializer.py deleted file mode 100644 index 7a35cabe80d..00000000000 --- a/addons/datasteward/serializer.py +++ /dev/null @@ -1,19 +0,0 @@ -from addons.base.serializer import AddonSerializer - - -class DataStewardSerializer(AddonSerializer): - addon_short_name = 'datasteward' - - REQUIRED_URLS = [] - - def addon_serialized_urls(self): - pass - - def serialized_urls(self): - pass - - def user_is_owner(self): - pass - - def credentials_owner(self): - pass diff --git a/addons/datasteward/static/datastewardUserConfig.js b/addons/datasteward/static/datastewardUserConfig.js index 18804eb4542..c76750f5d0e 100644 --- a/addons/datasteward/static/datastewardUserConfig.js +++ b/addons/datasteward/static/datastewardUserConfig.js @@ -6,12 +6,9 @@ var ko = require('knockout'); var $ = require('jquery'); var Raven = require('raven-js'); -var bootbox = require('bootbox'); require('js/osfToggleHeight'); -var language = require('js/osfLanguage').Addons.dataverse; var osfHelpers = require('js/osfHelpers'); -var addonSettings = require('js/addonSettings'); var $modal = $('#datastewardModal'); var $resultModal = $('#datastewardResultModal'); @@ -42,6 +39,7 @@ function ViewModel(url) { self.is_processing(false); $resultModal.modal('show'); } + self.changeMessage('',''); }); $resultModal.on("hidden.bs.modal", function () { @@ -98,8 +96,8 @@ function ViewModel(url) { $modal.modal('hide'); }).fail(function (xhr, textStatus, error) { self.is_processing(false); - self.changeMessage(language.userSettingsError, 'text-danger'); - Raven.captureMessage('Could not disable DataSteward add-on', { + self.changeMessage(_('Cannot disable DataSteward add-on'), 'text-danger'); + Raven.captureMessage(_('Cannot disable DataSteward add-on'), { extra: { url: url, textStatus: textStatus, @@ -134,8 +132,8 @@ function ViewModel(url) { self.addon_enabled(enabled); self.loaded(true); }).fail(function (xhr, textStatus, error) { - self.changeMessage(language.userSettingsError, 'text-danger'); - Raven.captureMessage('Could not GET DataSteward settings', { + self.changeMessage(_('Cannot get DataSteward add-on settings'), 'text-danger'); + Raven.captureMessage(_('Cannot get DataSteward add-on settings'), { extra: { url: url, textStatus: textStatus, diff --git a/addons/datasteward/templates/datasteward_result_modal.mako b/addons/datasteward/templates/datasteward_result_modal.mako index 45250df496e..650a554623a 100644 --- a/addons/datasteward/templates/datasteward_result_modal.mako +++ b/addons/datasteward/templates/datasteward_result_modal.mako @@ -3,7 +3,10 @@ @@ -63,7 +63,7 @@

- ${_("Disabling DataSteward add-on, please do not close this window or go back on your browser.")} + ${_('Disabling DataSteward add-on, please do not close this window or go back on your browser.')}

diff --git a/addons/datasteward/templates/datasteward_result_modal.mako b/addons/datasteward/templates/datasteward_result_modal.mako index 650a554623a..f83cd693e62 100644 --- a/addons/datasteward/templates/datasteward_result_modal.mako +++ b/addons/datasteward/templates/datasteward_result_modal.mako @@ -4,10 +4,10 @@ diff --git a/addons/datasteward/views.py b/addons/datasteward/views.py index 6f44abaabf9..7e3dcdf84c6 100644 --- a/addons/datasteward/views.py +++ b/addons/datasteward/views.py @@ -5,7 +5,7 @@ from framework.auth.decorators import must_be_logged_in from flask import request -from django.db import transaction, DatabaseError, IntegrityError +from django.db import transaction from osf.utils.permissions import ADMIN import logging @@ -95,29 +95,28 @@ def enable_datasteward_addon(user, is_authenticating=False, **kwargs): try: if not project.is_contributor(user): # If user is not project's contributor, add user to contributor list - add_result = project.add_contributor(user, permissions=ADMIN, visible=True, send_email=None, auth=None, log=False, save=False) + add_result = project.add_contributor(user, permissions=ADMIN, visible=True, send_email=None, auth=None, log=False, save=True) if add_result: contributor = project.contributor_class.objects.get(user=user, node=project) contributor.is_data_steward = True contributor.save() else: - # Otherwise, promote user's permission to Project Administrator # Get contributor by user's id and project's id contributor = project.contributor_class.objects.get(user=user, node=project) if not contributor.is_data_steward: - # If contributor's permission is not set by DataSteward add-on + # If contributor's current permission is not set by DataSteward add-on # set is_data_steward to True and data_steward_old_permission to contributor's current permission contributor.data_steward_old_permission = contributor.permission contributor.is_data_steward = True - project.update_contributor(user, permission=ADMIN, visible=True, auth=None, save=False, check_admin_permission=False) - contributor.save() - except (DatabaseError, IntegrityError) as e: - # If database error is raised, log error to server - logger.warning("Project {}: error raised while enabling DataSteward add-on with {}".format(project._id, e)) + contributor.save() + + if contributor.permission != ADMIN: + # If contributor's permission is not Project Administrator, update user's permission to Project Administrator + project.update_contributor(user, permission=ADMIN, visible=None, auth=None, save=True, check_admin_permission=False) except Exception as e: - # If other error is raised while running on "Configure add-on accounts" screen, raise error + # If error is raised while running on "Configure add-on accounts" screen, raise error # Otherwise, do nothing - logger.error("Project {}: error raised while enabling DataSteward add-on with {}".format(project._id, e)) + logger.error('Project {}: error raised while enabling DataSteward add-on with {}'.format(project._id, e)) if not is_authenticating: raise e @@ -150,8 +149,8 @@ def disable_datasteward_addon(user, **kwargs): if contributor.data_steward_old_permission is not None: # If user had contributor's old permission before enabling add-on in project, restore that permission - project.update_contributor(user, permission=contributor.data_steward_old_permission, visible=True, - auth=None, save=False, check_admin_permission=False) + project.update_contributor(user, permission=contributor.data_steward_old_permission, visible=None, + auth=None, save=True, check_admin_permission=False) contributor.is_data_steward = False contributor.data_steward_old_permission = None contributor.save() @@ -162,7 +161,7 @@ def disable_datasteward_addon(user, **kwargs): skipped_projects.append(project) except Exception as e: # If error is raised, log warning and add project to skipped project list - logger.warning("Project {}: error raised while disabling DataSteward add-on with {}".format(project._id, e)) + logger.warning('Project {}: error raised while disabling DataSteward add-on with {}'.format(project._id, e)) skipped_projects.append(project) return skipped_projects diff --git a/api/institutions/authentication.py b/api/institutions/authentication.py index 1d49d894393..eb075624950 100644 --- a/api/institutions/authentication.py +++ b/api/institutions/authentication.py @@ -419,6 +419,7 @@ def get_next(obj, *args): # Get user DataSteward add-on setings addon_user_settings = user.get_addon('datasteward') if addon_user_settings and addon_user_settings.enabled: + # If user enabled DataSteward add-on, restart enable datasteward add-on to add missing projects if have enable_datasteward_addon(user, is_authenticating=True) else: # Set user.is_data_steward to False diff --git a/osf/models/contributor.py b/osf/models/contributor.py index a1979354351..4c10d17afa1 100644 --- a/osf/models/contributor.py +++ b/osf/models/contributor.py @@ -6,10 +6,10 @@ CONTRIBUTOR_PERMISSION_CHOICES = ( - ("NULL", None), - ("READ", "read"), - ("WRITE", "write"), - ("ADMIN", "admin"), + ('NULL', None), + ('READ', 'read'), + ('WRITE', 'write'), + ('ADMIN', 'admin'), ) diff --git a/website/translations/en/LC_MESSAGES/messages.po b/website/translations/en/LC_MESSAGES/messages.po index dfcee987496..5e5756d5bfd 100644 --- a/website/translations/en/LC_MESSAGES/messages.po +++ b/website/translations/en/LC_MESSAGES/messages.po @@ -415,47 +415,47 @@ msgid "Before enabling DataSteward add-on, the following are the implementation msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:16 -msgid "* You will be automatically added as a project administrator for all projects of your institution." +msgid "・You will be automatically added as a project administrator for all projects of your institution." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:17 -msgid " * If you have already been added in the project before enabling this add-on, you will be promoted to a project administrator." +msgid "・If you have already been added in the project before enabling this add-on, you will be promoted to a project administrator." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:18 -msgid " * Project administrators added by this add-on have the same authority as project administrators added in the normal procedure." +msgid "・Project administrators added by this add-on have the same authority as project administrators added in the normal procedure." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:20 -msgid "* After enabling this add-on, newly created projects will not be automatically added as project administrators." +msgid "・After enabling this add-on, newly created projects will not be automatically added as project administrators." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:21 -msgid " * If you log in again with GakuNinRDMDataSteward assigned to the IdP's eduPersonEntitlement attribute and with this add-on enabled, you will be automatically be added as a project administrator for unregistered projects." +msgid "・If you log in again with GakuNinRDMDataSteward assigned to the IdP's eduPersonEntitlement attribute and with this add-on enabled, you will be automatically be added as a project administrator for unregistered projects." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:23 -msgid "* To enable this add-on, the value of GakuNinRDMDataSteward must be assigned to the IdP's eduPersonEntitlement attribute." +msgid "・To enable this add-on, the value of GakuNinRDMDataSteward must be assigned to the IdP's eduPersonEntitlement attribute." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:24 -msgid " * This add-on will not be disabled simply by removing GakuNinRDMDataSteward from the eduPersonEntitlement attribute." +msgid "・This add-on will not be disabled simply by removing GakuNinRDMDataSteward from the eduPersonEntitlement attribute." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:25 -msgid " * In order to disable this add-on (remove project as a project administrator), it is necessary to disable this add-on separately." +msgid "・In order to disable this add-on (remove project as a project administrator), it is necessary to disable this add-on separately." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:27 -msgid "* Each data steward must enable this add-on by themselves." +msgid "・Each data steward must enable this add-on by themselves." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:28 -msgid " * The number of project administrators participating in the project will increase by the number of different data stewards." +msgid "・The number of project administrators participating in the project will increase by the number of different data stewards." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:30 -msgid "* If the number of target projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgid "・If the number of target projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:32 @@ -479,35 +479,35 @@ msgid "Before disabling DataSteward add-on, the following are implementation det msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:75 -msgid "* Disabling this add-on will remove you from the project that was automatically added as a project administrator when this add-on was enabled." +msgid "・Disabling this add-on will remove you from the project that was automatically added as a project administrator when this add-on was enabled." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:76 -msgid " * If your permission is elevated to a project administrator when this add-on is enabled, the permission before this add-on is activated will be restored." +msgid "・If your permission is elevated to a project administrator when this add-on is enabled, the permission before this add-on is activated will be restored." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:78 -msgid "* When disabling this add-on, if there is only one administrator for the project, the revert process will be skipped." +msgid "・When disabling this add-on, if there is only one administrator for the project, the revert process will be skipped." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:79 -msgid " * For skipped projects, the result can be downloaded in the disable add-on result dialog." +msgid "・For skipped projects, the result can be downloaded in the disable add-on result dialog." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:80 -msgid " * Please manually update the project contributors based on the skipped results." +msgid "・Please manually update the project contributors based on the skipped results." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:82 -msgid "* After disabling this add-on, in order to enable it again, the value of GakuNinRDMDataSteward must be assigned to the eduPersonEntitlement attribute of the IdP." +msgid "・After disabling this add-on, in order to enable it again, the value of GakuNinRDMDataSteward must be assigned to the eduPersonEntitlement attribute of the IdP." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:84 -msgid "* If you want to revert project registration for all data stewards, each data steward must disable this add-on." +msgid "・If you want to revert project registration for all data stewards, each data steward must disable this add-on." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:86 -msgid "* If the number of affected projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgid "・If the number of affected projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:88 diff --git a/website/translations/ja/LC_MESSAGES/messages.po b/website/translations/ja/LC_MESSAGES/messages.po index abe0bfcf045..ef31d81bb9f 100644 --- a/website/translations/ja/LC_MESSAGES/messages.po +++ b/website/translations/ja/LC_MESSAGES/messages.po @@ -418,48 +418,48 @@ msgid "Before enabling DataSteward add-on, the following are the implementation msgstr "データ管理責任者アドオンを有効化します。\n以下に有効化時の実施内容と、注意点を記載します。" #: addons/datasteward/templates/datasteward_modal.mako:16 -msgid "* You will be automatically added as a project administrator for all projects of your institution." -msgstr "* 所属する機関の全てのプロジェクトに対し、プロジェクト管理者として自動で登録されます。" +msgid "・You will be automatically added as a project administrator for all projects of your institution." +msgstr "・所属する機関の全てのプロジェクトに対し、プロジェクト管理者として自動で登録されます。" #: addons/datasteward/templates/datasteward_modal.mako:17 -msgid " * If you have already been added in the project before enabling this add-on, you will be promoted to a project administrator." -msgstr " * 本アドオン有効化前に、既にプロジェクトに登録済みの場合、プロジェクト管理者に権限昇格されます。" +msgid "・If you have already been added in the project before enabling this add-on, you will be promoted to a project administrator." +msgstr "・本アドオン有効化前に、既にプロジェクトに登録済みの場合、プロジェクト管理者に権限昇格されます。" #: addons/datasteward/templates/datasteward_modal.mako:18 -msgid " * Project administrators added by this add-on have the same authority as project administrators added in the normal procedure." -msgstr " * 本アドオンによって登録されたプロジェクト管理者は、通常手順で追加されたプロジェクト管理者と同じ権限となります。" +msgid "・Project administrators added by this add-on have the same authority as project administrators added in the normal procedure." +msgstr "・本アドオンによって登録されたプロジェクト管理者は、通常手順で追加されたプロジェクト管理者と同じ権限となります。" #: addons/datasteward/templates/datasteward_modal.mako:20 -msgid "* After enabling this add-on, newly created projects will not be automatically added as project administrators." -msgstr "* 本アドオン有効化後、新規に作成されたプロジェクトには、自動ではプロジェクト管理者として登録されません。" +msgid "・After enabling this add-on, newly created projects will not be automatically added as project administrators." +msgstr "・本アドオン有効化後、新規に作成されたプロジェクトには、自動ではプロジェクト管理者として登録されません。" #: addons/datasteward/templates/datasteward_modal.mako:21 -msgid " * If you log in again with GakuNinRDMDataSteward assigned to the IdP's eduPersonEntitlement attribute and with this add-on enabled, you will be automatically be added as a project administrator for unregistered projects." -msgstr " * IdPのeduPersonEntitlement属性にGakuNinRDMDataStewardが付与されている状態かつ、本アドオンを有効化した状態で再ログインをすると、未登録のプロジェクトにプロジェクト管理者として自動で登録されます。" +msgid "・If you log in again with GakuNinRDMDataSteward assigned to the IdP's eduPersonEntitlement attribute and with this add-on enabled, you will be automatically be added as a project administrator for unregistered projects." +msgstr "・IdPのeduPersonEntitlement属性にGakuNinRDMDataStewardが付与されている状態かつ、本アドオンを有効化した状態で再ログインをすると、未登録のプロジェクトにプロジェクト管理者として自動で登録されます。" #: addons/datasteward/templates/datasteward_modal.mako:23 -msgid "* To enable this add-on, the value of GakuNinRDMDataSteward must be assigned to the IdP's eduPersonEntitlement attribute." -msgstr "* 本アドオンの有効化には、IdPのeduPersonEntitlement属性にGakuNinRDMDataStewardの値が付与されている必要があります。" +msgid "・To enable this add-on, the value of GakuNinRDMDataSteward must be assigned to the IdP's eduPersonEntitlement attribute." +msgstr "・本アドオンの有効化には、IdPのeduPersonEntitlement属性にGakuNinRDMDataStewardの値が付与されている必要があります。" #: addons/datasteward/templates/datasteward_modal.mako:24 -msgid " * This add-on will not be disabled simply by removing GakuNinRDMDataSteward from the eduPersonEntitlement attribute." -msgstr " * なお、eduPersonEntitlement属性からGakuNinRDMDataStewardを外しただけでは、本アドオンは無効化されません。" +msgid "・This add-on will not be disabled simply by removing GakuNinRDMDataSteward from the eduPersonEntitlement attribute." +msgstr "・なお、eduPersonEntitlement属性からGakuNinRDMDataStewardを外しただけでは、本アドオンは無効化されません。" #: addons/datasteward/templates/datasteward_modal.mako:25 -msgid " * In order to disable this add-on (remove project as a project administrator), it is necessary to disable this add-on separately." -msgstr " * 本アドオンを無効化(プロジェクト管理者の登録解除)をするためには、別途本アドオンの無効化が必要です。" +msgid "・In order to disable this add-on (remove project as a project administrator), it is necessary to disable this add-on separately." +msgstr "・本アドオンを無効化(プロジェクト管理者の登録解除)をするためには、別途本アドオンの無効化が必要です。" #: addons/datasteward/templates/datasteward_modal.mako:27 -msgid "* Each data steward must enable this add-on by themselves." -msgstr "* 「データ管理責任者」それぞれが、本アドオンを有効化する必要があります。" +msgid "・Each data steward must enable this add-on by themselves." +msgstr "・「データ管理責任者」それぞれが、本アドオンを有効化する必要があります。" #: addons/datasteward/templates/datasteward_modal.mako:28 -msgid " * The number of project administrators participating in the project will increase by the number of different data stewards." -msgstr " * 異なる「データ管理責任者」の人数分、プロジェクトに参加するプロジェクト管理者が増えます。" +msgid "・The number of project administrators participating in the project will increase by the number of different data stewards." +msgstr "・異なる「データ管理責任者」の人数分、プロジェクトに参加するプロジェクト管理者が増えます。" #: addons/datasteward/templates/datasteward_modal.mako:30 -msgid "* If the number of target projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." -msgstr "* 対象プロジェクト数が多い場合、有効化の処理時に時間がかかる(最大30秒程度)ため、別の画面への移動や画面を閉じることをせず、処理が終わるまで待機してください。" +msgid "・If the number of target projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgstr "・対象プロジェクト数が多い場合、有効化の処理時に時間がかかる(最大30秒程度)ため、別の画面への移動や画面を閉じることをせず、処理が終わるまで待機してください。" #: addons/datasteward/templates/datasteward_modal.mako:32 msgid "Do you want to enable DataSteward add-on?" @@ -482,36 +482,36 @@ msgid "Before disabling DataSteward add-on, the following are implementation det msgstr "データ管理責任者アドオンを無効化します。\n以下に無効化時の実施内容と、注意点を記載します。" #: addons/datasteward/templates/datasteward_modal.mako:75 -msgid "* Disabling this add-on will remove you from the project that was automatically added as a project administrator when this add-on was enabled." -msgstr "* 本アドオン有効化時にプロジェクト管理者として自動で登録されたプロジェクトから、登録解除します。" +msgid "・Disabling this add-on will remove you from the project that was automatically added as a project administrator when this add-on was enabled." +msgstr "・本アドオン有効化時にプロジェクト管理者として自動で登録されたプロジェクトから、登録解除します。" #: addons/datasteward/templates/datasteward_modal.mako:76 -msgid " * If your permission is elevated to a project administrator when this add-on is enabled, the permission before this add-on is activated will be restored." -msgstr " * 本アドオン有効化時にプロジェクト管理者に権限昇格された場合、本アドオン有効化前の権限に戻します。" +msgid "・If your permission is elevated to a project administrator when this add-on is enabled, the permission before this add-on is activated will be restored." +msgstr "・本アドオン有効化時にプロジェクト管理者に権限昇格された場合、本アドオン有効化前の権限に戻します。" #: addons/datasteward/templates/datasteward_modal.mako:78 -msgid "* When disabling this add-on, if there is only one administrator for the project, the revert process will be skipped." -msgstr "* 本アドオン無効化時、プロジェクトに対する管理者が一人のみの場合、登録解除処理はスキップされます。" +msgid "・When disabling this add-on, if there is only one administrator for the project, the revert process will be skipped." +msgstr "・本アドオン無効化時、プロジェクトに対する管理者が一人のみの場合、登録解除処理はスキップされます。" #: addons/datasteward/templates/datasteward_modal.mako:79 -msgid " * For skipped projects, the result can be downloaded in the disable add-on result dialog." -msgstr " * スキップされたプロジェクトは、アドオン無効化結果ポップアップにて結果がダウンロードできます。" +msgid "・For skipped projects, the result can be downloaded in the disable add-on result dialog." +msgstr "・スキップされたプロジェクトは、アドオン無効化結果ポップアップにて結果がダウンロードできます。" #: addons/datasteward/templates/datasteward_modal.mako:80 -msgid " * Please manually update the project contributors based on the skipped results." -msgstr " * スキップされた結果を元に、手動でプロジェクトへの参加者の更新をしてください。" +msgid "・Please manually update the project contributors based on the skipped results." +msgstr "・スキップされた結果を元に、手動でプロジェクトへの参加者の更新をしてください。" #: addons/datasteward/templates/datasteward_modal.mako:82 -msgid "* After disabling this add-on, in order to enable it again, the value of GakuNinRDMDataSteward must be assigned to the eduPersonEntitlement attribute of the IdP." -msgstr "* 本アドオン無効化後、再度有効化するためには、IdPのeduPersonEntitlement属性にGakuNinRDMDataStewardの値が付与されている必要があります。" +msgid "・After disabling this add-on, in order to enable it again, the value of GakuNinRDMDataSteward must be assigned to the eduPersonEntitlement attribute of the IdP." +msgstr "・本アドオン無効化後、再度有効化するためには、IdPのeduPersonEntitlement属性にGakuNinRDMDataStewardの値が付与されている必要があります。" #: addons/datasteward/templates/datasteward_modal.mako:84 -msgid "* If you want to revert project registration for all data stewards, each data steward must disable this add-on." -msgstr "* 「データ管理責任者」全ての登録を解除したい場合、「データ管理責任者」それぞれが、本アドオンを無効化する必要があります。" +msgid "・If you want to revert project registration for all data stewards, each data steward must disable this add-on." +msgstr "・「データ管理責任者」全ての登録を解除したい場合、「データ管理責任者」それぞれが、本アドオンを無効化する必要があります。" #: addons/datasteward/templates/datasteward_modal.mako:86 -msgid "* If the number of affected projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." -msgstr "* 対象プロジェクト数が多い場合、無効化の処理時に時間がかかる(最大30秒程度)ため、別の画面への移動や画面を閉じることをせず、処理が終わるまで待機してください。" +msgid "・If the number of affected projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgstr "・対象プロジェクト数が多い場合、無効化の処理時に時間がかかる(最大30秒程度)ため、別の画面への移動や画面を閉じることをせず、処理が終わるまで待機してください。" #: addons/datasteward/templates/datasteward_modal.mako:88 msgid "Do you want to disable DataSteward add-on?" diff --git a/website/translations/messages.pot b/website/translations/messages.pot index 5dde45c3c7d..276ebf24748 100644 --- a/website/translations/messages.pot +++ b/website/translations/messages.pot @@ -413,47 +413,47 @@ msgid "Before enabling DataSteward add-on, the following are the implementation msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:16 -msgid "* You will be automatically added as a project administrator for all projects of your institution." +msgid "・You will be automatically added as a project administrator for all projects of your institution." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:17 -msgid " * If you have already been added in the project before enabling this add-on, you will be promoted to a project administrator." +msgid "・If you have already been added in the project before enabling this add-on, you will be promoted to a project administrator." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:18 -msgid " * Project administrators added by this add-on have the same authority as project administrators added in the normal procedure." +msgid "・Project administrators added by this add-on have the same authority as project administrators added in the normal procedure." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:20 -msgid "* After enabling this add-on, newly created projects will not be automatically added as project administrators." +msgid "・After enabling this add-on, newly created projects will not be automatically added as project administrators." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:21 -msgid " * If you log in again with GakuNinRDMDataSteward assigned to the IdP's eduPersonEntitlement attribute and with this add-on enabled, you will be automatically be added as a project administrator for unregistered projects." +msgid "・If you log in again with GakuNinRDMDataSteward assigned to the IdP's eduPersonEntitlement attribute and with this add-on enabled, you will be automatically be added as a project administrator for unregistered projects." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:23 -msgid "* To enable this add-on, the value of GakuNinRDMDataSteward must be assigned to the IdP's eduPersonEntitlement attribute." +msgid "・To enable this add-on, the value of GakuNinRDMDataSteward must be assigned to the IdP's eduPersonEntitlement attribute." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:24 -msgid " * This add-on will not be disabled simply by removing GakuNinRDMDataSteward from the eduPersonEntitlement attribute." +msgid "・This add-on will not be disabled simply by removing GakuNinRDMDataSteward from the eduPersonEntitlement attribute." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:25 -msgid " * In order to disable this add-on (remove project as a project administrator), it is necessary to disable this add-on separately." +msgid "・In order to disable this add-on (remove project as a project administrator), it is necessary to disable this add-on separately." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:27 -msgid "* Each data steward must enable this add-on by themselves." +msgid "・Each data steward must enable this add-on by themselves." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:28 -msgid " * The number of project administrators participating in the project will increase by the number of different data stewards." +msgid "・The number of project administrators participating in the project will increase by the number of different data stewards." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:30 -msgid "* If the number of target projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgid "・If the number of target projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:32 @@ -477,35 +477,35 @@ msgid "Before disabling DataSteward add-on, the following are implementation det msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:75 -msgid "* Disabling this add-on will remove you from the project that was automatically added as a project administrator when this add-on was enabled." +msgid "・Disabling this add-on will remove you from the project that was automatically added as a project administrator when this add-on was enabled." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:76 -msgid " * If your permission is elevated to a project administrator when this add-on is enabled, the permission before this add-on is activated will be restored." +msgid "・If your permission is elevated to a project administrator when this add-on is enabled, the permission before this add-on is activated will be restored." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:78 -msgid "* When disabling this add-on, if there is only one administrator for the project, the revert process will be skipped." +msgid "・When disabling this add-on, if there is only one administrator for the project, the revert process will be skipped." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:79 -msgid " * For skipped projects, the result can be downloaded in the disable add-on result dialog." +msgid "・For skipped projects, the result can be downloaded in the disable add-on result dialog." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:80 -msgid " * Please manually update the project contributors based on the skipped results." +msgid "・Please manually update the project contributors based on the skipped results." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:82 -msgid "* After disabling this add-on, in order to enable it again, the value of GakuNinRDMDataSteward must be assigned to the eduPersonEntitlement attribute of the IdP." +msgid "・After disabling this add-on, in order to enable it again, the value of GakuNinRDMDataSteward must be assigned to the eduPersonEntitlement attribute of the IdP." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:84 -msgid "* If you want to revert project registration for all data stewards, each data steward must disable this add-on." +msgid "・If you want to revert project registration for all data stewards, each data steward must disable this add-on." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:86 -msgid "* If the number of affected projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." +msgid "・If the number of affected projects is large, it will take time to process (up to about 30 seconds), so please do not move to another screen or close the screen, and wait until the process is completed." msgstr "" #: addons/datasteward/templates/datasteward_modal.mako:88 From fef4ff2dc6a773b0dfa953dcd6d9248e98539f1d Mon Sep 17 00:00:00 2001 From: huanphan-tma Date: Fri, 10 Mar 2023 18:38:40 +0700 Subject: [PATCH 10/37] =?UTF-8?q?refs=20(1)4.2.=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=B2=AC=E4=BB=BB=E8=80=85=E3=82=A2=E3=83=89?= =?UTF-8?q?=E3=82=AA=E3=83=B3=E5=AE=9F=E8=A3=85:=20Add=20message=20for=20h?= =?UTF-8?q?ttp=20403=20when=20enable=20add-on,=20update=20comments=20and?= =?UTF-8?q?=20add=20warning=20log=20if=20cannot=20remove=20user=20from=20p?= =?UTF-8?q?roject?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/datastewardUserConfig.js | 107 +++++++++++------- .../templates/datasteward_modal.mako | 8 +- .../templates/datasteward_result_modal.mako | 8 +- .../templates/datasteward_user_settings.mako | 2 +- addons/datasteward/views.py | 15 ++- api/institutions/authentication.py | 2 +- website/profile/views.py | 2 +- .../en/LC_MESSAGES/js_messages.po | 13 ++- .../ja/LC_MESSAGES/js_messages.po | 13 ++- website/translations/js_messages.pot | 13 ++- 10 files changed, 116 insertions(+), 67 deletions(-) diff --git a/addons/datasteward/static/datastewardUserConfig.js b/addons/datasteward/static/datastewardUserConfig.js index c76750f5d0e..03ce33c71a8 100644 --- a/addons/datasteward/static/datastewardUserConfig.js +++ b/addons/datasteward/static/datastewardUserConfig.js @@ -18,51 +18,60 @@ function ViewModel(url) { var self = this; self.properName = 'DataSteward'; - self.dialog_closed_by_user = ko.observable(false); // Whether the initial data has been loaded + self.is_waiting = ko.observable(false); + + // Checkbox value self.addon_enabled = ko.observable(false); - self.loaded = ko.observable(false); - self.is_processing = ko.observable(false); - self.is_process_failed = ko.observable(false); + + // Whether add-on change failed or not + self.change_add_on_failed = ko.observable(false); + + // List of skipped projects while disabling DataSteward add-on self.skipped_projects = ko.observable([]); + // Whether modal is closed by user or programmatically closed + self.dialog_closed_by_user = ko.observable(false); + // Flashed messages self.message = ko.observable(''); self.messageClass = ko.observable('text-info'); + // Modal hidden events $modal.on("hidden.bs.modal", function () { if (self.dialog_closed_by_user()) { self.addon_enabled(!self.addon_enabled()); self.dialog_closed_by_user(false); } else { - self.is_processing(false); + self.is_waiting(false); $resultModal.modal('show'); } self.changeMessage('',''); }); $resultModal.on("hidden.bs.modal", function () { - if (self.is_process_failed()) { + if (self.change_add_on_failed()) { self.addon_enabled(!self.addon_enabled()); - self.is_process_failed(false); + self.change_add_on_failed(false); } self.skipped_projects([]); }); - /** Reset all fields from Dataverse host selection modal */ + /** Close confirm modal */ self.clearModal = function() { $modal.modal('hide'); self.dialog_closed_by_user(true); }; + /** Close result modal */ self.clearResultModal = function() { $resultModal.modal('hide'); } - /** Enable add on **/ + /** Enable add on */ self.enableAddon = function() { - self.is_processing(true); + self.is_waiting(true); var data = { 'enabled': self.addon_enabled() }; @@ -74,14 +83,26 @@ function ViewModel(url) { }).done(function (response) { $modal.modal('hide'); }).fail(function (xhr, textStatus, error) { - self.is_process_failed(true); - $modal.modal('hide'); + if (xhr.status === 403) { + self.is_waiting(false); + self.changeMessage(_('You do not have permission to perform this action.'), 'text-danger'); + Raven.captureMessage(_('You do not have permission to perform this action.'), { + extra: { + url: url, + textStatus: textStatus, + error: error + } + }); + } else { + self.change_add_on_failed(true); + $modal.modal('hide'); + } }); }; - /** Disable add on **/ + /** Disable add on */ self.disableAddon = function() { - self.is_processing(true); + self.is_waiting(true); var data = { 'enabled': self.addon_enabled() }; @@ -95,7 +116,7 @@ function ViewModel(url) { self.skipped_projects(skipped_projects); $modal.modal('hide'); }).fail(function (xhr, textStatus, error) { - self.is_processing(false); + self.is_waiting(false); self.changeMessage(_('Cannot disable DataSteward add-on'), 'text-danger'); Raven.captureMessage(_('Cannot disable DataSteward add-on'), { extra: { @@ -123,6 +144,7 @@ function ViewModel(url) { // Update observables with data from the server self.fetch = function() { + self.is_waiting(true); $.ajax({ url: url, type: 'GET', @@ -130,7 +152,7 @@ function ViewModel(url) { }).done(function (response) { var enabled = response.enabled; self.addon_enabled(enabled); - self.loaded(true); + self.is_waiting(false); }).fail(function (xhr, textStatus, error) { self.changeMessage(_('Cannot get DataSteward add-on settings'), 'text-danger'); Raven.captureMessage(_('Cannot get DataSteward add-on settings'), { @@ -143,10 +165,12 @@ function ViewModel(url) { }); }; - self.toggleCheckbox = function() { + /** Open confirm modal */ + self.openModal = function() { $modal.modal('show'); }; + /** Create CSV data and save it to client */ self.clickCSV = function () { var skipped_projects = self.skipped_projects(); if (!skipped_projects) { @@ -161,36 +185,41 @@ function ViewModel(url) { exportToCsv('skipped_projects.csv', rows); } - function exportToCsv(filename, rows) { - var processRow = function (row) { - var finalVal = ''; - for (var j = 0; j < row.length; j++) { - var innerValue = row[j] === null ? '' : row[j].toString(); - if (row[j] instanceof Date) { - innerValue = row[j].toLocaleString(); - }; - var result = innerValue.replace(/"/g, '""'); - if (result.search(/("|,|\n)/g) >= 0) - result = '"' + result + '"'; - if (j > 0) - finalVal += ','; - finalVal += result; - } - return finalVal + '\n'; - }; + /** Convert data array to CSV line string */ + var processRow = function (row) { + var finalVal = ''; + for (var j = 0; j < row.length; j++) { + var innerValue = row[j] === null ? '' : row[j].toString(); + if (row[j] instanceof Date) { + // If item is a Date, its locale string + innerValue = row[j].toLocaleString(); + }; + var result = innerValue.replace(/"/g, '""'); + if (result.search(/("|,|\n)/g) >= 0) + // If string has doublequote, comma or line break characters then wrap it in doublequotes + result = '"' + result + '"'; + if (j > 0) + finalVal += ','; + finalVal += result; + } + return finalVal + '\n'; + }; + /** Export data to CSV file */ + var exportToCsv = function(filename, rows) { var csvFile = ''; for (var i = 0; i < rows.length; i++) { csvFile += processRow(rows[i]); } var blob = new Blob([csvFile], { type: 'text/csv;charset=utf-8;' }); - if (navigator.msSaveBlob) { // IE 10+ + if (navigator.msSaveBlob) { + // For IE 10+ navigator.msSaveBlob(blob, filename); } else { + // For modern browsers var link = document.createElement("a"); - if (link.download !== undefined) { // feature detection - // Browsers that support HTML5 download attribute + if (link.download !== undefined) { var url = URL.createObjectURL(blob); link.setAttribute("href", url); link.setAttribute("download", filename); @@ -198,6 +227,8 @@ function ViewModel(url) { document.body.appendChild(link); link.click(); document.body.removeChild(link); + + // Release csv URL object URL.revokeObjectURL(url); } } @@ -216,5 +247,5 @@ function DataStewardUserConfig(selector, url) { module.exports = { DataStewardViewModel: ViewModel, - DataStewardUserConfig: DataStewardUserConfig // for backwards-compat + DataStewardUserConfig: DataStewardUserConfig }; diff --git a/addons/datasteward/templates/datasteward_modal.mako b/addons/datasteward/templates/datasteward_modal.mako index d372f9e53a0..7731c82870b 100644 --- a/addons/datasteward/templates/datasteward_modal.mako +++ b/addons/datasteward/templates/datasteward_modal.mako @@ -7,7 +7,7 @@

${_('Enable DataSteward add-on')}

-
+