From 2d36d419eae2e414cf2584338cc5aee66bdc70ec Mon Sep 17 00:00:00 2001 From: Lord Business <113387478+bp-cos@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:44:04 -0700 Subject: [PATCH 1/3] See example hot fix (#2070) * Fixed the route for the see example bad link * Moved to an "in-app" transition and included a new preprint in mirage --------- Co-authored-by: Yuhuai Liu --- app/preprints/index/template.hbs | 3 ++- mirage/scenarios/preprints.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index f89a2e79b2c..c521753cfd2 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -41,7 +41,8 @@ {{t 'preprints.header.example'}} diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index fbcc033ecb5..1916c2f679b 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -200,6 +200,21 @@ function buildOSF( isPublished: false, }, 'acceptedWithdrawalComment'); + const examplePreprint = server.create('preprint', { + provider: osf, + id: 'khbvy', + title: 'The "See Example" hard-coded preprint', + currentUserPermissions: [], + reviewsState: ReviewsState.ACCEPTED, + description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(100)}`, + doi: '10.30822/artk.v1i1.79', + originalPublicationDate: new Date('2016-11-30T16:00:00.000000Z'), + preprintDoiCreated: new Date('2016-11-30T16:00:00.000000Z'), + hasCoi: true, + hasDataLinks: PreprintDataLinksEnum.NOT_APPLICABLE, + hasPreregLinks: PreprintPreregLinksEnum.NOT_APPLICABLE, + }); + const subjects = server.createList('subject', 7); osf.update({ @@ -212,6 +227,7 @@ function buildOSF( brand, moderators: [currentUserModerator], preprints: [ + examplePreprint, rejectedAdminPreprint, approvedAdminPreprint, approvedPreprint, From f44a08ba533facc3d3df56c9d9e21ef3b72c005e Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:49:43 -0500 Subject: [PATCH 2/3] Add identifier relationship to preprint (#2071) --- app/models/identifier.ts | 3 ++- app/models/preprint.ts | 4 ++++ mirage/config.ts | 5 +++++ mirage/factories/identifier.ts | 3 +-- mirage/scenarios/preprints.ts | 4 ++++ mirage/serializers/preprint.ts | 8 ++++++++ 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/models/identifier.ts b/app/models/identifier.ts index 3be3de1f310..5687b0f692f 100644 --- a/app/models/identifier.ts +++ b/app/models/identifier.ts @@ -2,13 +2,14 @@ import { attr, belongsTo, AsyncBelongsTo } from '@ember-data/model'; import NodeModel from './node'; import OsfModel from './osf-model'; +import PreprintModel from './preprint'; export default class IdentifierModel extends OsfModel { @attr('fixstring') category!: string; @attr('fixstring') value!: string; @belongsTo('node', { inverse: 'identifiers', polymorphic: true }) - referent!: AsyncBelongsTo & NodeModel; + referent!: AsyncBelongsTo & (NodeModel | PreprintModel); } declare module 'ember-data/types/registries/model' { diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 9dd77d6448f..c1284f0fd65 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -8,6 +8,7 @@ import ReviewActionModel from 'ember-osf-web/models/review-action'; import ContributorModel from './contributor'; import FileModel from './file'; +import IdentifierModel from './identifier'; import LicenseModel from './license'; import NodeModel from './node'; import OsfModel, { Permission } from './osf-model'; @@ -89,6 +90,9 @@ export default class PreprintModel extends OsfModel { @hasMany('preprint-request', { inverse: 'target'}) requests!: AsyncHasMany; + @hasMany('identifiers', { inverse: 'referent' }) + identifiers!: AsyncHasMany; + @alias('links.doi') articleDoiUrl!: string | null; @alias('links.preprint_doi') preprintDoiUrl!: string; diff --git a/mirage/config.ts b/mirage/config.ts index c023ffb9925..1f4d407d506 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -352,6 +352,11 @@ export default function(this: Server) { defaultSortKey: 'index', relatedModelName: 'subject', }); + osfNestedResource(this, 'preprint', 'identifiers', { + path: '/preprints/:parentID/identifiers/', + defaultSortKey: 'index', + relatedModelName: 'identifier', + }); this.get('/preprints/:guid/citation/:citationStyleID', getCitation); /** diff --git a/mirage/factories/identifier.ts b/mirage/factories/identifier.ts index 08234ca74c8..ff0c66ec948 100644 --- a/mirage/factories/identifier.ts +++ b/mirage/factories/identifier.ts @@ -1,4 +1,4 @@ -import { belongsTo, Factory } from 'ember-cli-mirage'; +import { Factory } from 'ember-cli-mirage'; import faker from 'faker'; import Identifier from 'ember-osf-web/models/identifier'; @@ -8,7 +8,6 @@ export default Factory.extend({ value() { return faker.fake('10.5555/{{company.bsNoun}}'); }, - referent: belongsTo({ polymorphic: true }), }); declare module 'ember-cli-mirage/types/registries/schema' { diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 1916c2f679b..6a1cfce7b90 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -59,6 +59,10 @@ function buildOSF( hasPreregLinks: PreprintPreregLinksEnum.NOT_APPLICABLE, }); + const osfApprovedAdminIdentifier = server.create('identifier'); + + approvedAdminPreprint.update({ identifiers: [osfApprovedAdminIdentifier] }); + const notContributorPreprint = server.create('preprint', { provider: osf, id: 'osf-not-contributor', diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index 53f79a73dfb..219cb3ba2ff 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -108,6 +108,14 @@ export default class PreprintSerializer extends ApplicationSerializer Date: Thu, 30 Nov 2023 17:12:10 -0500 Subject: [PATCH 3/3] Lie about inverses (#2072) --- app/models/identifier.ts | 2 +- app/models/preprint.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/identifier.ts b/app/models/identifier.ts index 5687b0f692f..cc33d5d6d8e 100644 --- a/app/models/identifier.ts +++ b/app/models/identifier.ts @@ -8,7 +8,7 @@ export default class IdentifierModel extends OsfModel { @attr('fixstring') category!: string; @attr('fixstring') value!: string; - @belongsTo('node', { inverse: 'identifiers', polymorphic: true }) + @belongsTo('node', { polymorphic: true }) referent!: AsyncBelongsTo & (NodeModel | PreprintModel); } diff --git a/app/models/preprint.ts b/app/models/preprint.ts index c1284f0fd65..b9aa48bc134 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -90,7 +90,7 @@ export default class PreprintModel extends OsfModel { @hasMany('preprint-request', { inverse: 'target'}) requests!: AsyncHasMany; - @hasMany('identifiers', { inverse: 'referent' }) + @hasMany('identifiers') identifiers!: AsyncHasMany; @alias('links.doi') articleDoiUrl!: string | null;