This repository has been archived on 2025-03-30. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
hymenobacterdotinfo/app/abilities/strain.js
Matthew Dillon 8afce44a5e Authorship
2015-05-13 15:29:17 -08:00

17 lines
667 B
JavaScript

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.createdBy');
return (role === 'W' && (+id === author)) || (role === 'A');
}.property('session.currentUser.role', 'session.currentUser.id', 'model.createdBy')
});