Permalink
Browse files

changed implementation of Blogposts to have originalAuthor field popu…

…lated by import-blogposts scripts.

Also all calls of getCreatorName do not return email address of the creator anymore.
  • Loading branch information...
1 parent 439bec0 commit b213f4ff50a98532c3e1bb6ddde09d2f2c5a6144 @outbounder outbounder committed Feb 27, 2014
@@ -6,8 +6,11 @@ module.exports = require("./MongoModel").extend({
return "/api/blogposts/"+this.id;
},
getCreatorName: function(){
- if(this.get("creator"))
- return this.get("creator").name || this.get("creator").email
+ if(this.get("originalAuthor"))
+ return this.get("originalAuthor")
+
+ if(this.get("creator") && this.get("creator").name)
+ return this.get("creator").name
else
return "unknown"
}
@@ -16,8 +16,8 @@ module.exports = require("./MongoModel").extend({
return "end date is after start date"
},
getCreatorName: function(){
- if(this.get("creator"))
- return this.get("creator").name || this.get("creator").email
+ if(this.get("creator") && this.get("creator").name)
+ return this.get("creator").name
else
return "unknown"
}
@@ -7,6 +7,7 @@ marked = require("marked")
schema = mongoose.Schema({
title: { type: String, required: true }
creator: { type: mongoose.Schema.ObjectId, ref: "Member", required: true }
+ originalAuthor: String
ingress: { type: String, required: false }
content: { type: String, required: true }
date: { type: Date, default: Date.now }
@@ -62,10 +63,13 @@ schema.method "getUrl", () ->
[@created.getFullYear(), @created.getMonth()+1, @created.getDate(), @slug].join("/")
schema.method "getCreatorName", () ->
- if @get("creator")
- @get("creator").name || @get("creator").email
+ if @originalAuthor
+ return @originalAuthor
+
+ if @get("creator") && @get("creator").name
+ return @get("creator").name
else
- "unknown"
+ return "unknown"
Base.timestampify schema
@@ -39,8 +39,8 @@ schema.method "getUrl", () ->
[@startDateTime.getFullYear(), @startDateTime.getMonth()+1, @startDateTime.getDate(), @title].join("/")
schema.method "getCreatorName", () ->
- if @get("creator")
- @get("creator").name || @get("creator").email
+ if @get("creator") && @get("creator").name
+ @get("creator").name
else
"unknown"
@@ -28,7 +28,8 @@ module.exports.exec = function(next) {
updated: new Date(entry.updated),
title: entry.title.$t,
slug: entry.title.$t,
- content: entry.content.$t
+ content: entry.content.$t,
+ originalAuthor: entry.author.name
}, function(err, post){
console.log("Inserted", entry.title.$t, allCount)
})

0 comments on commit b213f4f

Please sign in to comment.