| author | raph |
| Mon, 22 Mar 2010 11:02:39 +0100 | |
| changeset 224 | cc85d241b81d |
| parent 142 | 9b3438382e53 |
| permissions | -rw-r--r-- |
| 142 | 1 |
from django.core.management.base import LabelCommand, CommandError, BaseCommand, make_option |
2 |
from base64 import b64decode |
|
|
141
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
3 |
|
|
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
4 |
class Command(LabelCommand): |
| 142 | 5 |
option_list = BaseCommand.option_list + ( |
6 |
make_option('--base64', action='store_true', dest='base64', default=False, |
|
7 |
help='Assume all input are base64 encoded.'), |
|
8 |
) |
|
9 |
||
|
141
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
10 |
help = "Change workspace name" |
|
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
11 |
|
|
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
12 |
def handle(self, *labels, **options): |
|
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
13 |
if len(labels)!=1: |
|
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
14 |
raise CommandError('Enter workspace name') |
| 142 | 15 |
base64 = options.get('base64') |
16 |
if base64: |
|
17 |
name = b64decode(labels[0]) |
|
18 |
else: |
|
19 |
name = labels[0] |
|
20 |
name = name.decode('utf8') |
|
21 |
||
22 |
from cm.models import Configuration |
|
23 |
Configuration.objects.set_workspace_name(name) |