diaspora/app/assets/javascripts/app/models/person.js
Florian Staudacher fba3092c61 * cleanup people_controller#show, add people_controller#stream for json
* introduce new presenters and extend the functionality of the BasePresenter
* add a handlebars template for the profile sidebar, render it everytime we need to update
* introduce a 'aspect_membership:update' global event
2014-09-15 01:37:23 +02:00

39 lines
952 B
JavaScript

app.models.Person = Backbone.Model.extend({
urlRoot: '/people',
url: function() {
return this.urlRoot + '/' + this.get('guid');
},
initialize: function() {
if( this.get('profile') )
this.profile = new app.models.Profile(this.get('profile'));
},
isSharing: function() {
var rel = this.get('relationship');
return (rel == 'mutual' || rel == 'sharing');
},
isReceiving: function() {
var rel = this.get('relationship');
return (rel == 'mutual' || rel == 'receiving');
},
isMutual: function() {
return (this.get('relationship') == 'mutual');
},
isBlocked: function() {
return (this.get('relationship') == 'blocked');
},
block: function() {
var self = this;
var block = new app.models.Block({block: {person_id: this.id}});
// return the jqXHR with Promise interface
return block.save()
.done(function() { app.events.trigger('person:block:'+self.id); });
}
});