Ejemplo n.º 1
0
def index():
    user = check_auth()
    user_hash = None
    if "PROGRAM_READY" in app.config['STAGES']:
        talks = get_talks_dict()
        extra_talks = []
    else:
        talks, extra_talks = get_talks()
        # bez razeni talks = sorted(talks, key=lambda x: x['title'])

    if user:
        user_hash = user['user_hash']

    stage_template = "index.html"
    if "END" in app.config['STAGES']:
        stage_template = "end.html"

    if "PREVIEW" in app.config['STAGES']:
        stage_template = "preview.html"

    return render_template(
        stage_template,
        user=user,
        menu=menu(),
        times=times,
        entrant_count=get_count(),
        entrants=get_entrants()[:50],
        user_votes=get_user_votes(user_hash),
        novinky=markdown_markup('novinky'),
        sponsors_main=markdown_markup('sponsors_main'),
        sponsors_medial=markdown_markup('sponsors_medial'),
        workshops=markdown_markup('workshopy-program'),
        sponsors=markdown_markup('sponsors'),
        talks=talks, extra_talks=extra_talks,
        talks_dict=get_talks_dict())
Ejemplo n.º 2
0
def index():
    talks, extra_talks = get_talks()
    workshops = get_workshops()
    tiles = Tiles(app.redis, app.config['YEAR'])
    sponsors = Sponsors(app.redis, app.config['YEAR'])

    stage_template = "index.html"
    if stage_is_active(app.config['YEAR'], 'END'):
        stage_template = "end.html"

    if stage_is_active(app.config['YEAR'], 'PREVIEW'):
        stage_template = "preview.html"

    return render_template(
        stage_template,
        times=times,
        entrant_count=get_count(),
        entrants=get_entrants()[:50],
        novinky=markdown_markup('novinky'),
        talks=talks,
        extra_talks=extra_talks,
        talks_dict=get_talks_dict(),
        workshops=workshops,
        hi_tiles=filter(lambda x: x['score'] > 10, tiles.get_all()),
        low_tiles=filter(lambda x: x['score'] <= 10, tiles.get_all()),
        sponsors=sponsors.get_all_by_type(),
    )
Ejemplo n.º 3
0
def program_aktualne():
    t = times[::]
    t.insert(0, 
            {'block_from': time(18, 0), 'block_to': time(19, 0), 'date': date(2013, 6, 14),
            'data': Markup(u'<a href="/stranka/warmup/">Honza Řezáč</a>')}
    )
    t.insert(1, 
        {'block_from': time(20, 0), 'block_to': time(23, 59), 'date': date(2013, 6, 14),
            'data': Markup(u'<a href="/stranka/warmup/">Warm-up párty</a>')}
    )
    actual_date = datetime.now().date()
    actual_time = datetime.now().time()
    next_times = []
    for event in t:
        if (event['date'] == actual_date and event['block_to'] >= actual_time)\
                or event['date'] > actual_date:
            next_times.append(event)

    return render_template(
        'aktualne.html',
        menu=menu(),
        talks=get_talks_dict(),
        times=next_times,
        user=check_auth()
    )
Ejemplo n.º 4
0
def program_aktualne():
    t = times[::]
    t.insert(
        0, {
            'block_from':
            time(18, 0),
            'block_to':
            time(23, 59),
            'date':
            date(2016, 6, 3),
            'data':
            Markup(u'<a href="/' + app.config['YEAR'] +
                   u'/stranka/warm-up-social-event.html">Warm-up párty</a>')
        })
    actual_date = datetime.now().date()
    actual_time = datetime.now().time()
    next_times = []
    for event in t:
        if (event['date'] == actual_date and event['block_to'] >= actual_time)\
                or event['date'] > actual_date:
            next_times.append(event)
    return render_template(
        'aktualne.html',
        talks=get_talks_dict(),
        times=next_times,
        workshops=get_workshops_dict(),
    )
Ejemplo n.º 5
0
def rc_program():
    return render_template(
        'rc-talks.html',
        times=times,
        page_style='program',
        talks=get_talks_dict(),
    )
Ejemplo n.º 6
0
def rc_program():
    return render_template(
        'rc-talks.html',
        times=times,
        page_style='program',
        talks=get_talks_dict(),
    )
Ejemplo n.º 7
0
def program():
    return render_template(
        'program.html',
        menu=menu(),
        times=times,
        talks=get_talks_dict(),
        user=check_auth()
    )
