src/cm/management/commands/set_workspacename.py
author Simon Descarpentries <sid@sopinspace.com>
Wed, 30 Oct 2013 18:08:42 +0100
changeset 556 69503659fe8f
parent 142 9b3438382e53
permissions -rw-r--r--
[c_selection.js] If safari_mobile, get current selection from a previously created global variable [c_sync.js] ref where the safari_mobile global is used [c_text_view_comments.js] if safari_mobile update selection also on selectionChange event [text_view_comments.html] if safari_mobile store a clone of the current selection on each selectionChange set layout width to 99% to improve display factorize safari mobile detection code

from django.core.management.base import LabelCommand, CommandError, BaseCommand, make_option
from base64 import b64decode

class Command(LabelCommand):
    option_list = BaseCommand.option_list + (
        make_option('--base64', action='store_true', dest='base64', default=False,
            help='Assume all input are base64 encoded.'),
    )
    
    help = "Change workspace name"

    def handle(self, *labels, **options):
        if len(labels)!=1:
            raise CommandError('Enter workspace name')
        base64 = options.get('base64')
        if base64:
            name = b64decode(labels[0])
        else:
            name = labels[0]
        name = name.decode('utf8')
        
        from cm.models import Configuration        
        Configuration.objects.set_workspace_name(name)