You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
725 B
Python
24 lines
725 B
Python
# tasks.py
|
|
from celery import shared_task
|
|
from osinacore.models import *
|
|
from django.db.models import Q
|
|
|
|
@shared_task
|
|
def set_offline():
|
|
print('Hello')
|
|
all_staff_profiles = StaffProfile.objects.all()
|
|
|
|
staff_without_working_points = all_staff_profiles.exclude(
|
|
Q(task__point__status='Working On')
|
|
)
|
|
|
|
users_without_working_points = [staff_profile.user for staff_profile in staff_without_working_points]
|
|
print(users_without_working_points)
|
|
|
|
# Create a new connection record for each user with status set to 'Offline'
|
|
for user in users_without_working_points:
|
|
Connection.objects.create(
|
|
status='Offline',
|
|
date=timezone.now(),
|
|
user=user
|
|
) |