| author | raph |
| Wed, 03 Feb 2010 15:42:56 +0100 | |
| changeset 142 | 9b3438382e53 |
| parent 141 | 3acc965253e2 |
| 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 = "Create manager" |
|
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)!=5: |
|
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
14 |
raise CommandError("Enter manager's email, username, password, first_name, last_name") |
| 142 | 15 |
|
16 |
base64 = options.get('base64') |
|
17 |
if base64: |
|
18 |
email = b64decode(labels[0]) |
|
19 |
username = b64decode(labels[1]) |
|
20 |
password = b64decode(labels[2]) |
|
21 |
first_name = b64decode(labels[3]) |
|
22 |
last_name = b64decode(labels[4]) |
|
23 |
else: |
|
24 |
email = labels[0] |
|
25 |
username = labels[1] |
|
26 |
password = labels[2] |
|
27 |
first_name = labels[3] |
|
28 |
last_name = labels[4] |
|
29 |
||
30 |
email = email.decode('utf8') |
|
31 |
username = username.decode('utf8') |
|
32 |
password = password.decode('utf8') |
|
33 |
first_name = first_name.decode('utf8') |
|
34 |
last_name = last_name.decode('utf8') |
|
|
141
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
35 |
|
|
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
36 |
from cm.models import UserProfile |
|
3acc965253e2
add set_workspacename and create_manager management commands
raph
parents:
diff
changeset
|
37 |
UserProfile.objects._create_manager(email, username, password, first_name, last_name) |