Ejemplo n.º 8
0
def room_program():
    output = io.BytesIO()
    writer = csv.writer(output, delimiter=",", dialect="excel", quotechar='"')
    writer.writerow([
        'room',
        'room_name',
        'title',
        'name',
        'from',
        'to',
        'next_title',
        'next_name',
        'next_from',
        'next_to',
    ])
    talk_hashed = get_talks_dict()

    rooms = (
        ('d105', u'Prygl'),
        ('e112', u'Špilas'),
        ('d0206', u'Rola'),
        ('d0207', u'Šalina'),
        ('e104', u'Škopek'),
        ('e105', u'Čára'),
    )

    for room, room_name in rooms:
        talks = []
        for i, t in enumerate(times):
            if type(t['data']) is dict:
                if t['data'][room] in talk_hashed:
                    talk = talk_hashed.get(t['data'][room], None)
                else:
                    talks.append([
                        '','', 
                        t['block_from'].strftime('%H.%M'),
                        t['block_to'].strftime('%H.%M')])
                    continue
            else:
                continue

            talks.append([
                talk['title'],
                talk['user']['name'],
                t['block_from'].strftime('%H.%M'),
                t['block_to'].strftime('%H.%M')
            ])

        for i in range(len(talks)):
            if i == len(talks) - 1:
                _ = [room.upper(), room_name] + talks[i] + ['', '', '', '']
            else:
                _ = [room.upper(), room_name] + talks[i] +  talks[i+1]
            writer.writerow([unicode(s).encode("utf-8") for s in _])

    return Response(output.getvalue(), mimetype="text/plain")
Ejemplo n.º 9
0
def room_program():
    output = io.BytesIO()
    writer = csv.writer(output, delimiter=",", dialect="excel", quotechar='"')
    writer.writerow([
        'room',
        'room_name',
        'from',
        'to',
        'first_title',
        'first_name',
        'second_title',
        'second_name',
    ])
    talk_hashed = get_talks_dict()

    rooms = (
        ('d105', u'Prygl'),
        ('e112', u'Špilas'),
        ('d0206', u'Rola'),
        ('d0207', u'Šalina'),
        ('e104', u'Škopek'),
        ('e105', u'Čára'),
    )

    for room, room_name in rooms:
        talks = []
        for i, t in enumerate(times):
            row = [room.upper(), room_name, t['block_from'], t['block_to']]
            if type(t['data']) is dict:
                talk_data = t['data'][room]
                if type(talk_data) is dict:
                    # lightning talks
                    row += [
                        u'Lightning talks', u'({})'.format(
                            translate_category(talk_data['category'])), '', ''
                    ]
                if type(talk_data) is tuple:
                    # ordinary talks
                    for talk_hash in talk_data:
                        talk = talk_hashed.get(talk_hash, None)
                        if talk:
                            row += [talk['title'], talk['user']['name']]
                    if len(talk_data) < 2:
                        row += ['', '']
            else:
                continue

            writer.writerow([unicode(s).encode("utf-8") for s in row])

    return Response(output.getvalue(), mimetype="text/plain")
Ejemplo n.º 10
0
def talks_all():
    user = check_auth()
    user_hash = None

    if stage_is_active(app.config['YEAR'], 'PROGRAM'):
        talks = get_talks_dict()
    else:
        talks = get_talks_by_type()

    if user:
        user_hash = user['user_hash']

    return render_template("talks.html",
                           talks=talks,
                           times=times,
                           user_votes=get_user_votes(user_hash))
Ejemplo n.º 11
0
def service_vyvoleni(_format):
    # talks, extra_talks = get_talks()
    talk_hashed = get_talks_dict()
    talks = []
    for t in times:
        if type(t['data']) is dict:
            for room in ('d105', 'd0206', 'd0207', 'e112', 'e104', 'e105'):
                if type(t['data'][room]) is tuple:
                    for h in t['data'][room]:
                        talk = talk_hashed.get(h, None)
                        if talk:
                            talk['room'] = room
                            talks.append(talk)

    output = io.BytesIO()

    if _format == "csv":
        writer = csv.writer(output,
                            delimiter=";",
                            dialect="excel",
                            quotechar='"')

        writer.writerow([
            'video', 'name', 'email', 'web', 'company', 'twitter', 'title',
            'detail_url'
            'description', 'purpose', 'other'
        ])

        for talk in talks:
            user = talk['user']
            _ = [
                talk['video'], user['name'], user['email'], talk['web'],
                talk['company'], talk['twitter'], talk['title'],
                'http://www.barcampbrno.cz%s' %
                url_for('talk_detail', talk_hash=talk['talk_hash']),
                talk['description'].replace("\r\n", "<br/>"),
                talk['purpose'].replace("\r\n", "<br/>"),
                talk['other'].replace("\r\n", "<br/>")
            ]
            writer.writerow([unicode(s).encode("utf-8") for s in _])
    else:
        for talk in talks:
            output.write(
                ("%s: <%s>\r\n" %
                 (talk['room'], talk['user']['email'])).encode('utf-8'))

    return Response(output.getvalue(), mimetype="text/plain")
