Roughing in ember-can: placeholders for strain mod

This commit is contained in:
Matthew Dillon 2015-04-22 11:44:25 -08:00
parent b337ca0ee4
commit ce40ef6071
7 changed files with 53 additions and 0 deletions
app/abilities

17
app/abilities/strain.js Normal file
View 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')
});