Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactivation user cleans the reason of the last deactivation via comm… #37

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
"Operating System :: OS Independent",
"Topic :: Software Development"
],
zip_safe=True,
zip_safe=False,
packages=[
'useraudit',
'useraudit.migrations',
'useraudit.management.commands',
],
include_package_date=True,
include_package_data=True,
)
2 changes: 2 additions & 0 deletions useraudit/management/commands/activate_user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth import get_user_model
from django.db import transaction
from useraudit.models import UserDeactivation


class Command(BaseCommand):
Expand Down Expand Up @@ -30,3 +31,4 @@ def _activate_user(self, user):
return
user.is_active = True
user.save()
UserDeactivation.objects.filter(username=user.username).delete()
3 changes: 2 additions & 1 deletion useraudit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.auth import get_user_model
from django.urls import reverse

from .models import LoginAttemptLogger
from .models import LoginAttemptLogger, UserDeactivation
from . import middleware


Expand All @@ -24,6 +24,7 @@ def reactivate_user(request, user_id):
user = _get_user(user_id)
user.is_active = True
user.save()
UserDeactivation.objects.filter(username=user.username).delete()
login_attempt_logger.reset(user.username)
return HttpResponseRedirect(reverse("admin:useraudit_loginattempt_changelist"))

Expand Down