如何设置管理员批准模型的编辑 [英] How to setup admin approval a model's edits

查看:72
本文介绍了如何设置管理员批准模型的编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个普通用户可以编辑模型的系统,但是只有在管理员批准之后才能进行编辑.我发现了一个名为 paper_trail 的宝石,该宝石具有模型版本控制功能,但不专门支持我想做的事情.我想知道其他人如何处理这个问题.我应该补充一点,就是我还希望用户能够同时进行编辑.它们不是很复杂,例如,一个就是别名.

I need a system where a regular user can edit a model but the edits don't actually happen until they are approved by an administrator. I found a gem called paper_trail that does had model versioning but doesn't support specifically what I want to do. I'm wondering how other people have handled this problem. I should add that there are also associations that I would like to be able for the user to edit at the same time. They aren't very complicated, for example one is aliases.

更复杂的部分可能是多个用户编辑同一模型并尝试进行某种合并的情况.

The more complicated part maybe be the case where multiple users edit the same model and trying to do some sort of merge.

推荐答案

一种方法是通过版本批准进行版本控制.

One approach would be to do versioning with version approval.

每次编辑都会创建模型对象及其关联的新版本.在任何时候,任何模型对象都只有一个当前"版本(及其在数据库中的表示形式).

Every edit creates a new version of the model object and its associations. At any one time there is only one "current" version of any model object (and it's representation in the database).

如果两个用户提交两个单独的编辑,则它们将创建两个待处理"版本.

If two users submit two separate edits, these would create two "pending" versions.

管理员可以通过将当前版本移动到新的待处理"版本来批准编辑.合并也可以完成,但是合并可能非常针对特定领域,并且可能导致冲突,因此无论如何保持单独的版本都是明智的.

An admin would approve edits by moving the current version to the new "pending" version. Merges could be accomplished as well, but that could be very domain specific, and could result in conflicts, so keeping separate versions would be smart anyways.

有几种方法可以做到这一点,最好的方法取决于情况的动态.

There are a few ways to accomplish this, and the best would depend on the dynamics of the situation.

我建议您查看Git的工作方式,然后尝试为您的系统建模.某种指向您的HEAD模型对象的指针,该指针具有修订历史记录,并且能够将HEAD移至不同的修订.合并也可以类似于Git.

I'd recommend looking at how Git works and trying to model your system after that. Some sort of pointer to your HEAD model object with a revision history and the ability to move HEAD to different revisions. Merging could also work similar to Git.

希望有帮助.

这篇关于如何设置管理员批准模型的编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