Ejemplo n.º 12
0
def service_vyvoleni():
    # talks, extra_talks = get_talks()
    talk_hashed = get_talks_dict()
    talks = []
    for t in times:
        if type(t['data']) is dict:
            for room in ('d105', 'd0206', 'd0207', 'e112', 'e104', 'e105'):
                talk = talk_hashed.get(t['data'][room], None)
                if talk:
                    talks.append(talk)

    # talks = talks[:35]
    output = io.BytesIO()
    writer = csv.writer(output, delimiter=";", dialect="excel", quotechar='"')

    writer.writerow([
        'video',
        'name',
        'email',
        'web',
        'company',
        'twitter',
        'title',
        'detail_url'
        'description',
        'purpose',
        'other'
    ])

    for talk in talks:
        user = talk['user']
        _ = [
            talk['video'],
            user['name'],
            user['email'],
            talk['web'],
            talk['company'],
            talk['twitter'],
            talk['title'], 
            'http://www.barcampbrno.cz%s' % url_for('talk_detail', talk_hash=talk['talk_hash']),
            talk['description'].replace("\r\n", "<br/>"),
            talk['purpose'].replace("\r\n", "<br/>"),
            talk['other'].replace("\r\n", "<br/>")
        ]
        writer.writerow([unicode(s).encode("utf-8") for s in _])

    return Response(output.getvalue(), mimetype="text/plain")
Ejemplo n.º 13
0
def index():
    user = check_auth()
    user_hash = None
    talks, extra_talks = get_talks()
    if user:
        user_hash = user['user_hash']
    return render_template(
        "index.html",
        user=user,
        menu=menu(),
        times=times,
        entrant_count=get_count(),
        entrants=get_entrants()[50:0:-1],
        #user_votes=get_user_votes(user_hash),
        sponsors_main=markdown_markup('sponsors_main'),
        sponsors=markdown_markup('sponsors'),
        talks=get_talks_dict())
Ejemplo n.º 14
0
def service_bad_luck():

    talk_hashed = get_talks_dict()
    for t in times:
        if type(t['data']) is dict:
            for room in ('d105', 'd0206', 'd0207', 'e112', 'e104', 'e105'):
                if type(t['data'][room]) is tuple:
                    for h in t['data'][room]:
                        if h in talk_hashed:
                            del talk_hashed[h]

    output = io.BytesIO()

    for i, talk in enumerate(talk_hashed.values()):
        user = talk['user']
        output.write(("<%s>\r\n" % (user['email'])).encode('utf-8'))

    return Response(output.getvalue(), mimetype="text/plain")
Ejemplo n.º 15
0
def program_aktualne():
    t = times[::]
    t.insert(0,
        {'block_from': time(18, 0), 'block_to': time(23, 59), 'date': date(2016, 6, 3),
            'data': Markup(u'<a href="/' + app.config['YEAR'] + u'/stranka/warm-up-social-event.html">Warm-up párty</a>')}
    )
    actual_date = datetime.now().date()
    actual_time = datetime.now().time()
    next_times = []
    for event in t:
        if (event['date'] == actual_date and event['block_to'] >= actual_time)\
                or event['date'] > actual_date:
            next_times.append(event)

    return render_template(
        'aktualne.html',
        talks=get_talks_dict(),
        times=next_times,
        workshops=get_workshops_dict(),
    )
Ejemplo n.º 16
0
def talks_all():
    user = check_auth()
    user_hash = None

    if stage_is_active(app.config['YEAR'], 'PROGRAM'):
        talks = get_talks_dict()
        extra_talks = []
    else:
        talks, extra_talks = get_talks()

    if user:
        user_hash = user['user_hash']

    return render_template(
        "talks.html",
        talks=talks,
        times=times,
        user_votes=get_user_votes(user_hash),
        extra_talks=extra_talks
    )
