Introduced a new field ends_at to the Role model, allowing roles to be granted for a specified period and automatically removed after a certain date.
Changes:
saas/models.py:
Modified RoleManager, providing two approaches to ensure the role is only valid if datetime_or_now < ends_at. The first approach, involving changes to the get_queryset method, is left commented but might be the overall "correct" approach as it automatically excludes expired roles. However, it's risky since it's unclear where this queryset is being referenced, and it could potentially break existing functionality. The second approach is implemented and should not affect existing queries.
Updated AbstractRole to add the ends_at field and related methods.
Added related comments to document both approaches.
The inclusion of two approaches is there for consideration of the best method.
Introduced a new field
ends_at
to the Role model, allowing roles to be granted for a specified period and automatically removed after a certain date.Changes:
saas/models.py
:RoleManager
, providing two approaches to ensure the role is only valid ifdatetime_or_now < ends_at
. The first approach, involving changes to theget_queryset
method, is left commented but might be the overall "correct" approach as it automatically excludes expired roles. However, it's risky since it's unclear where this queryset is being referenced, and it could potentially break existing functionality. The second approach is implemented and should not affect existing queries.AbstractRole
to add theends_at
field and related methods.The inclusion of two approaches is there for consideration of the best method.