How to make Premoderation for documents in collection


#1

I’m working on Arabic-Russian dictionary which contains from Articles. I want to make premoderation for editing and adding. Until now I have only one idea how to realize it. (I will glad to hear other ideas too)

If user haven’t Moderator role, all his edits of some Article will save to special field: { premoderation: [ {Article version from user1}, {Article version with from user2}, .... ]

And then Moderator will check all this Premoderation Article versions and merge them manually with actual Article if they are good, or delete them.

Question is: how to get Autoform data (Article object) - before submit and if user is not Moderator, save Article version to especial field without saving it to main document.


#2

I would check out this hooks package. You can do a permissions check based on the userId, and then make adjustments based on that.

Note that if you are using before hook on an insert, you will be making changes to the doc, whereas if you are using the before hook on an update, you will be making changes to the modifier – changing the doc won’t do anything. I still make that mistake once in a while!


#3

What I do is that whener a user saves, the document body gets $pushed into a “history” array on the document. Admins can look through the whole history and select any version, that is then copied into the “content” field. Before $pushing, I check if the user was the last one that made an edit previously, and if that was less than a day ago, I replace their latest “commit” instead, to reduce clutter a bit. As you see, this way you get also a full version history (and I use a diffing package to highlight changes between versions in the “history” view)


#4

This is the point where I’d start moving logic into Meteor methods and do all the special handling in there