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

[Need QA Prep] Feature/The Amicable Node-Preprint Divorce [PLAT-555][PLAT-480][PLAT-559][PLAT-561] #8422

Conversation

pattisdr
Copy link
Contributor

@pattisdr pattisdr commented Jun 8, 2018

Purpose

Removes the dependency of Preprints on Nodes. Nodes can house supplemental files for a preprint, but beyond that, Preprints are completely independent.

Ticket contains:

How to create a preprint in the API

Step 1: Start Preprint

POST http://localhost:8000/v2/preprints/
Required fields are title and provider

request body
 {
     "data": {
       "type": "preprints",
       "attributes": {
        "title": "My first preprint",
        "tags": ["coffee", "cinnamon"]
       },
       "relationships": {
          "provider": {
             "data": {
                "type": "providers",
                "id": "osf"
             
             }
          }
    		
       }
     }
}

Step 2 Upload new file to preprint, or copy file from existing node:

Uploading new file

GET http://localhost:8000/v2/preprints/nmqp6/files/ and then

curl -X "PUT" "http://localhost:7777/v1/resources/nmqp6/providers/osfstorage/?kind=file&name=my_preprint_file.txt" \
--
-H "Authorization: Bearer my-token-goes-here" \
-H "Content-Type: text/plain" \
-d "This is a text file"

Copying file from supplementary node

Get "move" link from supplementary node and then POST to move link where resource is the preprint id, action is copy, and provider is osfstorage.
GET http://localhost:8000/v2/nodes/4u3mk/files/osfstorage/ and then

curl -X "POST" "http://localhost:7777/v1/resources/4u3mk/providers/osfstorage/5b2803b04c9d8502e5aea0cf" \
--
-H "Authorization: Bearer my-token-goes-here " \
-H "Content-Type: application/json" \
-d '{"action": "copy", "path": "/", "resource": "nmqp6", "provider": "osfstorage", "conflict": "replace"}'

Step 3 - Update preprint to set newly uploaded file as primary file, add subjects if not there already, (supplementary node optional) and publish

PATCH http://localhost:8000/v2/preprints/nmqp6/
 {
     "data": {
       "id": "nmqp6",
       "type": "preprints",
       "attributes": {
        "subjects": [["5b2419881f4ae00001670157"]],
        "is_published": "true"
       },
       "relationships": {
          "primary_file": {
             "data": {
                "type": "files",
                "id": "5b2809294c9d8502e5aea0e1"
             }
          },
          "node": {
             "data": {
                 "type": "nodes",
                 "id": "4u3mk"
             }
          }
    		
       }
     }
}

Changes

Too many to list, here are some of them.

Admin App

  • Preprints are their own thing in the admin app, not relying on node fields
  • You can modify contributors directly, flag preprints as spam, and reindex preprints in elastic search
  • Several node templates/views made more generic to work with nearly-identical preprints

API

  • Preprint endpoints are looking at preprint fields, not node fields.
  • PreprintProviderList endpoint and PreprintFiles list endpoint added (to expose OSFStorage Waterbutler endpoints for uploading primary file
  • New process for creating a preprint 1) POST to v2/preprints/ (title, provider are required fields) 2) Use WB links to upload or move file to created preprint 3) PATCH to v2/preprints/<preprint_id>/ to finish up process.
  • New preprints scopes added now that preprints/nodes are separate

Elastic Search

  • Legacy nodes attached to preprints are reindexed as nodes in a one-off script (scripts/remove_after_use/node_preprint_es.py)
  • Legacy preprints are added to the index as preprints
  • Moving forward, nodes are indexed as nodes, preprints are indexed as preprints
  • Modifications to search migration to not include QuickFIlesNode in Project list (bug fix?)
  • Modifications to search migration to add indexing for preprints and preprint files, and to stop indexing nodes as preprints

Modeling

  • New PreprintLog and PreprintContributor models
  • New ContributorMixin to share contributor-related methods between Nodes and Preprints
  • New SpamOverrideMixin to share spam-methods between Nodes and Preprints
  • Preprints uses Django-guardian for contributor permissions
  • Write contributors have been upgraded to have more permissions - can edit most things on a submitted preprint except publishing, withdrawing, etc.
  • Preprints do not have addons, so a few OSFStorage methods have been moved to the preprint.
  • UploadMixin added to Preprint that creates a root folder for storage

Preprint File

  • Stored on preprint instead of node
  • Some OSFStorage methods modified to handle permission checking on preprint in addition to node
  • Preprints have regions (by default, same region as UserSettings, in migration, pulls region off of node).

Legacy UI

  • Dashboard My Preprints fetches from users/preprints/ instead of users/nodes/?filter['preprint']=True. Activity logs removed
  • Preprint file restrictions removed from fangorn
  • Language changed on project page to reflect that project is a supplemental file for a project

screen shot 2018-06-20 at 6 29 08 pm

screen shot 2018-06-20 at 6 29 15 pm

Supplemental project attached to withdrawn preprint - status says Withdrawn

screen shot 2018-06-21 at 1 04 21 pm

screen shot 2018-06-07 at 5 58 33 pm

Withdrawn preprint still shows up for a user on My Projects page. Is marked as withdrawn.

screen shot 2018-06-20 at 4 39 01 pm

Published preprints show up on My Projects page

screen shot 2018-06-20 at 12 42 57 pm

My private preprints still show up on My Projects page

