-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c6b37e
commit c41444e
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.core.management.base import BaseCommand, CommandError | ||
from django.contrib.sites.models import Site | ||
from django.conf import settings | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Set Patchman Site Name' | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
'-n', '--name', dest='site_name', help='Site name') | ||
parser.add_argument( | ||
'--clear-cache', action='store_true', default=False, | ||
dest='clear_cache', help='Clear Site cache') | ||
|
||
def handle(self, *args, **options): | ||
try: | ||
Site.objects.filter(pk=settings.SITE_ID).update( | ||
name=options['site_name'], domain=options['site_name']) | ||
if options['claer_cache']: | ||
Site.objects.clear_cache() | ||
except Exception as e: | ||
raise CommandError('Failed to update Site name', str(e)) |