Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLAT-1181] Waffle all Prereg Challenge specific parts of the codebase #8833

Merged

Conversation

Johnetordoff
Copy link
Contributor

Purpose

We have to shut down all prereg challenge registration capbilities at midmight on New's Years Eve, the PR covers some of the gaps.

Changes

  • disables challenge submit button with waffle switch
  • disables submit/ endpoint with waffle switch (not they can hit it through the browser anyway
  • disables email task with waffle switch

QA Notes

According to David the admin commenting ability doesn't effect users, so it can be totally removed in the future, so no need to waffle now.

Documentation

technical task, no docs.

Side Effects

No that I know of.

Ticket

https://openscience.atlassian.net/browse/PLAT-1181

%if waffle.switch_is_active(features.OSF_PREREGISTRATION):
<button type="button" class="btn btn-success pull-right"
data-toggle="tooltip" data-placement="top" title="The Prereg Challenge has expired"
style="margin-left: 5px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird use of style tags here because the disabled class unjustly disables tooltips, so it's hacked to look and act disabled.

if not dry_run:
add_file_logger(logger, __file__)
main(dry_run=dry_run)
if not waffle.switch_is_active(features.OSF_PREREGISTRATION):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might seem better to waffle this in the Celery config in defaults.py then here inside the running task, but that causes a circular import in waffle

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with David M. in person and we can completely remove this reminder email now (no sense reminding people to finish their prereg draft when there's two weeks remaining...). Go ahead and remove the script, task, and email template.

Copy link
Contributor

@caseyrollins caseyrollins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor suggestions and a bit more code that can be removed. Thanks for your work on this @Johnetordoff, looks good!

"""Landing page for the prereg challenge"""
return views._view_registries_landing_page('prereg', **kwargs)
"""Landing page for osf prereg"""
if waffle.switch_is_active(features.OSF_PREREGISTRATION):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the changes to this function necessary? The same mako template is returned regardless of the switch and it doesn't look like _view_registraties_landing_page was changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, campaign is used to determine which draft registrations to load on the landing page. Got it.


%if waffle.switch_is_active(features.OSF_PREREGISTRATION):
<button type="button" class="btn btn-success pull-right"
data-toggle="tooltip" data-placement="top" title="The Prereg Challenge has expired"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "The Prereg Challenge has ended."? Ended sounds a bit more accurate than expired imo.

@@ -121,6 +123,9 @@ def submit_draft_for_review(auth, node, draft, *args, **kwargs):
:rtype: dict
:raises: HTTPError if embargo end date is invalid
"""
if waffle.switch_is_active(features.OSF_PREREGISTRATION):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test to ensure that this function doesn't execute when the switch is active?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if not dry_run:
add_file_logger(logger, __file__)
main(dry_run=dry_run)
if not waffle.switch_is_active(features.OSF_PREREGISTRATION):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with David M. in person and we can completely remove this reminder email now (no sense reminding people to finish their prereg draft when there's two weeks remaining...). Go ahead and remove the script, task, and email template.

@caseyrollins
Copy link
Contributor

@Johnetordoff, we should also go ahead and remove the custom messaging that's passed here to this template (it's also passed to 5 or so other templates -- do a global find to find them all). We don't want to mention the Prereg Challenge if someone registers an existing draft in January,

@caseyrollins
Copy link
Contributor

When the osf_preregistration switch is active, I still see this tooltip on the "Register without review" button. I think we should remove both of these buttons and replace with a single "Register" (like all other forms) when the switch is active.

screen shot 2018-12-05 at 12 18 35 pm

Also, this modal appears when I click "Register for review" and should be removed.

screen shot 2018-12-05 at 12 18 58 pm

@caseyrollins
Copy link
Contributor

I'm seeing these buttons when creating an "OSF Preregistration" registration. The "Submit for review" button shouldn't exist for this schema.
screen shot 2018-12-05 at 12 27 41 pm

<span data-bind="if: (draft.metaSchema.name === 'Prereg Challenge' && !draft.isPendingApproval)">
<button id="register-submit" type="button" class="btn btn-primary pull-right" data-toggle="tooltip" data-placement="top" title="Not eligible for the Pre-Registration Challenge" data-bind="click: draft.registerWithoutReview.bind(draft)">Register without review</button>
</span>
%endif:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: : after endif should be removed

@caseyrollins caseyrollins changed the base branch from feature/prereg-winddown to develop December 6, 2018 18:39
@caseyrollins
Copy link
Contributor

@Johnetordoff, one minor comment and a merge conflict that needs resolving. Looks great when testing locally!

 into winddown-waffle-the-rest

* 'develop' of https://github.com/CenterForOpenScience/osf.io:
  Bump version and update changelog
  [PLAT-1254] Fix embargoing pre-registrations
  Update export_user_account script for files-on-anything
  Add an absolute_url property to Institutions model
  Move call to delete files on a node to a celery task
  Expect 410 gone again rather than not permission for less confusion
  Allow sorting search results by "modified"
  Downgrade DRF to 3.8.2
  Raise 410 instead of 404, include helpful message
  Update entity ID for Ferris
  When viewing a deleted file on a private node with no access, raise 404
  If a node is deleted, show No files in the file browser when viewing tombstone metadata
  Update index settings, post-bulk indexing
  Limit the number of buckets in ES aggregation for preprints
  Upgrade django-elasticsearch-metrics; speed up backfill
  Reduce batch size; show progress
  Delete files on nodes removed from bulk destroy
  Fix related lookup contenttype restriction
  Change URL for captured raven message to send to Sentry
  chore: upgrade to osf-style@1.8.0

# Conflicts:
#	website/project/views/drafts.py
'is_logged_in': False,
}
)

cache.delete(Switch._cache_key(OSF_PREREGISTRATION))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? If you're using override_switch to set the value of a switch, you shouldn't have to worry about the cache.

}
)

cache.delete(Switch._cache_key(OSF_PREREGISTRATION))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are unnecessary, too, right?

@@ -121,6 +123,12 @@ def submit_draft_for_review(auth, node, draft, *args, **kwargs):
:rtype: dict
:raises: HTTPError if embargo end date is invalid
"""
if waffle.switch_is_active(features.OSF_PREREGISTRATION):
raise HTTPError(http.GONE, data={
'message_short': 'The Prereg Challenge has ended.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: message_short isn't usually a sentence, because it gets rendered as the page title when the OsfWebRenderer is used. Is this ever rendered to HTML?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this should never actually be hittable by the UI.

if waffle.switch_is_active(features.OSF_PREREGISTRATION):
raise HTTPError(http.GONE, data={
'message_short': 'The Prereg Challenge has ended.',
'message_long': 'The Prereg Challenge has ended. This endpoint is currently depreciated.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "deprecated". That said, this endpoint isn't really deprecated (I mean...all of v1 is deprecated, but that's besides the point)--it is still used for other schemas.

Maybe it makes sense for message_long to be The Prereg Challenge has ended. No new submissions are accepted at this time. message_short` can be unset, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is still used for other schemas.

Just to clarify Prereg Challenge is the only schema that uses this endpoint because it's the only one where requiresApproval is set to true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ok. Then I suppose it's fine to deprecate this endpoint. Just need to make sure we weren't exposing language like "deprecated endpoint" in the UI.

Copy link
Contributor

@sloria sloria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just took a quick glance. Looks good to go to staging. Just a few nits.

@caseyrollins
Copy link
Contributor

Deployed to staging3 🎉

@caseyrollins
Copy link
Contributor

Latest commits headed to staging3

@@ -144,7 +144,7 @@
},
{
"text": "Registration following analysis of the data",
"tooltip": "As of the date of submission, you have accessed and analyzed some of the data relevant to the research plan. This includes preliminary analysis of variables, calculation of descriptive statistics, and observation of data distributions. Please contact us (prereg@cos.io) and we will be happy to help you."
"tooltip": "As of the date of submission, you have accessed and analyzed some of the data relevant to the research plan. This includes preliminary analysis of variables, calculation of descriptive statistics, and observation of data distributions. Please see https://cos.io/prereg for more information."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Johnetordoff Will these changes require a migration?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's my bad. I pushed a migration to release/next-platform but not to this branch because I thought this PR already had an ensure_schemas migration. This PR will need a migration like this: 8cbe44b

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sloria Yes we'll have to run ensure_schemas to see any effect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok. @Johnetordoff Can you please add that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please document in "Side Effects" that python manage.py migrate needs to be run when this is released (and any other necessary steps).

@sloria
Copy link
Contributor

sloria commented Dec 18, 2018

I got this up to date with develop in release/18.9.0. I canceled the build so that we can get that release branch's build started. If that passes, I'll go ahead and release.

@sloria sloria merged commit 816c61b into CenterForOpenScience:develop Dec 19, 2018
@Johnetordoff Johnetordoff deleted the winddown-waffle-the-rest branch August 17, 2023 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants