Authorship

This commit is contained in:
Matthew Dillon 2015-05-13 15:29:17 -08:00
parent e2aa298a8f
commit 8afce44a5e
7 changed files with 65 additions and 21 deletions

View file

@ -11,7 +11,7 @@ export default Ability.extend({
canEdit: function() { canEdit: function() {
let role = this.get('session.currentUser.role'); let role = this.get('session.currentUser.role');
let id = this.get('session.currentUser.id'); let id = this.get('session.currentUser.id');
let author = this.get('model.author'); let author = this.get('model.createdBy');
return (role === 'W' && (+id === author)) || (role === 'A'); return (role === 'W' && (+id === author)) || (role === 'A');
}.property('session.currentUser.role', 'session.currentUser.id', 'model.author') }.property('session.currentUser.role', 'session.currentUser.id', 'model.createdBy')
}); });

View file

@ -7,5 +7,8 @@ export default DS.Model.extend({
measurements: DS.hasMany('measurements'), measurements: DS.hasMany('measurements'),
createdAt: DS.attr('date'), createdAt: DS.attr('date'),
updatedAt: DS.attr('date'), updatedAt: DS.attr('date'),
deletedAt: DS.attr('date') deletedAt: DS.attr('date'),
createdBy: DS.attr('number'),
updatedBy: DS.attr('number'),
deletedBy: DS.attr('number')
}); });

View file

