|
|
|
@ -224,22 +224,21 @@ def status_mobile_modal (request, *args, **kwargs):
|
|
|
|
|
|
|
|
|
|
@staff_login_required
|
|
|
|
|
def user_recent_activities_modal(request, user_id):
|
|
|
|
|
current_time = timezone.now()
|
|
|
|
|
today = datetime.now().date()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Calculate the datetime of 24 hours ago
|
|
|
|
|
twenty_four_hours_ago = current_time - timezone.timedelta(hours=24)
|
|
|
|
|
|
|
|
|
|
if user_id:
|
|
|
|
|
specific_user = get_object_or_404(User, id=user_id)
|
|
|
|
|
|
|
|
|
|
# Fetch the specific user's statuses from the last 24 hours
|
|
|
|
|
user_statuses = Status.objects.filter(staff__user=specific_user, date__gte=twenty_four_hours_ago).order_by('-id')
|
|
|
|
|
user_statuses = Status.objects.filter(staff__user=specific_user, date=today).order_by('-id')
|
|
|
|
|
|
|
|
|
|
# Calculate time ago for each user status and store it in a dictionary
|
|
|
|
|
user_statuses_time_ago = [{'status': status, 'time_ago': calculate_time_ago(status)} for status in user_statuses]
|
|
|
|
|
else:
|
|
|
|
|
# No specific user ID provided, fetch statuses for all users in the last 24 hours
|
|
|
|
|
all_user_statuses = Status.objects.filter(date__gte=twenty_four_hours_ago).order_by('-id')
|
|
|
|
|
all_user_statuses = Status.objects.filter(date=today).order_by('-id')
|
|
|
|
|
|
|
|
|
|
# Calculate time ago for each user status and store it in a dictionary
|
|
|
|
|
user_statuses_time_ago = [{'status': status, 'time_ago': calculate_time_ago(status)} for status in all_user_statuses]
|
|
|
|
|