Exemple #1
0
def createSchedules(request):
    """
    Create SchedulingRequest and submit a task in the queue to process it.

    The request body looks like this:
    {
        scheduleTemplate: int,
        users: [list of user IDs],
        events: [{
                meta: {
                    isCollective: true
                },
                data: {
                    summary: 'Breakfast!',
                    description: 'Everyone is welcome',
                    locations: [list of room IDs],
                    date: '2014-05-22',
                    startTime: '09:00',
                    endTime: '09:25',
                    invitees: [list of user IDs],
                    eventTemplate: int
                }
            },
            {
                meta: {
                    isCollective: false,
                    forUser: int (user ID)
                },
                data: {
                    ... same fields ...
                }
            }
            ...additional events...
        ]
    }
    """

    if request.method == 'POST':
        schedReq = models.SchedulingRequest.objects.create(
            json=json.dumps(json.load(request)),
            requestedBy=request.user,
            status=models.SchedulingRequest.IN_PROGRESS)
        tasksched.enqueue(tasksched.SCHED_REQ, schedReq.id)
        return HttpResponse('', status=202)

    return HttpResponse(json.dumps({
        'error':
        'Method ' + request.method + ' not allowed. Use POST instead.'
    }),
                        content_type="application/json",
                        status=405)
Exemple #2
0
def schedulingRequestDetail(request, sr_id):
    if request.method == 'DELETE':
        sr = models.SchedulingRequest.objects.get(id=sr_id)
        dr = models.DeletionTask.objects.create(schedReq=sr,
                requestedByUser=request.user)
        tasksched.enqueue(tasksched.DELETION_TASK, dr.id)
        return HttpResponse('')
    elif request.method == 'GET':
        context = {'sr_id': sr_id}
        return render(request, 'futuschedule/scheduling-request-detail.html',
                context)
    else:
        return HttpResponse(json.dumps({'error': 'Method ' + request.method +
            ' not allowed.'}), content_type="application/json", status=405)
Exemple #3
0
def createSchedules(request):
    """
    Create SchedulingRequest and submit a task in the queue to process it.

    The request body looks like this:
    {
        scheduleTemplate: int,
        users: [list of user IDs],
        events: [{
                meta: {
                    isCollective: true
                },
                data: {
                    summary: 'Breakfast!',
                    description: 'Everyone is welcome',
                    locations: [list of room IDs],
                    date: '2014-05-22',
                    startTime: '09:00',
                    endTime: '09:25',
                    invitees: [list of user IDs],
                    eventTemplate: int
                }
            },
            {
                meta: {
                    isCollective: false,
                    forUser: int (user ID)
                },
                data: {
                    ... same fields ...
                }
            }
            ...additional events...
        ]
    }
    """

    if request.method == 'POST':
        schedReq = models.SchedulingRequest.objects.create(
                json=json.dumps(json.load(request)),
                requestedBy=request.user,
                status=models.SchedulingRequest.IN_PROGRESS)
        tasksched.enqueue(tasksched.SCHED_REQ, schedReq.id)
        return HttpResponse('', status=202)

    return HttpResponse(json.dumps({'error': 'Method ' + request.method +
        ' not allowed. Use POST instead.'}),
        content_type="application/json", status=405)
Exemple #4
0
def schedulingRequestDetail(request, sr_id):
    if request.method == 'DELETE':
        sr = models.SchedulingRequest.objects.get(id=sr_id)
        dr = models.DeletionTask.objects.create(schedReq=sr,
                                                requestedByUser=request.user)
        tasksched.enqueue(tasksched.DELETION_TASK, dr.id)
        return HttpResponse('')
    elif request.method == 'GET':
        context = {'sr_id': sr_id}
        return render(request, 'futuschedule/scheduling-request-detail.html',
                      context)
    else:
        return HttpResponse(json.dumps(
            {'error': 'Method ' + request.method + ' not allowed.'}),
                            content_type="application/json",
                            status=405)