forked from 42CTF/website
Compare commits
7 Commits
cce09ed254
...
32bbc392d6
Author | SHA1 | Date |
---|---|---|
Danhia | 32bbc392d6 | |
UncleReaton | acf306097a | |
UncleReaton | dc955fc189 | |
UncleReaton | e304f7cd15 | |
Danhia | 73cf94515d | |
Danhia | 94237bd9b6 | |
Starthur | a983aafba2 |
|
@ -0,0 +1,24 @@
|
||||||
|
from collections import defaultdict
|
||||||
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
from accounts import models as acc_models
|
||||||
|
from django.contrib.auth import models as auth_models
|
||||||
|
from django.contrib.auth.models import timezone
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Remove all users who never logged in'
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
all_users = acc_models.UserProfileInfo.objects.filter(score=0).select_related()
|
||||||
|
to_remove = []
|
||||||
|
for elem in all_users:
|
||||||
|
user = elem.user
|
||||||
|
if user.last_login is None and user.date_joined < timezone.now() - timedelta(hours=72):
|
||||||
|
to_remove.append(user)
|
||||||
|
print("You are going to remove {} users.".format(len(to_remove)))
|
||||||
|
answer = input("Continue ? [y/N] ")
|
||||||
|
|
||||||
|
if answer.lower() in ["y","yes"]:
|
||||||
|
for elem in to_remove:
|
||||||
|
elem.delete()
|
||||||
|
print("Users have been successfully pruned.")
|
|
@ -92,6 +92,13 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="list-group-item">{% trans "Registered since" %} {{ user.date_joined|date:"Y-m-d" }}</li>
|
<li class="list-group-item">{% trans "Registered since" %} {{ user.date_joined|date:"Y-m-d" }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul class="list-group">
|
||||||
|
<form method='GET' action="{% url 'accounts:profile' user %}">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<input class="form-control" type="submit" value="{% trans " View my profile" %}">
|
||||||
|
</li>
|
||||||
|
</form>
|
||||||
|
</ul>
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
<form method='GET' action="{% url 'accounts:delete_account' %}">
|
<form method='GET' action="{% url 'accounts:delete_account' %}">
|
||||||
{%csrf_token%}
|
{%csrf_token%}
|
||||||
|
|
|
@ -95,7 +95,7 @@
|
||||||
<a href="{% url 'accounts:edit' %}" class="nav-link">{{ request.user.username }}</a>
|
<a href="{% url 'accounts:edit' %}" class="nav-link">{{ request.user.username }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<span class="nav-link">{{ request.user.userprofileinfo.score }}</span>
|
<a class="nav-link" href="{% url 'accounts:profile' user %}">{{ request.user.userprofileinfo.score }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link" href="{% url 'accounts:out' %}">{% translate "Logout" %}</a>
|
<a class="nav-link" href="{% url 'accounts:out' %}">{% translate "Logout" %}</a>
|
||||||
|
|
Loading…
Reference in New Issue