This repository was archived by the owner on Apr 14, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
[Feature] Changes needed for reviews to work with ember-preprints #272
Merged
aaxelb
merged 26 commits into
CenterForOpenScience:develop
from
aaxelb:feature/reviews-minimal
Oct 23, 2017
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
fb5cdda
[Feature] Update for reviews (#2)
aaxelb c237ed7
[Feature] Include reviewable when creating review logs (#3)
aaxelb 429ce0e
Add dateLastTransitioned to preprint model (#5)
aaxelb 55e69ab
[Fix] Only fetch the logged in user once
chrisseto d433892
Allow reviews settings to be nullable
chrisseto 0cc20ec
Fix infinite authentication
chrisseto b844a34
Add support for using query parameters in findRecord
chrisseto a7f14a0
[Fix] Use `getRecords()` instead of `.record` (#8)
laurenbarker 607311e
Tweaks and updates for reviews
chrisseto e416b28
Fix typo
chrisseto 9cc89c5
[Feature][MOD-73] Rename log to action (minimal branch) (#2)
aaxelb 838ad02
[MOD-72][Feature] Add "My Reviews" for users with view_submissions pe…
chrisseto 024aa2b
Add actions property to user model
aaxelb e032fa4
Add `user` property to current-user instead
aaxelb 6ad3b89
Add DOI alias properties to preprint model
aaxelb 25e5913
Fix permissions check in navbar (#6)
laurenbarker c660ea5
Only serialize actually dirty relationships
aaxelb 447e5e4
Wait for currentUser.user to resolve (#8)
laurenbarker 81a9ffa
[Feature][MOD-111] Add preprint" button direct to the current provide…
sheriefvt f1ebddf
Use forked/fixed ember-data-has-many-query
aaxelb 5eccd08
Update ember-data-has-many-query dependency
aaxelb 6f49fc9
Revert to non-forked ember-data-has-many-query
aaxelb 4964ade
Merge branch 'develop' into feature/reviews-minimal
aaxelb 671c2b9
Merge branch 'develop' into feature/reviews-minimal
aaxelb e7e565b
Update CHANGELOG
aaxelb 9d8e4b7
Merge branch 'develop' into feature/reviews-minimal
jamescdavis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import OsfAdapter from './osf-adapter'; | ||
|
|
||
| export default OsfAdapter.extend({}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import DS from 'ember-data'; | ||
| import OsfModel from './osf-model'; | ||
|
|
||
| export default OsfModel.extend({ | ||
| actionTrigger: DS.attr('string'), | ||
| comment: DS.attr('string'), | ||
| fromState: DS.attr('string'), | ||
| toState: DS.attr('string'), | ||
| dateCreated: DS.attr('date'), | ||
| dateModified: DS.attr('date'), | ||
|
|
||
| // Relationships | ||
| provider: DS.belongsTo('preprint-provider', { inverse: null, async: true }), | ||
| target: DS.belongsTo('preprint', { inverse: 'actions', async: true }), | ||
| creator: DS.belongsTo('user', { inverse: null, async: true }), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import Ember from 'ember'; | ||
| import DS from 'ember-data'; | ||
| import OsfModel from './osf-model'; | ||
|
|
||
|
|
@@ -27,10 +28,31 @@ export default OsfModel.extend({ | |
| isPublished: DS.attr('boolean'), | ||
| isPreprintOrphan: DS.attr('boolean'), | ||
| licenseRecord: DS.attr(), | ||
| reviewsState: DS.attr('string'), | ||
| dateLastTransitioned: DS.attr('date'), | ||
|
|
||
| // Relationships | ||
| node: DS.belongsTo('node', { inverse: null, async: true }), | ||
| license: DS.belongsTo('license', { inverse: null }), | ||
| primaryFile: DS.belongsTo('file', { inverse: null }), | ||
| provider: DS.belongsTo('preprint-provider', { inverse: 'preprints', async: true }), | ||
| actions: DS.hasMany('action', { inverse: 'target', async: true }), | ||
| contributors: DS.hasMany('contributors', { async: true }), | ||
|
|
||
| uniqueSubjects: Ember.computed('subjects', function() { | ||
| if (!this.get('subjects')) return []; | ||
| return this.get('subjects').reduce((acc, val) => acc.concat(val), []).uniqBy('id'); | ||
| }), | ||
|
|
||
| articleDoiUrl: Ember.computed.alias('links.doi'), | ||
| preprintDoiUrl: Ember.computed.alias('links.preprint_doi'), | ||
|
|
||
| licenseText: Ember.computed('license', function() { | ||
| const text = this.get('license.text') || ''; | ||
| const {year = '', copyright_holders = []} = this.get('licenseRecord'); | ||
|
|
||
| return text | ||
| .replace(/({{year}})/g, year) | ||
| .replace(/({{copyrightHolders}})/g, copyright_holders.join(', ')); | ||
| }), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is much better doing this here! |
||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import OsfSerializer from './osf-serializer'; | ||
|
|
||
| export default OsfSerializer.extend({ | ||
| // Because `trigger` is a private method on DS.Model | ||
| attrs: { | ||
| actionTrigger: 'trigger', | ||
| }, | ||
| // Serialize `target` relationship | ||
| relationshipTypes: { | ||
| target: 'preprints', | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,8 @@ | ||
| import Ember from 'ember'; | ||
| import OsfSerializer from './osf-serializer'; | ||
|
|
||
| export default OsfSerializer.extend({ | ||
| serialize(snapshot) { | ||
| // Normal OSF serializer strips out relationships. We need to add back primaryFile/node/provider for this endpoint | ||
| const res = this._super(...arguments); | ||
| res.data.relationships = {}; | ||
| let hasRelation = false; | ||
| for (var rel in snapshot.record._dirtyRelationships) { | ||
| let relationship = Ember.String.underscore(rel); | ||
| if (relationship.includes('license')) { | ||
| res.data.relationships[relationship] = { | ||
| data: { | ||
| id: snapshot.belongsTo(rel, { id: true }), | ||
| type: 'licenses' | ||
| } | ||
| }; | ||
| hasRelation = true; | ||
| } | ||
| } | ||
| if (!hasRelation) { | ||
| delete res.data.relationships; | ||
| } | ||
| return res; | ||
| } | ||
| // Serialize license relationship | ||
| relationshipTypes: { | ||
| license: 'licenses', | ||
| }, | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better in the model. 👍