Exemplo n.º 1
0
def ParseError(msg, request, status=400):
    caltitle    = request.POST.get("title", '')
    callocation = request.POST.get("location", '')
    shiftinput  = request.POST.get("roster", None)

    if not caltitle:
        caltitle = request.GET.get("title", '')
    if not callocation:
        callocation = request.GET.get("location", '')

    dbroster = Roster(
        event_title=caltitle,
        event_location=callocation,
        raw_roster=shiftinput,
        method='site',
        created=dtnow(),
        success=False,
        error=msg
    )

    if request.POST.get('bm', False):
        dbroster.method = 'bookmarklet'
        dbroster.version = request.POST.get('v', '_none_')

    dbroster.save()

    return JSONError(msg, status)