Limit species and strain new access
This commit is contained in:
parent
58779a4a7d
commit
bb2386807c
4 changed files with 34 additions and 16 deletions
|
@ -18,12 +18,6 @@ export default Ember.Controller.extend({
|
|||
},
|
||||
|
||||
cancel: function() {
|
||||
let species = this.get('model');
|
||||
|
||||
if (species.get('isNew')) {
|
||||
species.deleteRecord();
|
||||
}
|
||||
|
||||
this.transitionToRoute('species.index');
|
||||
},
|
||||
|
||||
|
|
|
@ -2,8 +2,25 @@ import Ember from 'ember';
|
|||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
beforeModel: function() {
|
||||
if (this.get('session.currentUser.role') === 'R') {
|
||||
this.transitionTo('species.index');
|
||||
}
|
||||
},
|
||||
|
||||
model: function() {
|
||||
return this.store.createRecord('species');
|
||||
},
|
||||
|
||||
actions: {
|
||||
willTransition: function(transition) {
|
||||
let controller = this.get('controller');
|
||||
let species = controller.get('model');
|
||||
|
||||
if (species.get('isNew')) {
|
||||
species.deleteRecord();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
|
Reference in a new issue