Rough in species
This commit is contained in:
parent
dfc62cd1ac
commit
afcf24a8d8
22 changed files with 399 additions and 2 deletions
17
app/abilities/species.js
Normal file
17
app/abilities/species.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { Ability } from 'ember-can';
|
||||
|
||||
export default Ability.extend({
|
||||
// Only admins and writers can create a new species
|
||||
canAdd: function() {
|
||||
let role = this.get('session.currentUser.role');
|
||||
return (role === 'W') || (role === 'A');
|
||||
}.property('session.currentUser.role'),
|
||||
|
||||
// Only admins and the person who created can edit
|
||||
canEdit: function() {
|
||||
let role = this.get('session.currentUser.role');
|
||||
let id = this.get('session.currentUser.id');
|
||||
let author = this.get('model.createdBy');
|
||||
return (role === 'W' && (+id === author)) || (role === 'A');
|
||||
}.property('session.currentUser.role', 'session.currentUser.id', 'model.createdBy')
|
||||
});
|
Reference in a new issue