Total Complexity | 3 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | |||
2 | import logging |
||
3 | |||
4 | from django.core.management import BaseCommand |
||
5 | |||
6 | from uid.models import truncate_database, truncate_filled_tables |
||
7 | |||
8 | # Get an instance of a logger |
||
9 | logger = logging.getLogger(__name__) |
||
10 | |||
11 | |||
12 | class Command(BaseCommand): |
||
13 | help = """Truncate uid tables and reset counters""" |
||
14 | |||
15 | def add_arguments(self, parser): |
||
16 | # Named (optional) arguments |
||
17 | parser.add_argument( |
||
18 | '--all', |
||
19 | action='store_true', |
||
20 | dest='all', |
||
21 | help='Truncate all uid tables and reset counters', |
||
22 | ) |
||
23 | |||
24 | def handle(self, *args, **options): |
||
25 | # HINT: maybe UID or InjectTools could be more informative than |
||
26 | # uid suffix? |
||
27 | |||
28 | logger.info("Starting truncate_image_tables") |
||
29 | |||
30 | if options['all'] is True: |
||
31 | truncate_database() |
||
32 | |||
33 | else: |
||
34 | truncate_filled_tables() |
||
35 | |||
36 | # debug |
||
37 | logger.info("Done!") |
||
38 |