from taskmaster.db import task_model, org_model, queue_model, tags_model
from use_cases import PROJECTS

org = {'name': ''}
queue = {'name': ''}
task = {'name': ''}

try:
    for project in PROJECTS:
        org = org_model.create({
            'name': project['name'],
        })

        for queue_definition in project['queues']:
            queue = queue_model.create({
                'name': queue_definition['name'],
                'org': org['id'],
            })

            for task_id in queue_definition['tasks']:
                task = project['tasks'][task_id]

                task_obj = {
                    "name": task['name'],
                    "org": org['id'],
                    "tags": ','.join(project['tags'].get(task['name'], [])),
                    "status": task.get('status', "Not Started"),
                    "assignee": "",
                    "created_date": datetime.datetime.now().strftime("%Y-%m-%d"),
                    "queue": queue['id'],
                    "description": task['description'],
                }
Beispiel #2
0
        user_id = user_model.id_from('email', email)
        if user_id:
            org_model.add_user(org['id'], user_id, level='admin')

    # Add queues
    org_queue_names = db.zrange('org-queues2>%s' % orgname, 0, -1)
    for queue_name in org_queue_names:
        try:
            # Check it isn't already converted
            int(queue_name, 16)
            continue
        except ValueError:
            pass

        queue = queue_model.create({
            'name': queue_name,
            'org': org['id'],
        })

        # Have tasks reference queue id instead of queue name
        try:
            db.rename('queue-tasks2>%s' % queue_name,
                      'queue-tasks2>%s' % queue['id'])
        except:
            print "Queue rename failed on %s" % queue_name

        for task_id in db.zrange('queue-tasks2>%s' % queue['id'], 0, -1):
            task_model.update(task_id, 'queue', queue['id'], internal=True)

    # Have tasks reference org id instead of org name
    try:
        db.rename('org-tasks2>%s' % orgname, 'org-tasks2>%s' % org['id'])
Beispiel #3
0
def create_queue():
    queue = queue_model.create({
        'name': request.form['name'],
        'org': g.org,
    })
    return Response(json.dumps(queue), status=201, content_type='application/json')
from taskmaster.db import task_model, org_model, queue_model, tags_model
from use_cases import PROJECTS

org = {'name': ''}
queue = {'name': ''}
task = {'name': ''}

try:
    for project in PROJECTS:
        org = org_model.create({
            'name': project['name'],
        })

        for queue_definition in project['queues']:
            queue = queue_model.create({
                'name': queue_definition['name'],
                'org': org['id'],
            })

            for task_id in queue_definition['tasks']:
                task = project['tasks'][task_id]

                task_obj = {
                    "name": task['name'],
                    "org": org['id'],
                    "tags": ','.join(project['tags'].get(task['name'], [])),
                    "status": task.get('status', "Not Started"),
                    "assignee": "",
                    "created_date":
                    datetime.datetime.now().strftime("%Y-%m-%d"),
                    "queue": queue['id'],
                    "description": task['description'],
        user_id = user_model.id_from('email', email)
        if user_id:
            org_model.add_user(org['id'], user_id, level='admin')

    # Add queues
    org_queue_names = db.zrange('org-queues2>%s' % orgname, 0, -1)
    for queue_name in org_queue_names:
        try:
            # Check it isn't already converted
            int(queue_name, 16)
            continue
        except ValueError:
            pass

        queue = queue_model.create({
            'name': queue_name,
            'org': org['id'],
        })

        # Have tasks reference queue id instead of queue name
        try:
            db.rename('queue-tasks2>%s' % queue_name, 'queue-tasks2>%s' % queue['id'])
        except:
            print "Queue rename failed on %s" % queue_name

        for task_id in db.zrange('queue-tasks2>%s' % queue['id'], 0, -1):
            task_model.update(task_id, 'queue', queue['id'], internal=True)

    # Have tasks reference org id instead of org name
    try:
        db.rename('org-tasks2>%s' % orgname, 'org-tasks2>%s' % org['id'])
    except: