Skip to content
Snippets Groups Projects
Commit 25923e28 authored by Tore.Brede's avatar Tore.Brede
Browse files

GREG-7: Adding comment

parent cf2fd3b6
No related branches found
No related tags found
1 merge request!18GREG-7: Simple task running functionality. Adding ask for checking roles about to expire
Pipeline #89035 passed
......@@ -46,7 +46,10 @@ class BaseSchedule(ABC):
class ExpiringRolesNotification(BaseSchedule):
"""
This task does a simple check for roles that will expire in 30 days
and creates entries in the notification table for them
and creates entries in the notification table for them.
There should be an entry in the ScheduleTask-table with name role_expiration
before this task is run.
Some assumptions that are made:
......@@ -66,13 +69,14 @@ class ExpiringRolesNotification(BaseSchedule):
def _run_internal(self):
last_run = self.get_last_run()
# Only run once per day
if last_run is None or last_run.date() != date.today():
check_date = datetime.today() + timedelta(
days=self.EXPIRATION_THRESHOLD_DAYS
)
self._get_roles_about_to_expire(check_date)
self.__get_roles_about_to_expire(check_date)
def _get_roles_about_to_expire(self, end_date: date):
def __get_roles_about_to_expire(self, end_date: date):
roles_about_to_expire = PersonRole.objects.filter(end_date=end_date)
for person_role in roles_about_to_expire:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment