##// END OF EJS Templates
Deleting old users when the new are created. Only empty users without posts and tags are removed
neko259 -
r486:9da0f7ed 1.6-dev
parent child Browse files
Show More
@@ -1,3 +1,8 b''
1 from datetime import datetime, timedelta
2 from django.db.models import Count
3
4 OLD_USER_AGE_DAYS = 90
5
1 __author__ = 'neko259'
6 __author__ = 'neko259'
2
7
3 import hashlib
8 import hashlib
@@ -521,6 +526,8 b' def _get_user(request):'
521 user = User.objects.create(user_id=new_id, rank=RANK_USER,
526 user = User.objects.create(user_id=new_id, rank=RANK_USER,
522 registration_time=time_now)
527 registration_time=time_now)
523
528
529 _delete_old_users()
530
524 session['user_id'] = user.id
531 session['user_id'] = user.id
525 else:
532 else:
526 user = User.objects.get(id=session['user_id'])
533 user = User.objects.get(id=session['user_id'])
@@ -588,3 +595,17 b' def _get_template_thread(thread_to_show)'
588 'last_replies': last_replies,
595 'last_replies': last_replies,
589 'skipped_replies': skipped_replies_count,
596 'skipped_replies': skipped_replies_count,
590 }
597 }
598
599
600 def _delete_old_users():
601 """
602 Delete users with no favorite tags and posted messages. These can be spam
603 bots or just old user accounts
604 """
605
606 old_registration_date = datetime.now().date() - timedelta(OLD_USER_AGE_DAYS)
607
608 for user in User.objects.annotate(tags_count=Count('fav_tags')).filter(
609 tags_count=0).filter(registration_time__lt=old_registration_date):
610 if not Post.objects.filter(user=user).exists():
611 user.delete()
@@ -7,4 +7,5 b' thread.'
7 * Added new gallery with search links and image metadata
7 * Added new gallery with search links and image metadata
8
8
9 # 1.6 Amon #
9 # 1.6 Amon #
10 * Deleted threads are moved to archive instead of permanent delete No newline at end of file
10 * Deleted threads are moved to archive instead of permanent delete
11 * User management fixes and optimizations No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now