1

I am fairly new to Django and could not figure out by reading the docs or by looking at existing questions. I looked into Django permissions and authentication but could not find a solution.

Let's say I have a Detail View listing all instances of a Model called Item. For each Item, I want to control which User can view it, and for how long. In other words, for each User having access to the Item, I want the right/permission to view it to expire after a specified period of time. After that period of time, the Item would disapear from the list and the User could not access the url detailing the Item.

The logic to implement is pretty simple, I know, but the "per user / per object" part confuses me. Help would be much appreciated!

hlcarriere
  • 13
  • 2

1 Answers1

1

Information about UserItemExpiryDate has to be stored in a separate table (Model). I would recommend using your coding in Django.

There are few scenarios to consider: 1) A new user is created, and he/she should have access to items. In this case, you add entries to UserItemExpiry with new User<>Item combination (as key) and expiry date. Then, for logged in user you look for items from Items that has User<>Item in UserItemExpiry in the future. 2) A new item is created, and it has to be added to existing users. In such case, you add entries to UserItemExpiry with ALL users<> new Item combination (as key) and expiry date. And logic for "selecting" valid items is the same as in point 1.

Best of luck, Radek Szwarc