adding stub for post slug update method

This commit is contained in:
Sacha Greif 2013-10-25 10:07:19 +09:00
parent 540b34d470
commit 405c1ed82c
3 changed files with 26 additions and 17 deletions

View file

@ -5,6 +5,8 @@
<li><a href="#" class="update-categories">Update Categories</a></li>
<li><a href="#" class="give-invites">Give 1 Invite to Everybody</a></li>
<li><a href="#" class="update-user-slugs">Update User Slugs</a></li>
<li><a href="#" class="update-posts-slugs">Update Posts Slugs</a></li>
<li><a href="#" class="update-comments-slugs">Update Comments Slugs</a></li>
</ul>
</div>
</template>

View file

@ -7,5 +7,8 @@ Template.toolbox.events= {
} ,
'click .update-user-slugs':function(){
Meteor.call('updateUserSlugs');
}
},
'click .update-posts-slugs':function(){
Meteor.call('updatePostsSlugs');
}
}

View file

@ -1,25 +1,29 @@
Meteor.methods({
updateCategories: function () {
if(isAdmin(Meteor.user())){
Posts.find().forEach(function(post){
if(post.categories){
console.log('Found categories for post "'+post.headline+'"');
Posts.update(post._id,{$set:{userId:post.user_id}}, function(error){
console.log(error);
});
}
});
updateCategories: function () {
// TODO: see if this method is still necessary
if(isAdmin(Meteor.user())){
Posts.find().forEach(function(post){
if(post.categories){
console.log('Found categories for post "'+post.headline+'"');
Posts.update(post._id,{$set:{userId:post.user_id}}, function(error){
console.log(error);
});
}
});
}
},
},
giveInvites: function () {
if(isAdmin(Meteor.user()))
Meteor.users.update({}, {$inc:{invitesCount: 1}}, {multi:true});
},
updateUserSlugs: function () {
if(isAdmin(Meteor.user())){
Meteor.users.find().forEach(function(user){
Meteor.users.update(user._id, {$set:{slug: slugify(getUserName(user))}});
});
}
if(isAdmin(Meteor.user())){
Meteor.users.find().forEach(function(user){
Meteor.users.update(user._id, {$set:{slug: slugify(getUserName(user))}});
});
}
},
updatePostsSlugs: function () {
//TODO
}
})