screen shot 2018-06-20 at 12 44 57 pm

Selecting multiple preprints on My Projects page

screen shot 2018-06-20 at 4 56 07 pm

Elastic search before migration - 2 preprints 3 projects

screen shot 2018-06-12 at 12 02 27 am

Elastic search after migration - 2 preprints 5 projects (2 projects formerly indexed as preprints were reindexed as projects)

screen shot 2018-06-12 at 12 08 46 am

Preprint files don't have links, but you can click on preprint link. File detail for preprint page is blocked.

screen shot 2018-06-12 at 12 08 53 am

QA Notes

Many many things to test. A lot of Node code was adapted to work for preprints so we want to make sure we didn't break things. Preprints front-end is not addressed here.

To check on Node

  • That file logs still work, (osfstorage_file_added, osfstorage_file_copied, for example). Do all the file operations on a node, verify logs are what you expect.
  • Contributor operations on nodes still work.
  • Project page banners that your node is a supplementary file for a preprint are what you expect, and appear when you expect. Test for various providers.
  • MyProjects page shows what you would expect for preprints. Activity log has been removed since we're not exposing preprint logs yet.
  • Searching for nodes still works the way it used to
  • SHARE updates for projects still work the way you would expect.
  • Test nodes in admin app, removing contributors, marking node as deleted, marking nodes as spam/ham,
  • Make sure deleting nodes with children on them still works

To check on preprint

  • Preprints themselves, instead of nodes are indexed in elastic search
  • Preprints are indexed in SHARE correctly (HAVE NOT TESTED THIS LOCALLY)
  • Test preprints in admin app, removing contributors, marking preprint as deleted, marking preprints as spam/ham, reindexing preprint in elastic search
  • Preprint files only show up in search if preprint is verified publishable
  • If you change the preprint file, the original is removed from search
  • Preprint files don't have links to file in search
  • Full regression on preprint dois

Checking migration

  • Make several preprints ahead of time, make sure they have a title, abstract, primary_file, multiple contributors with different permissions/bibligraphic, article_doi, some public, others private, some that have been deleted, some that have been abandoned, tags, some whose nodes have been marked as spam, modified date.
  • modified date of preprint will be modified to the date of a preprint-related node log if it is a later date than the preprint modified.
  • Make sure that all of these files are moved over to the preprint.

Side Effects

Ticket

Cameron Blandford and others added 30 commits March 12, 2018 09:33
[#PLAT-509]Django-guardian for preprint permissions
This reverts commit 4d9434f, reversing
changes made to 8acd0e8. 4d943f was
causing tests to fail and should be adjusted before being re-merged.
LIMIT 1
) PREPRINT ON TRUE
WHERE (TYPE = 'osf.node' OR TYPE = 'osf.registration' OR TYPE = 'osf.quickfilesnode')
WHERE (TYPE = 'osf.node' OR TYPE = 'osf.registration')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug fix? Seems like this would make quickfile nodes show up in search

- Restore dashes between preprint contributors in search
- Annotate preprint result as (Preprint)
- Delete unused email templates
- Don't index preprints that were withdrawn before becoming public
- Don't add affiliated institutions to preprints when formatting preprint
- Modify check_spam management command to separate nodes/preprints so if a node is marked as spam, a preprint is not automatially marked.
- In migrate_preprint and migrate_node, delete items from the index that have been marked as spam
- Don't restrict the queryset when running migrate_preprints, individual migrate_preprint will check whether or not item should be indexed.
- Modify data migration to change both codename and name of renamed permissions.
- Remove unnecessary attempts to modify non-existent contributor attributes on user object
- Make the contributors method more generic, by defining more class variables on the node and preprint models instead of type checking in the mixin
-
@pattisdr pattisdr force-pushed the feature/node-preprint branch 5 times, most recently from 2c16b29 to 8d20809 Compare July 5, 2018 02:04
@pattisdr pattisdr force-pushed the feature/node-preprint branch 2 times, most recently from beb09da to 49167e4 Compare July 6, 2018 16:42
- Modify enqueue_postcommit_task to just run the task while testing.
@pattisdr
Copy link
Contributor Author

pattisdr commented Jul 6, 2018

Recent updates involve responding to an in-person review w/ Steve and accommodating Erin's DOI work.

…. Shift migrations to depend on latest added (0117_set_is_root).

- See if is_quickfiles exists in update_file method (preprints don't have this attribute).
@pattisdr
Copy link
Contributor Author

Now that the one preprint per provider constraint has been removed, project page can list the multiple preprints for which it holds supplemental information. In practice, this will probably be uncommon.
animated gif-downsized_large
screen shot 2018-07-27 at 3 05 21 pm

- Nodes can hold supplemental material for multiple preprints.
- Remove migration which added a partial index on one preprint per provider per node, provided node existed.
- Project page now can display all the preprints for which the node holds supplemental material, provided the logged in user has permission to view those preprints.
- Removes a lot of now unused preprint-related node properties
- Email sent to contributors when a user is added to a node that is linked to a preprint lists all the published preprints the node holds supplemental information for.
- Remove preprint_url from relations_meta metadata tags since the node has been separated from the preprint.
- "preprint" property on the node serializer is true if the node is a supplemental node for a preprint the user can view.
@pattisdr
Copy link
Contributor Author

@laurenbarker, constraint of one preprint per provider per node removed.

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

6 participants