Ejemplo n.º 17
0
def index():
    talks, extra_talks = get_talks()
    workshops = get_workshops()

    stage_template = "index.html"
    if stage_is_active(app.config['YEAR'], 'END'):
        stage_template = "end.html"

    if stage_is_active(app.config['YEAR'], 'PREVIEW'):
        stage_template = "preview.html"

    return render_template(
        stage_template,
        times=times,
        entrant_count=get_count(),
        entrants=get_entrants()[:50],
        novinky=markdown_markup('novinky'),
        talks=talks, extra_talks=extra_talks,
        talks_dict=get_talks_dict(),
        workshops=workshops
    )
Ejemplo n.º 18
0
def service_speaker_mail():
    talk_hashed = get_talks_dict()
    talks = []
    for t in times:
        if type(t['data']) is dict:
            for room in ('d105', 'd0206', 'd0207', 'e112', 'e104', 'e105'):
                talk = talk_hashed.get(t['data'][room], None)
                if talk:
                    talks.append(talk)
    workshop_hashed = get_workshops_dict()
    workshops = []
    for t in times:
        if type(t['data']) is dict:
            for room in ('a112', 'a113', 'c228'):
                workshop = workshop_hashed.get(t['data'][room], None)
                if workshop:
                    workshops.append(workshop)

    output = io.BytesIO()
    writer = csv.writer(output, delimiter=";", dialect="excel", quotechar='"')
    for lecture in talks + workshops:
        writer.writerow([lecture['user']['email']])

    return Response(output.getvalue(), mimetype="text/plain")
Ejemplo n.º 19
0
def service_speaker_mail():
    talk_hashed = get_talks_dict()
    talks = []
    for t in times:
        if type(t['data']) is dict:
            for room in ('d105', 'd0206', 'd0207', 'e112', 'e104', 'e105'):
                talk = talk_hashed.get(t['data'][room], None)
                if talk:
                    talks.append(talk)
    workshop_hashed = get_workshops_dict()
    workshops = []
    for t in times:
        if type(t['data']) is dict:
            for room in ('a112', 'a113', 'c228'):
                workshop = workshop_hashed.get(t['data'][room], None)
                if workshop:
                    workshops.append(workshop)

    output = io.BytesIO()
    writer = csv.writer(output, delimiter=";", dialect="excel", quotechar='"')
    for lecture in talks + workshops:
        writer.writerow([lecture['user']['email']])

    return Response(output.getvalue(), mimetype="text/plain")
