Implementing Admin Trash in Open Event
So last week I had the task of implementing a trash system for the Admin. It was observed that sometimes a user may delete an item and then realize that the item needs to be restores. Thus a trash system works well in this case. Presently the items that are being moved to the trash are:
- Deleted Users
- Deleted Events
- Deleted Sessions
So it works like this. I added a column in_trash to the tables User, Event and Sessions to mark whether the item is in the trash or not
in_trash = db.Column(db.Boolean, default=False)
So depending on whether the value is True or False the item will be in the trash of the admin. Thus for a normal user on deleting an event, user or session a message would flash that the item is deleted and the item would not be shown in the table list of the user. However it would not be deleted from the database.
Thus for the user the item is deleted. The item’s in_trash property is set to True and it gets moved to the trash. The items are displayed in the “Deleted Items” section of the Admin panel
The items deleted are displayed in the trash and as soon as they deleted in the trash they are deleted from the database permanently. A message will flash for the Admin when it is deleted
Thus the trash is implemented. 🙂
Two more things are left:
- To restore items from trash
- To automatically delete the items in trash after an inactivity of 30 days
This will soon be implemented 🙂
You must be logged in to post a comment.