Skip to content

Commit

Permalink
Tweak awaiting approval count to better ignore inactive users
Browse files Browse the repository at this point in the history
  • Loading branch information
FreneticScribbler committed Oct 11, 2023
1 parent 1a32ef4 commit e265ad5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions RIGS/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import hashlib
import random
import string
Expand Down Expand Up @@ -77,7 +76,7 @@ def admins(cls):
@classmethod
def users_awaiting_approval_count(cls):
# last_login = None ensures we only pick up genuinely new users, not those that have been deactivated for inactivity
return Profile.objects.filter(is_approved=False, last_login=None).count()
return Profile.objects.filter(is_approved=False, last_login=None, date_joined_date=timezone.now().date()).count()

def __str__(self):
return self.name
Expand Down
3 changes: 2 additions & 1 deletion RIGS/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import urllib.parse
import urllib.request
from io import BytesIO
import datetime

from PyPDF2 import PdfFileReader, PdfFileMerger
from django.conf import settings
Expand Down Expand Up @@ -110,7 +111,7 @@ def send_admin_awaiting_approval_email(user, request, **kwargs):
if admin.last_emailed is None or admin.last_emailed + settings.EMAIL_COOLDOWN <= timezone.now():
context = {
'request': request,
'link_suffix': reverse("admin:RIGS_profile_changelist") + '?is_approved__exact=0',
'link_suffix': reverse("admin:RIGS_profile_changelist") + f'?is_approved__exact=0&date_joined__date={timezone.now().date()}',
'number_of_users': models.Profile.users_awaiting_approval_count(),
'to_name': admin.first_name
}
Expand Down

0 comments on commit e265ad5

Please sign in to comment.