Developing a platform that grows with the help of the community is a complex task.
I am currently experiencing difficulties in processing community contributions to my publicly available Database.
My Backend is designed using django, and people are allowed to update some data via api calls.
The structure of the Database Table is designed with three states: “draft”, “accepted” and “rejected”.
class SomeModel(models.Model): class Status(models.TextChoices): DRAFT = 'draft', _('Draft') ACCEPTED = 'accepted', _('Accepted') REJECTED = 'rejected', _('Rejected') top_city = models.CharField(max_length=255) ... all other attributes goes here ...
Let’s look at the model example above, so that after the moderator reviews the contribution of one of the users from the community, it sets the status Accepted, and this record becomes active. Let’s say someone makes changes to this particular record and these changes cannot be immediately published as they need to be reviewed before. So I can set it to a draft and apply the changes made, but in this case I will lose the previous accepted changes and also this record will be hidden from the community until it is reviewed and accepted.
I hope, I could get the point across.
How to design models so that I can save the contributions to the “temporary model” and apply them to the main model after changing their status to the adopted model.
Solution that I’m thinking about
I could created separate models for each attribute of the main model, for instance:
class PendingChangesToTopCityAttributeOfSomeModel(models.Model): value_to_be_reviewd = models.CharField(max_length=255) apply_to_model = models.ForegnKey(SomeModel) def reject(self): reject_changes def accept(self): accept changes
If I do it this way, I will end up with a huge number of models and it will be very difficult to maintain such a project.
I hope you guys have better advice how to handle this problem.