refactor authorIsCurrentUser to user model as isAuthorOf

Dried up authorIsCurrentUser in views.js

removed authorIsCurrentUser, now called from views.js

remove authorIsCurrentUser from views.js
This commit is contained in:
Daniel Sun 2014-08-19 10:32:36 +01:00
parent 844fe9d6b9
commit 13419066d4
4 changed files with 8 additions and 12 deletions

View file

@ -15,5 +15,9 @@ app.models.User = Backbone.Model.extend({
isServiceConfigured : function(providerName) { isServiceConfigured : function(providerName) {
return _.include(this.get("configured_services"), providerName) return _.include(this.get("configured_services"), providerName)
},
isAuthorOf: function(model) {
return this.authenticated() && model.get("author").id == this.id;
} }
}); });

View file

@ -18,7 +18,7 @@ app.views.Photo = app.views.Base.extend({
presenter : function() { presenter : function() {
return _.extend(this.defaultPresenter(), { return _.extend(this.defaultPresenter(), {
authorIsCurrentUser : this.authorIsCurrentUser(), authorIsCurrentUser : app.currentUser.isAuthorOf(this.model),
}); });
} }
}); });

View file

@ -1,16 +1,12 @@
app.views.Post = app.views.Base.extend({ app.views.Post = app.views.Base.extend({
presenter : function() { presenter : function() {
return _.extend(this.defaultPresenter(), { return _.extend(this.defaultPresenter(), {
authorIsCurrentUser : this.authorIsCurrentUser(), authorIsCurrentUser : app.currentUser.isAuthorOf(this.model),
showPost : this.showPost(), showPost : this.showPost(),
text : app.helpers.textFormatter(this.model.get("text"), this.model) text : app.helpers.textFormatter(this.model.get("text"), this.model)
}) })
}, },
authorIsCurrentUser : function() {
return app.currentUser.authenticated() && this.model.get("author").id == app.user().id
},
showPost : function() { showPost : function() {
return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw") return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw")
} }

View file

@ -25,16 +25,12 @@ app.views.SinglePostContent = app.views.Base.extend({
presenter : function() { presenter : function() {
return _.extend(this.defaultPresenter(), { return _.extend(this.defaultPresenter(), {
authorIsCurrentUser : this.authorIsCurrentUser(), authorIsCurrentUser :app.currentUser.isAuthorOf(this.model),
showPost : this.showPost(), showPost : this.showPost(),
text : app.helpers.textFormatter(this.model.get("text"), this.model) text : app.helpers.textFormatter(this.model.get("text"), this.model)
}) })
}, },
authorIsCurrentUser : function() {
return app.currentUser.authenticated() && this.model.get("author").id == app.user().id
},
showPost : function() { showPost : function() {
return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw") return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw")
} }