Skip to content

Commit 3c80a49

Browse files
committed
Merge tag '23.15.4' into develop
Hotfix tombstone page
2 parents 988f174 + 2dea2ec commit 3c80a49

File tree

5 files changed

+65
-45
lines changed

5 files changed

+65
-45
lines changed

app/models/preprint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default class PreprintModel extends OsfModel {
6464
license!: AsyncBelongsTo<LicenseModel> & LicenseModel;
6565

6666
@belongsTo('file', { inverse: null })
67-
primaryFile!: AsyncBelongsTo<FileModel> & FileModel;
67+
primaryFile?: AsyncBelongsTo<FileModel> & FileModel;
6868

6969
@belongsTo('preprint-provider', { inverse: 'preprints' })
7070
provider!: AsyncBelongsTo<PreprintProviderModel> & PreprintProviderModel;

app/preprints/detail/route.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,16 @@ export default class PreprintsDetail extends Route {
5858

5959
const provider = await preprint?.get('provider');
6060

61-
const primaryFile = await preprint?.get('primaryFile');
62-
63-
primaryFile.versions = await primaryFile?.versions;
64-
6561
this.theme.set('providerType', 'preprint');
6662
this.theme.set('id', provider.id);
6763

64+
let primaryFile;
65+
66+
if (!preprint.isWithdrawn) {
67+
primaryFile = await preprint?.get('primaryFile');
68+
primaryFile.versions = await primaryFile?.versions;
69+
}
70+
6871
const contributors = await preprint?.queryHasMany('contributors');
6972

7073
const license = await preprint?.get('license');

mirage/factories/preprint.ts

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface PreprintMirageModel extends PreprintModel {
2323

2424
export interface PreprintTraits {
2525
pendingWithdrawal: Trait;
26+
withdrawn: Trait;
2627
isContributor: Trait;
2728
rejectedWithdrawalComment: Trait;
2829
acceptedWithdrawalComment: Trait;
@@ -77,24 +78,6 @@ export default Factory.extend<PreprintMirageModel & PreprintTraits>({
7778
afterCreate(preprint, server) {
7879
guidAfterCreate(preprint, server);
7980

80-
const file = server.create('file', {
81-
// Comment in the id with a guid and the download if you want to
82-
// verify the `serializeVersions` method in the `preprint-file-render`
83-
// component
84-
id: 'afile',
85-
// id: '65453248654b1e000b0ac15e',
86-
target: preprint,
87-
links: {
88-
info: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
89-
move: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
90-
delete: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
91-
html: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
92-
upload: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
93-
// download: 'https://staging3.osf.io/download/65453248654b1e000b0ac15e/',
94-
download: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
95-
},
96-
});
97-
9881
const node = server.create('node');
9982

10083
const license = server.create('license', {
@@ -129,13 +112,31 @@ export default Factory.extend<PreprintMirageModel & PreprintTraits>({
129112

130113
const allContributors = [contributor, unregisteredContributor, secondContributor, thirdContributor];
131114

115+
const file = server.create('file', {
116+
// Comment in the id with a guid and the download if you want to
117+
// verify the `serializeVersions` method in the `preprint-file-render`
118+
// component
119+
// id: 'afile',
120+
// id: '65453248654b1e000b0ac15e',
121+
target: preprint,
122+
links: {
123+
info: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
124+
move: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
125+
delete: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
126+
html: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
127+
upload: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
128+
// download: 'https://staging3.osf.io/download/65453248654b1e000b0ac15e/',
129+
download: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf',
130+
},
131+
});
132+
132133
preprint.update({
133134
contributors: allContributors,
134135
bibliographicContributors: allContributors,
135-
files: [file],
136-
primaryFile: file,
137136
license,
138137
subjects,
138+
files: [file],
139+
primaryFile: file,
139140
date_created: new Date('2018-05-05T14:49:27.746938Z'),
140141
date_modified: new Date('2018-07-02T11:51:07.837747Z'),
141142
date_published: new Date('2018-05-05T14:54:01.681202Z'),
@@ -171,12 +172,25 @@ export default Factory.extend<PreprintMirageModel & PreprintTraits>({
171172
},
172173
}),
173174

175+
withdrawn: trait<PreprintModel>({
176+
afterCreate(preprint, server) {
177+
const primaryFile = server.schema.files.find(preprint.primaryFile!.id);
178+
primaryFile.destroy();
179+
preprint.update({
180+
files: undefined,
181+
primaryFile: undefined,
182+
});
183+
},
184+
}),
185+
174186
acceptedWithdrawalComment: trait<PreprintModel>({
175187
afterCreate(preprint, server) {
176188
const preprintRequest = server.create('preprintRequest', {
177189
target: preprint,
178190
}, 'acceptComment');
179-
preprint.update({ requests: [preprintRequest ]});
191+
preprint.update({
192+
requests: [preprintRequest ],
193+
});
180194
},
181195
}),
182196

@@ -191,7 +205,6 @@ export default Factory.extend<PreprintMirageModel & PreprintTraits>({
191205

192206
reviewAction: trait<PreprintModel>({
193207
afterCreate(preprint, server) {
194-
// console.log('created');
195208
const creator = server.create('user', { fullName: 'Review action Commentor' });
196209
const preprintReviewAction = server.create('review-action', {
197210
target: preprint,

mirage/scenarios/preprints.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function buildOSF(
154154
isPublished: false,
155155
dateWithdrawn: new Date(),
156156
addLicenseName: false,
157-
}), 'isContributor');
157+
}), 'isContributor', 'withdrawn' );
158158

159159
const withdrawnLicensePreprint = server.create('preprint', Object({
160160
provider: osf,
@@ -166,7 +166,7 @@ function buildOSF(
166166
dateWithdrawn: new Date(),
167167
withdrawalJustification: 'This is the justification',
168168
description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(100)}`,
169-
}), 'isContributor');
169+
}), 'isContributor', 'withdrawn');
170170

171171
const pendingWithdrawalPreprint = server.create('preprint', {
172172
provider: osf,

mirage/serializers/preprint.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,6 @@ export default class PreprintSerializer extends ApplicationSerializer<PreprintMi
4444
},
4545
},
4646
},
47-
files: {
48-
links: {
49-
related: {
50-
href: `${apiUrl}/v2/preprints/${model.id}/files/`,
51-
meta: this.buildRelatedLinkMeta(model, 'files'),
52-
},
53-
},
54-
},
55-
primaryFile: {
56-
links: {
57-
related: {
58-
href: `${apiUrl}/v2/files/${model.primaryFile.id}/`,
59-
meta: this.buildRelatedLinkMeta(model, 'files'),
60-
},
61-
},
62-
},
6347
license: {
6448
links: {
6549
related: {
@@ -118,6 +102,26 @@ export default class PreprintSerializer extends ApplicationSerializer<PreprintMi
118102
},
119103
};
120104

105+
if (model.primaryFile) {
106+
relationships['files'] = {
107+
links: {
108+
related: {
109+
href: `${apiUrl}/v2/preprints/${model.id}/files/`,
110+
meta: this.buildRelatedLinkMeta(model, 'files'),
111+
},
112+
},
113+
};
114+
115+
relationships['primaryFile'] = {
116+
links: {
117+
related: {
118+
href: `${apiUrl}/v2/files/${model.primaryFile.id}/`,
119+
meta: this.buildRelatedLinkMeta(model, 'files'),
120+
},
121+
},
122+
};
123+
}
124+
121125
if (model.license !== null) {
122126
const { id } = model.license;
123127
relationships.license = {

0 commit comments

Comments
 (0)