Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into develop

* 'develop' of https://github.com/CenterForOpenScience/osf.io:
  Rename, reword template - Fix redirect
  Add AGU Conference campaign
  Fix ResolveGuid tests
  Routing changes for Preprints Modernization - Phase 1
  Update ReviewActionListCreate write scopes
  • Loading branch information
John Tordoff committed Dec 7, 2023
2 parents a1e9aa5 + ee87e96 commit 2d56c94
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 23 deletions.
2 changes: 1 addition & 1 deletion api/actions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class ReviewActionListCreate(JSONAPIBaseView, generics.ListCreateAPIView, ListFi
)

required_read_scopes = [CoreScopes.ACTIONS_READ]
required_write_scopes = [CoreScopes.NULL]
required_write_scopes = [CoreScopes.ACTIONS_WRITE]

parser_classes = (JSONAPIMultipleRelationshipsParser, JSONAPIMultipleRelationshipsParserForRegularJSON,)
serializer_class = ReviewActionSerializer
Expand Down
3 changes: 3 additions & 0 deletions api/base/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,9 @@ def to_representation(self, value):
or related_class.view_name == 'registration-citation':
related_id = resolved_url.kwargs['node_id']
related_type = 'citation'
elif related_class.view_name == 'preprint-citation':
related_id = resolved_url.kwargs['preprint_id']
related_type = 'citation'
elif related_type in ('preprint_providers', 'preprint-providers', 'registration-providers'):
related_id = resolved_url.kwargs['provider_id']
elif related_type in ('registrations', 'draft_nodes'):
Expand Down
9 changes: 9 additions & 0 deletions framework/auth/campaigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ def get_campaigns():
}
})

newest_campaigns.update({
'agu_conference_2023': {
'system_tag': CampaignSourceTags.AguConference2023.value,
'redirect_url': furl.furl(DOMAIN).add(path='dashboard/').url,
'confirmation_email_template': mails.CONFIRM_EMAIL_AGU_CONFERENCE_2023,
'login_type': 'native',
}
})

CAMPAIGNS = newest_campaigns
CAMPAIGNS_LAST_REFRESHED = timezone.now()

Expand Down
1 change: 1 addition & 0 deletions tests/test_campaigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def setUp(self):
'psyarxiv-preprints',
'osf-registries',
'osf-registered-reports',
'agu_conference_2023',
]
self.refresh = timezone.now()
campaigns.CAMPAIGNS = None # force campaign refresh now that preprint providers are populated
Expand Down
27 changes: 9 additions & 18 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5018,28 +5018,22 @@ class TestResolveGuid(OsfTestCase):
def setUp(self):
super(TestResolveGuid, self).setUp()

def test_preprint_provider_without_domain(self):
@mock.patch('website.views.use_ember_app')
def test_preprint_provider_without_domain(self, mock_use_ember_app):
provider = PreprintProviderFactory(domain='')
preprint = PreprintFactory(provider=provider)
url = web_url_for('resolve_guid', _guid=True, guid=preprint._id)
res = self.app.get(url)
assert_equal(res.status_code, 200)
assert_equal(
res.request.path,
'/{}/'.format(preprint._id)
)
mock_use_ember_app.assert_called_with()

def test_preprint_provider_with_domain_without_redirect(self):
@mock.patch('website.views.use_ember_app')
def test_preprint_provider_with_domain_without_redirect(self, mock_use_ember_app):
domain = 'https://test.com/'
provider = PreprintProviderFactory(_id='test', domain=domain, domain_redirect_enabled=False)
preprint = PreprintFactory(provider=provider)
url = web_url_for('resolve_guid', _guid=True, guid=preprint._id)
res = self.app.get(url)
assert_equal(res.status_code, 200)
assert_equal(
res.request.path,
'/{}/'.format(preprint._id)
)
mock_use_ember_app.assert_called_with()

def test_preprint_provider_with_domain_with_redirect(self):
domain = 'https://test.com/'
Expand All @@ -5062,16 +5056,13 @@ def test_preprint_provider_with_domain_with_redirect(self):



