def getStatusDetails(request):
    response = dict()

    statusid = request.REQUEST['statusid']
    lastmessageid = request.REQUEST.get('lastmessageid', None)

    try:
        status = Status.getStatus(statusid)
    except Status.DoesNotExist:
        return errorResponse("Invalid status")

    messagesJson = getNewStatusMessages(status, lastmessageid)
    locationSuggestions = list()
    for locationSugg in status.locationSuggestions.all():
        locationSuggestions.append(createLocationSuggestionJson(locationSugg))

    timeSuggestions = list()
    for timeSugg in status.timeSuggestions.all():
        timeSuggestions.append(createTimeSuggestionJson(timeSugg))

    response['success'] = True
    response['messages'] = messagesJson
    attending, invited, userDetails = createAttendingAndInvitedAndUserDetailsJsonResponse(status)
    response['attending'] = attending
    response['invited'] = invited
    response['users'] = userDetails
    response['locationsuggestions'] = locationSuggestions
    response['timesuggestions'] = timeSuggestions
    response['deleted'] = status.deleted

    response.update(createStatusJsonObject(status))

    return HttpResponse(json.dumps(response))
def sendStatusMessage(request):
    response = dict()

    text = request.REQUEST['text']
    userid = request.REQUEST['userid']
    statusid = request.REQUEST['statusid']
    lastMessageId = request.REQUEST.get('lastmessageid', None)

    try:
        userProfile = UserProfile.getUser(userid)
    except UserProfile.DoesNotExist:
        return errorResponse('Invalid User')

    try:
        status = Status.getStatus(statusid)
    except Status.DoesNotExist:
        return errorResponse('Invalid status id')

    message = StatusMessage.objects.create(user=userProfile, text=text, status=status)
    sendStatusMessageNotification(message)
    createCreateStatusMessageNotification(message)

    response['success'] = True
    response['messages'] = getNewStatusMessages(status, lastMessageId)

    return HttpResponse(json.dumps(response))