Completed
Pull Request — master (#68)
by Paolo
08:44 queued 07:18
created

Command.add_arguments()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nop 2
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