def test_preprint_provider_with_osf_domain(self):
@mock.patch('website.views.use_ember_app')
def test_preprint_provider_with_osf_domain(self, mock_use_ember_app):
provider = PreprintProviderFactory(_id='osf', domain='https://osf.io/')
preprint = PreprintFactory(provider=provider)
url = web_url_for('resolve_guid', _guid=True, guid=preprint._id)
res = self.app.get(url)
assert_equal(res.status_code, 200)
assert_equal(
res.request.path,
'/{}/'.format(preprint._id)
)
mock_use_ember_app.assert_called_with()


class TestConfirmationViewBlockBingPreview(OsfTestCase):
Expand Down
4 changes: 4 additions & 0 deletions website/mails/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ def get_english_article(word):
'confirm_erpc',
subject='OSF Account Verification, Election Research Preacceptance Competition'
)
CONFIRM_EMAIL_AGU_CONFERENCE_2023 = Mail(
'confirm_agu_conference_2023',
subject='OSF Account Verification, from the American Geophysical Union Conference'
)
CONFIRM_EMAIL_PREPRINTS = lambda name, provider: Mail(
'confirm_preprints_{}'.format(name),
subject='OSF Account Verification, {}'.format(provider)
Expand Down
13 changes: 10 additions & 3 deletions website/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,16 @@ def ember_app(path=None):
for k in EXTERNAL_EMBER_APPS.keys():
if request.path.strip('/').startswith(k):
ember_app = EXTERNAL_EMBER_APPS[k]
if k == 'preprints' and request.path.rstrip('/').endswith('discover'):
# Route preprint discover pages to new search page in EOW
ember_app = EXTERNAL_EMBER_APPS.get('ember_osf_web', False) or ember_app
if k == 'preprints':
if request.path.rstrip('/').endswith('edit'):
# Route preprint edit pages to old preprint app
ember_app = EXTERNAL_EMBER_APPS.get('preprints', False) or ember_app
elif request.path.rstrip('/').endswith('submit'):
# Route preprint submit pages to old preprint app
ember_app = EXTERNAL_EMBER_APPS.get('preprints', False) or ember_app
else:
# Route other preprint pages to EOW
ember_app = EXTERNAL_EMBER_APPS.get('ember_osf_web', False) or ember_app
break

if not ember_app:
Expand Down
25 changes: 25 additions & 0 deletions website/templates/emails/confirm_agu_conference_2023.html.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<%inherit file="notify_base.mako" />

<%def name="content()">
<tr>
<td style="border-collapse: collapse;">
Hello ${user.fullname},<br>
<br>
Thank you for joining us at the AGU Open Science Pavilion, and welcome to the Open Science Framework.
We are pleased to offer a special AGU attendees exclusive community call to continue our conversation and to help
you get oriented on the OSF. This is an opportunity for us to show you useful OSF features, talk about
open science in your domains, and for you to ask any questions you may have.
You can register for this free event here:
<br>
https://cos-io.zoom.us/meeting/register/tZAuceCvrjotHNG3n6XzLFDv1Rnn2hkjczHr
<br><br>
To confirm your OSF account, please verify your email address by visiting this link:<br>
<br>
${confirmation_url}<br>
<br>
From the team at the Center for Open Science<br>
</tr>
</%def>
1 change: 1 addition & 0 deletions website/util/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class CampaignSourceTags(Enum):
ErpChallenge = campaign_source_tag('erp_challenge')
OsfRegisteredReports = campaign_source_tag('osf_registered_reports')
Osf4m = campaign_source_tag('osf4m')
AguConference2023 = campaign_source_tag('agu_conference_2023')


class OsfClaimedTags(Enum):
Expand Down
4 changes: 3 additions & 1 deletion website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ def resolve_guid(guid, suffix=None):
if isinstance(resource, Preprint):
if resource.provider.domain_redirect_enabled:
return redirect(resource.absolute_url, http_status.HTTP_301_MOVED_PERMANENTLY)
return stream_emberapp(EXTERNAL_EMBER_APPS['preprints']['server'], preprints_dir)
if clean_suffix.endswith('edit'):
return stream_emberapp(EXTERNAL_EMBER_APPS['preprints']['server'], preprints_dir)
return use_ember_app()

elif isinstance(resource, Registration) and (clean_suffix in ('', 'comments', 'links', 'components', 'resources',)) and waffle.flag_is_active(request, features.EMBER_REGISTRIES_DETAIL_PAGE):
return use_ember_app()
Expand Down

0 comments on commit 2d56c94

Please sign in to comment.