Ejemplo n.º 20
0
def fill_eventee_app():
    headers = app.eventee
    redis_key = KEYS['eventee']
    ids = {
        'breaks': [],
        'rooms': [],
        'talks': [],
        'speakers': [],
    }

    data = requests.get('https://eventee.co/api/public/all?date=2017-06-03',
                        headers=headers)
    data = data.json()

    for hall in data['halls'].values():
        ids['rooms'].append(hall['id'])
        if type(hall['lectures']) is dict:
            for lecture in hall['lectures'].values():
                ids['talks'].append(lecture['id'])

    for b in data['breaks'].values():
        ids['breaks'].append(b['id'])

    for lecturer in data['lecturers'].values():
        ids['speakers'].append(lecturer['id'])

    # sync rooms
    rooms = (
        ('d105', u'Prygl'),
        ('e112', u'Špilas'),
        ('d0206', u'Rola'),
        ('d0207', u'Šalina'),
        ('e104', u'Škopek'),
        ('e105', u'Čára'),
        ('a112', u'workshopy'),
        ('a113', u'workshopy'),
        ('c228', u'workshopy'),
    )

    for room, desc in rooms:
        room_key = 'room_%s' % room
        resource_id = app.redis.hget(redis_key, room_key)
        endpoint = ENDPOINT['room']
        if resource_id:
            ids['rooms'].remove(int(resource_id))
            endpoint = '{}/{}'.format(endpoint, resource_id)
        data = {'name': u'{} {}'.format(room.upper(), desc)}
        print(data['name'])
        response = requests.post(endpoint, json=data, headers=headers)
        status = response.json()
        app.redis.hset(redis_key, room_key, int(status['id']))

    for room_id in ids['rooms']:
        endpoint = "{}/{}".format(ENDPOINT['room'], room_id)
        requests.delete(endpoint, headers=headers)

    # sync breaks
    for t in times:
        if type(t['data']) is not dict:
            break_key = 'break_{}_{}'.format(t['date'], t['block_from'])
            endpoint = ENDPOINT['break']
            resource_id = app.redis.hget(redis_key, break_key)

            if resource_id:
                ids['breaks'].remove(int(resource_id))
                endpoint = "{}/{}".format(endpoint, resource_id)
            data = {
                'name':
                re.sub('<[^<]+?>', '', t['data']),
                'start':
                '{} {}'.format(t['date'].strftime('%Y-%m-%d'),
                               t['block_from']),
                'end':
                '{} {}'.format(t['date'].strftime('%Y-%m-%d'), t['block_to']),
            }

            print(data['name'])
            response = requests.post(endpoint, json=data, headers=headers)
            status = response.json()
            app.redis.hset(redis_key, break_key, int(status['id']))

    for break_id in ids['breaks']:
        endpoint = "{}/{}".format(ENDPOINT['break'], break_id)
        requests.delete(endpoint, headers=headers)

    # sync talks & speakers
    talk_rooms = ('d105', 'd0206', 'd0207', 'e112', 'e104', 'e105')
    workshop_rooms = ('a112', 'a113', 'c228')
    talks = get_talks_dict()
    workshops = get_workshops_dict()
    _shit_re = re.compile(r'[^\w .-/?!,()*\n\r]+', re.UNICODE)
    _spaces = re.compile(r'\s\s+')
    explode_speakers = ()

    def clear(s):
        s = _shit_re.sub('', s)
        s = _spaces.sub(' ', s)
        return s.strip()

    i = 0
    for t in times:
        if type(t['data']) is not dict:
            continue

        for room in talk_rooms + workshop_rooms:
            room_id = app.redis.hget(redis_key, 'room_%s' % room)
            hashes = t['data'].get(room, False)
            if not hashes:
                continue

            if type(hashes) == dict:
                # process lighning talks

                # speaker
                speaker_key = 'speaker_barcamp'
                resource_id = app.redis.hget(redis_key, speaker_key)
                speaker_ids = []
                if not resource_id:
                    print("Barcamp Brno")
                    endpoint = ENDPOINT['speaker']
                    data = {
                        'name': "Barcamp Brno",
                        'bio': '',
                    }
                    response = requests.post(endpoint,
                                             json=data,
                                             headers=headers)
                    status = response.json()
                    resource_id = int(status['id'])
                    app.redis.hset(redis_key, speaker_key, resource_id)
                speaker_ids.append(resource_id)

                #lightning talk
                talk_key = "talk_lightning_{}".format(hashes['category'])
                endpoint = ENDPOINT['talk']
                resource_id = app.redis.hget(redis_key, talk_key)

                if resource_id:
                    ids['talks'].remove(int(resource_id))
                    endpoint = "{}/{}".format(endpoint, resource_id)

                data = {
                    'name':
                    u"Lightning talky ({})".format(
                        translate_category(hashes['category'])),
                    'description':
                    "",
                    'start':
                    '{} {}'.format(t['date'].strftime('%Y-%m-%d'),
                                   t['block_from']),
                    'end':
                    '{} {}'.format(t['date'].strftime('%Y-%m-%d'),
                                   t['block_to']),
                    'speakers':
                    speaker_ids,
                    'hallId':
                    room_id,
                }

                print(data['name'])

                response = requests.post(endpoint, json=data, headers=headers)
                status = response.json()
                app.redis.hset(redis_key, talk_key, int(status['id']))

                continue

            if room not in talk_rooms:
                hashes = (hashes, )

            for i, h in enumerate(hashes):
                if room in talk_rooms:
                    lecture = talks.get(h, False)
                    hash_key = 'talk_hash'
                else:
                    lecture = workshops.get(h, False)
                    hash_key = 'workshop_hash'

                if not lecture:
                    print("missing {} {}".format(room, h))
                    continue

                speakers = [lecture['user']]

                if h in explode_speakers:
                    words = speakers[0]['name'].split(' ')
                    speaker1 = copy(speakers[0])
                    speaker1['name'] = ' '.join(words[0:2])
                    speaker1['user_hash'] += '_1'
                    speaker2 = copy(speakers[0])
                    speaker2['name'] = ' '.join(words[3:5])
                    speaker2['user_hash'] += '_2'
                    speakers = [speaker1, speaker2]

                speaker_ids = []

                for speaker in speakers:
                    speaker_key = 'speaker_{}'.format(speaker['user_hash'])
                    resource_id = app.redis.hget(redis_key, speaker_key)
                    print speaker['name']
                    if not resource_id:
                        endpoint = ENDPOINT['speaker']
                        data = {
                            'name': clear(speaker['name']),
                            'bio': '',
                        }
                        response = requests.post(endpoint,
                                                 json=data,
                                                 headers=headers)
                        status = response.json()
                        resource_id = int(status['id'])
                        app.redis.hset(redis_key, speaker_key, resource_id)
                    speaker_ids.append(resource_id)

                #talk
                talk_key = "talk_{}".format(lecture[hash_key])
                endpoint = ENDPOINT['talk']
                resource_id = app.redis.hget(redis_key, talk_key)

                if resource_id:
                    ids['talks'].remove(int(resource_id))
                    endpoint = "{}/{}".format(endpoint, resource_id)

                data = {
                    'name':
                    clear(lecture['title']),
                    'description':
                    clear(lecture['description']),
                    'start':
                    '{} {}'.format(t['date'].strftime('%Y-%m-%d'),
                                   t['block_from']),
                    'end':
                    '{} {}'.format(t['date'].strftime('%Y-%m-%d'),
                                   t['block_to']),
                    'speakers':
                    speaker_ids,
                    'hallId':
                    room_id,
                }

                print(data['name'])

                if room in workshop_rooms:
                    minutes = 45 if lecture['minutes'] <= 60 else 105
                    end = datetime.combine(
                        t['date'],
                        t['block_from']) + timedelta(minutes=minutes)
                    data['end'] = str(end)

                if len(hashes) > 1 and i == 0:
                    data['end'] = str(
                        datetime.combine(t['date'], t['block_to']) -
                        timedelta(minutes=22))
                if len(hashes) > 1 and i == 1:
                    data['start'] = str(
                        datetime.combine(t['date'], t['block_from']) +
                        timedelta(minutes=22))

                response = requests.post(endpoint, json=data, headers=headers)
                status = response.json()
                app.redis.hset(redis_key, talk_key, int(status['id']))

    for talk_id in ids['talks']:
        endpoint = "{}/{}".format(ENDPOINT['talk'], talk_id)
        requests.delete(endpoint, headers=headers)

    return Response("ok", mimetype="text/plain")
