File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
patchman/management/commands Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ from django .core .management .base import BaseCommand , CommandError
2+ from django .contrib .sites .models import Site
3+ from django .conf import settings
4+
5+
6+ class Command (BaseCommand ):
7+ help = 'Set Patchman Site Name'
8+
9+ def add_arguments (self , parser ):
10+ parser .add_argument (
11+ '-n' , '--name' , dest = 'site_name' , help = 'Site name' )
12+ parser .add_argument (
13+ '--clear-cache' , action = 'store_true' , default = False ,
14+ dest = 'clear_cache' , help = 'Clear Site cache' )
15+
16+ def handle (self , * args , ** options ):
17+ try :
18+ Site .objects .filter (pk = settings .SITE_ID ).update (
19+ name = options ['site_name' ], domain = options ['site_name' ])
20+ if options ['claer_cache' ]:
21+ Site .objects .clear_cache ()
22+ except Exception as e :
23+ raise CommandError ('Failed to update Site name' , str (e ))
You can’t perform that action at this time.
0 commit comments