def create_conferences(df):
    n_nodes = 0
    for _, row in df.drop_duplicates(subset=["conference"]).iterrows():
        conference = Conference(name=row["conference"])
        conference.save()
        n_nodes += 1
    print("created {} nodes".format(n_nodes))
예제 #2
0
def match_or_send_to_waiting_room(call, schedule):

    # Refreshing database object
    flush_transaction()
    call.reload()

    if call.matched:
        other = call.conference.call_set.exclude(pk=call.pk)[0]
        data = send_to_conference_room(call, schedule, other, initial=False)

        if data: return data


    matchcall = find_match(schedule, call)
    if matchcall:
        conf = Conference()
        conf.maxcapacity = 2
        conf.datecreated = as_date(schedule)
        conf.save()

        call.conference = conf
        call.matched = True
        call.save()

        matchcall.conference = conf
        matchcall.matched = True
        matchcall.save()

        data = send_to_conference_room(call, schedule, matchcall, initial=True)
        if data: return data

    if call.user.profile.any_match:
        call.user.profile.any_match = False
        call.user.profile.save()

        return render_to_response("twilioresponse.xml", { 'say' :"We are very sorry - We could not find you a match today, but tomorrow we'll do our best to compensate it! We wish you an awesome day!",
                                                          'hangup' : True })
    #Check if we have exceeded the waiting redirect limits
    elif call.retries >= REDIRECT_LIMIT:
        # The user has reached the limit of redials, so hang up
        logger.debug("LIMIT RETRIES - Ask to try to match with any person")
        any_match = "We could not find any matches. If you'd like us to try to match you with Anyone please press any number now."
        goodbye = "We wish you an Amazing day! Good bye!"
        return render_to_response("twilioresponse.xml", { 'any_match' :any_match, 'schedule': schedule, 'hangup': True, 'goodbye' : goodbye })

    call.retries = call.retries + 1
    call.save()

    # Send user to private conference (Conferencename=Username) or send them to the waiting room they were at
    return send_to_waiting_room(  HOLD_LIMIT
                                    , schedule
                                    , call.user.username
                                    , False
                                    , "Please bare with us - we'll find the best match for you!")
예제 #3
0
def get_active_waiting_room(schedule):
    dateSchedule = as_date(schedule)
    # Refreshing database
    flush_transaction()
    try:
        allWaitingRooms = Conference.objects.filter(datecreated=dateSchedule, maxcapacity=WAITING_ROOM_MAX)
        logger.debug("All waiting rooms: " + str(allWaitingRooms))

        # Find free waiting room
        for waiting in allWaitingRooms:
            if waiting.available():
                logger.debug("Waiting room chosen: " + str(waiting.pk))
                return waiting

    # No free waiting rooms so create one
    except Conference.DoesNotExist:
        pass # None found, so create one

    waiting = Conference()
    waiting.datecreated = dateSchedule
    waiting.maxcapacity = WAITING_ROOM_MAX
    waiting.save()
    return waiting
예제 #4
0
def get_active_waiting_room(schedule):
    dateSchedule = as_date(schedule)
    # Refreshing database
    flush_transaction()
    try:
        allWaitingRooms = Conference.objects.filter(
            datecreated=dateSchedule, maxcapacity=WAITING_ROOM_MAX)
        logger.debug("All waiting rooms: " + str(allWaitingRooms))

        # Find free waiting room
        for waiting in allWaitingRooms:
            if waiting.available():
                logger.debug("Waiting room chosen: " + str(waiting.pk))
                return waiting

    # No free waiting rooms so create one
    except Conference.DoesNotExist:
        pass  # None found, so create one

    waiting = Conference()
    waiting.datecreated = dateSchedule
    waiting.maxcapacity = WAITING_ROOM_MAX
    waiting.save()
    return waiting
예제 #5
0
파일: handlers.py 프로젝트: droot/Batty
    def post(self, id = None):
	request = self.wsgi_request
	response = self.wsgi_response
	c = self.context

	param_dict = dict(
		url_title = request.params.url_title,
		title = request.params.title,
		desc = request.params.desc,
		venue = request.params.venue,
		start_date = parse(request.params.start_date),
		end_date = parse(request.params.end_date),
		twitter_handle = request.params.twitter_handle,
		twitter_hashcode = request.params.twitter_hashcode)
	content = param_dict
	conf = Conference(**param_dict)
	conf = conf.save()
	conf.update_url_key()
	self.set_body(conf.to_json())
	response.headers['content-type'] = 'application/json'
	return self.render()
예제 #6
0
def match_or_send_to_waiting_room(call, schedule):

    # Refreshing database object
    flush_transaction()
    call.reload()

    if call.matched:
        other = call.conference.call_set.exclude(pk=call.pk)[0]
        data = send_to_conference_room(call, schedule, other, initial=False)

        if data: return data

    matchcall = find_match(schedule, call)
    if matchcall:
        conf = Conference()
        conf.maxcapacity = 2
        conf.datecreated = as_date(schedule)
        conf.save()

        call.conference = conf
        call.matched = True
        call.save()

        matchcall.conference = conf
        matchcall.matched = True
        matchcall.save()

        data = send_to_conference_room(call, schedule, matchcall, initial=True)
        if data: return data

    if call.user.profile.any_match:
        call.user.profile.any_match = False
        call.user.profile.save()

        return render_to_response(
            "twilioresponse.xml", {
                'say':
                "We are very sorry - We could not find you a match today, but tomorrow we'll do our best to compensate it! We wish you an awesome day!",
                'hangup': True
            })
    #Check if we have exceeded the waiting redirect limits
    elif call.retries >= REDIRECT_LIMIT:
        # The user has reached the limit of redials, so hang up
        logger.debug("LIMIT RETRIES - Ask to try to match with any person")
        any_match = "We could not find any matches. If you'd like us to try to match you with Anyone please press any number now."
        goodbye = "We wish you an Amazing day! Good bye!"
        return render_to_response(
            "twilioresponse.xml", {
                'any_match': any_match,
                'schedule': schedule,
                'hangup': True,
                'goodbye': goodbye
            })

    call.retries = call.retries + 1
    call.save()

    # Send user to private conference (Conferencename=Username) or send them to the waiting room they were at
    return send_to_waiting_room(
        HOLD_LIMIT, schedule, call.user.username, False,
        "Please bare with us - we'll find the best match for you!")