1

In my app there's a Project model which users can create, request to join, invite others to join, accept/reject requests/invites to join, leave, etc.

I'm using the Django LogEntry to help the application admins keep track of all changes to each Project, but also changes to related objects such as ProjectMember, ProjectMemberRequest and ProjectMemberInvite.
Both ProjectMemberRequest and ProjectMemberInvite have expiration dates which means that, if they aren't accepted/rejected within 3 days after being created, the system automatically sets them as 'expired'.

How can I log this automatic expiration of ProjectMemberRequest and ProjectMemberInvite, knowing that LogEntry requires a user and this expiration actions are not triggered by a user?

A workaround I could use is to create a "System" superuser and log these automatic actions to that user.
Is there anything better?

Marco Castanho
  • 395
  • 1
  • 7
  • 24
  • How do you 'automatically' expire those objects? – Marco Apr 21 '23 at 15:41
  • With [celery](https://docs.celeryq.dev/). When a `ProjectMemberRequest`/`ProjectMemberInvite` object is created, it sets a celery task to expire the object 3 days later, in case it isn't accepted in the meantime. – Marco Castanho Apr 24 '23 at 11:39
  • 1
    I think there is no "better" option than using a system user if you would like to use Django Admin's LogEntry module. – Marco Apr 24 '23 at 22:26

0 Answers0