Ejemplo n.º 21
0
def fill_eventee_app():
    headers = app.eventee
    redis_key = KEYS['eventee']
    ids = {
        'breaks': [],
        'rooms': [],
        'talks': [],
        'speakers': [],
    }

    data = requests.get('https://eventee.co/api/public/all?date=2016-06-04', headers=headers)
    data = data.json()

    for hall in data['halls'].values():
        ids['rooms'].append(hall['id'])
        if type(hall['lectures']) is dict:
            for lecture in hall['lectures'].values():
                ids['talks'].append(lecture['id'])

    for b in data['breaks'].values():
        ids['breaks'].append(b['id'])

    for lecturer in data['lecturers'].values():
        ids['speakers'].append(lecturer['id'])

    # sync rooms
    rooms = (
        ('d105', u'Prygl'),
        ('e112', u'Špilas'),
        ('d0206', u'Rola'),
        ('d0207', u'Šalina'),
        ('e104', u'Škopek'),
        ('e105', u'Čára'),
        ('a112', u'workshopy'),
        ('a113', u'workshopy'),
        ('c228', u'workshopy'),
        ('Hyde', 'Park'),
    )

    for room, desc in rooms:
        room_key = 'room_%s' % room
        resource_id = app.redis.hget(redis_key, room_key)
        endpoint = ENDPOINT['room']
        if resource_id:
            ids['rooms'].remove(int(resource_id))
            endpoint = '{}/{}'.format(endpoint, resource_id)
        data = {
            'name': u'{} {}'.format(room.upper(), desc)
        }
        response = requests.post(
            endpoint,
            json=data,
            headers=headers
        )
        status = response.json()
        app.redis.hset(redis_key, room_key, int(status['id']))

    for room_id in ids['rooms']:
        endpoint = "{}/{}".format(ENDPOINT['room'], room_id)
        requests.delete(endpoint, headers=headers)

    # sync breaks
    for t in times:
        if type(t['data']) is not dict:
            break_key = 'break_{}_{}'.format(t['date'], t['block_from'])
            endpoint = ENDPOINT['break']
            resource_id = app.redis.hget(redis_key, break_key)

            if resource_id:
                ids['breaks'].remove(int(resource_id))
                endpoint = "{}/{}".format(endpoint, resource_id)
            data = {
                'name': re.sub('<[^<]+?>', '', t['data']),
                'start': '{} {}'.format(t['date'].strftime('%Y-%m-%d'), t['block_from']),
                'end': '{} {}'.format(t['date'].strftime('%Y-%m-%d'), t['block_to']),
            }
            response = requests.post(
                endpoint,
                json=data,
                headers=headers
            )
            status = response.json()
            app.redis.hset(redis_key, break_key, int(status['id']))

    for break_id in ids['breaks']:
        endpoint = "{}/{}".format(ENDPOINT['break'], break_id)
        requests.delete(endpoint, headers=headers)


    # sync talks & speakers
    talk_rooms = ('d105', 'd0206', 'd0207', 'e112', 'e104', 'e105')
    workshop_rooms = ('a112', 'a113', 'c228')
    talks = get_talks_dict()
    workshops = get_workshops_dict()
    _shit_re = re.compile(r'[^\w .-/?!,()*\n\r]+', re.UNICODE)
    _spaces = re.compile(r'\s\s+')
    explode_speakers = ('bea84558', 'f89ae7e6')
    def clear(s):
        s = _shit_re.sub('', s)
        s = _spaces.sub(' ', s)
        return s.strip()

    i = 0
    for t in times:
        if type(t['data']) is not dict:
            continue

        for room in talk_rooms + workshop_rooms:
            room_id = app.redis.hget(redis_key, 'room_%s' % room)
            h = t['data'].get(room, False)
            if not h:
                continue

            if room in talk_rooms:
                lecture = talks.get(h, False)
                hash_key = 'talk_hash'
            else:
                lecture = workshops.get(h, False)
                hash_key = 'workshop_hash'

            if not lecture:
                continue

            speakers = [lecture['user']]

            if h in explode_speakers:
                words = speakers[0]['name'].split(' ')
                speaker1 = copy(speakers[0])
                speaker1['name'] = ' '.join(words[0:2])
                speaker1['user_hash'] += '_1'
                speaker2 = copy(speakers[0])
                speaker2['name'] = ' '.join(words[3:5])
                speaker2['user_hash'] += '_2'
                speakers = [speaker1, speaker2]

            speaker_ids = []

            for speaker in speakers:
                speaker_key = 'speaker_{}'.format(speaker['user_hash'])
                resource_id = app.redis.hget(redis_key, speaker_key)
                print speaker['name']
                if not resource_id:
                    endpoint = ENDPOINT['speaker']
                    data = {
                        'name': clear(speaker['name']),
                        'bio': '',
                    }
                    response = requests.post(
                        endpoint,
                        json=data,
                        headers=headers
                    )
                    status = response.json()
                    resource_id = int(status['id'])
                    app.redis.hset(redis_key, speaker_key, resource_id)
                speaker_ids.append(resource_id)

            #talk
            talk_key = "talk_{}".format(lecture[hash_key])
            endpoint = ENDPOINT['talk']
            resource_id = app.redis.hget(redis_key, talk_key)

            if resource_id:
                ids['talks'].remove(int(resource_id))
                endpoint = "{}/{}".format(endpoint, resource_id)

            data = {
                'name': clear(lecture['title']),
                'description': clear(lecture['description']),
                'start': '{} {}'.format(t['date'].strftime('%Y-%m-%d'), t['block_from']),
                'end': '{} {}'.format(t['date'].strftime('%Y-%m-%d'), t['block_to']),
                'speakers': speaker_ids,
                'hallId': room_id,
            }

            if room in workshop_rooms:
                minutes = 45 if lecture['minutes'] <= 60 else 105
                end = datetime.combine(t['date'], t['block_from']) + timedelta(minutes=minutes)
                data['end'] = str(end)

            response = requests.post(
                endpoint,
                json=data,
                headers=headers
            )
            status = response.json()
            app.redis.hset(redis_key, talk_key, int(status['id']))

    for talk_id in ids['talks']:
        endpoint = "{}/{}".format(ENDPOINT['talk'], talk_id)
        requests.delete(endpoint, headers=headers)

    return Response("ok", mimetype="text/plain")