Roughing in ember-can: placeholders for strain mod
This commit is contained in:
parent
b337ca0ee4
commit
ce40ef6071
7 changed files with 53 additions and 0 deletions
app/abilities
17
app/abilities/strain.js
Normal file
17
app/abilities/strain.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { Ability } from 'ember-can';
|
||||
|
||||
export default Ability.extend({
|
||||
// Only admins and writers can create a new strain
|
||||
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.author');
|
||||
return (role === 'W' && (+id === author)) || (role === 'A');
|
||||
}.property('session.currentUser.role', 'session.currentUser.id', 'model.author')
|
||||
});
|
Reference in a new issue