mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
parent
e6f24cc78a
commit
81bcd47ab0
4 changed files with 30 additions and 0 deletions
0
src/auditlog/management/__init__.py
Normal file
0
src/auditlog/management/__init__.py
Normal file
0
src/auditlog/management/commands/__init__.py
Normal file
0
src/auditlog/management/commands/__init__.py
Normal file
20
src/auditlog/management/commands/auditlogflush.py
Normal file
20
src/auditlog/management/commands/auditlogflush.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from django.core.management.base import NoArgsCommand
|
||||
from six import moves
|
||||
|
||||
from auditlog.models import LogEntry
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
help = 'Deletes all log entries from the database.'
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
answer = None
|
||||
|
||||
while answer not in ['', 'y', 'n']:
|
||||
answer = moves.input("Are you sure? [y/N]: ").lower().strip()
|
||||
|
||||
if answer == 'y':
|
||||
count = LogEntry.objects.all().count()
|
||||
LogEntry.objects.all().delete()
|
||||
|
||||
print("Deleted %d objects." % count)
|
||||
10
src/auditlog_tests/manage.py
Normal file
10
src/auditlog_tests/manage.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "auditlog_tests.test_settings")
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
execute_from_command_line(sys.argv)
|
||||
Loading…
Reference in a new issue