@@ -23,6 +23,7 @@ export interface PreprintMirageModel extends PreprintModel {
2323
2424export 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 ,
0 commit comments