@ -13,6 +13,8 @@ export default DS.Model.extend({
testMethod: DS.attr('string'), testMethod: DS.attr('string'),
createdAt: DS.attr('date'), createdAt: DS.attr('date'),
updatedAt: DS.attr('date'), updatedAt: DS.attr('date'),
createdBy: DS.attr('number'),
updatedBy: DS.attr('number'),
computedType: Ember.computed('textMeasurementType', 'txtValue', 'numValue', function() { computedType: Ember.computed('textMeasurementType', 'txtValue', 'numValue', function() {
if (this.get('textMeasurementType') && !this.get('txtValue') && !this.get('numValue')) { if (this.get('textMeasurementType') && !this.get('txtValue') && !this.get('numValue')) {
return 'Fixed-text'; return 'Fixed-text';

View file

@ -13,7 +13,9 @@ export default DS.Model.extend({
createdAt: DS.attr('date'), createdAt: DS.attr('date'),
updatedAt: DS.attr('date'), updatedAt: DS.attr('date'),
deletedAt: DS.attr('date'), deletedAt: DS.attr('date'),
author: DS.attr('number'), createdBy: DS.attr('number'),
updatedBy: DS.attr('number'),
deletedBy: DS.attr('number'),
totalMeasurements: DS.attr('number'), totalMeasurements: DS.attr('number'),
fullName: Ember.computed('speciesName', 'strainName', function() { fullName: Ember.computed('speciesName', 'strainName', function() {
return this.get('speciesName') + ' (' + this.get('strainName') + ')'; return this.get('speciesName') + ' (' + this.get('strainName') + ')';

View file

@ -11,7 +11,10 @@ module.exports = function(app) {
measurements: [1], measurements: [1],
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z", updatedAt: "0001-01-01T00:00:00Z",
deletedAt: null deletedAt: null,
createdBy: 1,
updatedBy: 1,
deletedBy: null
}, },
{ {
id: 2, id: 2,
@ -21,7 +24,10 @@ module.exports = function(app) {
measurements: [2], measurements: [2],
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z", updatedAt: "0001-01-01T00:00:00Z",
deletedAt: null deletedAt: null,
createdBy: 1,
updatedBy: 1,
deletedBy: null
}, },
{ {
id: 3, id: 3,
@ -31,7 +37,10 @@ module.exports = function(app) {
measurements: [3], measurements: [3],
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z", updatedAt: "0001-01-01T00:00:00Z",
deletedAt: null deletedAt: null,
createdBy: 1,
updatedBy: 1,
deletedBy: null
} }
] ]

View file

@ -15,7 +15,9 @@ module.exports = function(app) {
notes: null, notes: null,
testMethod: null, testMethod: null,
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z" updatedAt: "0001-01-01T00:00:00Z",
createdBy: 1,
updatedBy: 1
}, },
{ {
id: 2, id: 2,
@ -29,7 +31,9 @@ module.exports = function(app) {
notes: null, notes: null,
testMethod: null, testMethod: null,
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z" updatedAt: "0001-01-01T00:00:00Z",
createdBy: 1,
updatedBy: 1
}, },
{ {
id: 3, id: 3,
@ -43,7 +47,9 @@ module.exports = function(app) {
notes: "some notes", notes: "some notes",
testMethod: null, testMethod: null,
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z" updatedAt: "0001-01-01T00:00:00Z",
createdBy: 1,
updatedBy: 1
}, },
{ {
id: 4, id: 4,
@ -57,7 +63,9 @@ module.exports = function(app) {
notes: null, notes: null,
testMethod: null, testMethod: null,
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z" updatedAt: "0001-01-01T00:00:00Z",
createdBy: 1,
updatedBy: 1
}, },
{ {
id: 5, id: 5,
@ -71,7 +79,9 @@ module.exports = function(app) {
notes: null, notes: null,
testMethod: null, testMethod: null,
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z" updatedAt: "0001-01-01T00:00:00Z",
createdBy: 1,
updatedBy: 1
}, },
{ {
id: 6, id: 6,
@ -85,7 +95,9 @@ module.exports = function(app) {
notes: null, notes: null,
testMethod: null, testMethod: null,
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z" updatedAt: "0001-01-01T00:00:00Z",
createdBy: 1,
updatedBy: 1
}, },
{ {
id: 7, id: 7,
@ -99,7 +111,9 @@ module.exports = function(app) {
notes: null, notes: null,
testMethod: null, testMethod: null,
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z" updatedAt: "0001-01-01T00:00:00Z",
createdBy: 1,
updatedBy: 1
}, },
{ {
id: 8, id: 8,
@ -113,7 +127,9 @@ module.exports = function(app) {
notes: "some notes", notes: "some notes",
testMethod: null, testMethod: null,
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z" updatedAt: "0001-01-01T00:00:00Z",
createdBy: 1,
updatedBy: 1
}, },
{ {
id: 9, id: 9,
@ -127,7 +143,9 @@ module.exports = function(app) {
notes: null, notes: null,
testMethod: null, testMethod: null,
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z" updatedAt: "0001-01-01T00:00:00Z",
createdBy: 1,
updatedBy: 1
}, },
{ {
id: 10, id: 10,
@ -141,7 +159,9 @@ module.exports = function(app) {
notes: null, notes: null,
testMethod: null, testMethod: null,
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z" updatedAt: "0001-01-01T00:00:00Z",
createdBy: 1,
updatedBy: 1
} }
] ]

View file

@ -15,7 +15,9 @@ module.exports = function(app) {
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z", updatedAt: "0001-01-01T00:00:00Z",
deletedAt: null, deletedAt: null,
author: 1, createdBy: 1,
updatedBy: 1,
deletedBy: null,
totalMeasurements: 5, totalMeasurements: 5,
notes: "Test notes", notes: "Test notes",
}, },
@ -31,7 +33,9 @@ module.exports = function(app) {
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z", updatedAt: "0001-01-01T00:00:00Z",
deletedAt: null, deletedAt: null,
author: 3, createdBy: 3,
updatedBy: 3,
deletedBy: null,
totalMeasurements: 5, totalMeasurements: 5,
notes: "Test notes", notes: "Test notes",
}, },
@ -47,7 +51,9 @@ module.exports = function(app) {
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z", updatedAt: "0001-01-01T00:00:00Z",
deletedAt: null, deletedAt: null,
author: 1, createdBy: 1,
updatedBy: 1,
deletedBy: null,
totalMeasurements: 0, totalMeasurements: 0,
notes: "Test notes", notes: "Test notes",
}, },
@ -63,7 +69,9 @@ module.exports = function(app) {
createdAt: "0001-01-01T00:00:00Z", createdAt: "0001-01-01T00:00:00Z",
updatedAt: "0001-01-01T00:00:00Z", updatedAt: "0001-01-01T00:00:00Z",
deletedAt: null, deletedAt: null,
author: 3, createdBy: 3,
updatedBy: 3,
deletedBy: null,
totalMeasurements: 0, totalMeasurements: 0,
notes: "Test notes", notes: "Test notes",
} }