Skip to content

Commit

Permalink
Merge tag '23.15.2' into develop
Browse files Browse the repository at this point in the history
Hotfix for see example link and plaudit widget
  • Loading branch information
adlius committed Dec 1, 2023
2 parents 6320bc4 + daed496 commit f1a1d6d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/models/identifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> & NodeModel;
@belongsTo('node', { polymorphic: true })
referent!: AsyncBelongsTo<NodeModel | PreprintModel> & (NodeModel | PreprintModel);
}

declare module 'ember-data/types/registries/model' {
Expand Down
4 changes: 4 additions & 0 deletions app/models/preprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -89,6 +90,9 @@ export default class PreprintModel extends OsfModel {
@hasMany('preprint-request', { inverse: 'target'})
requests!: AsyncHasMany<PreprintRequestModel>;

@hasMany('identifiers')
identifiers!: AsyncHasMany<IdentifierModel>;

@alias('links.doi') articleDoiUrl!: string | null;
@alias('links.preprint_doi') preprintDoiUrl!: string;

Expand Down
3 changes: 2 additions & 1 deletion app/preprints/index/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
<OsfLink
data-test-submission-see-submission-example
data-analytics-name='See Submission Example'
@href={{concat '/content/' (if this.theme.provider.example this.theme.provider.example 'khbvy')}}
@route='resolve-guid'
@models={{array (if this.theme.provider.example this.theme.provider.example 'khbvy')}}
>
{{t 'preprints.header.example'}}
</OsfLink>
Expand Down
5 changes: 5 additions & 0 deletions mirage/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down
3 changes: 1 addition & 2 deletions mirage/factories/identifier.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -8,7 +8,6 @@ export default Factory.extend<Identifier>({
value() {
return faker.fake('10.5555/{{company.bsNoun}}');
},
referent: belongsTo({ polymorphic: true }),
});

declare module 'ember-cli-mirage/types/registries/schema' {
Expand Down
20 changes: 20 additions & 0 deletions mirage/scenarios/preprints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -200,6 +204,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({
Expand All @@ -212,6 +231,7 @@ function buildOSF(
brand,
moderators: [currentUserModerator],
preprints: [
examplePreprint,
rejectedAdminPreprint,
approvedAdminPreprint,
approvedPreprint,
Expand Down
8 changes: 8 additions & 0 deletions mirage/serializers/preprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ export default class PreprintSerializer extends ApplicationSerializer<PreprintMi
},
},
},
identifiers: {
links: {
related: {
href: `${apiUrl}/v2/preprints/${model.id}/identifiers/`,
meta: this.buildRelatedLinkMeta(model, 'identifiers'),
},
},
},
};

if (model.license !== null) {
Expand Down

0 comments on commit f1a1d6d

Please sign in to comment.