Exemplo n.º 1
0
def render_archive(context, conference):
    ctx = Context(context)

    def match(e,
              exclude_tags=set(
                  ('partner0', 'partner1', 'sprint1', 'sprint2', 'sprint3'))):
        if e['tags'] & exclude_tags:
            return False
        if not e['talk']:
            return False
        return True

    events = {
        x['id']: x
        for x in filter(match, cdataaccess.events(conf=conference))
    }
    talks = {}
    for e in events.values():
        t = e['talk']
        if t['id'] in talks:
            continue
        t['dates'] = sorted([(events[x]['time'],
                              events[x]['talk']['video_url'])
                             for x in t['events_id']])
        talks[t['id']] = t

    ctx.update({
        'conference': conference,
        'talks': sorted(talks.values(), key=lambda x: x['title']),
    })
    return ctx
Exemplo n.º 2
0
def covers(request, conference):
    events = settings.VIDEO_COVER_EVENTS(conference)
    if not events:
        raise http.Http404()

    schedules = dataaccess.schedules_data(
        models.Schedule.objects.filter(conference=conference).order_by("date").values_list("id", flat=True)
    )

    from collections import defaultdict

    tracks = defaultdict(dict)
    for s in schedules:
        for t in s["tracks"].values():
            tracks[s["id"]][t.track] = t.title

    grouped = defaultdict(lambda: defaultdict(list))
    for e in dataaccess.events(eids=events):
        if not e["tracks"]:
            continue
        sid = e["schedule_id"]
        t = tracks[sid][e["tracks"][0]]
        grouped[sid][t].append(e)

    ordered = []
    for s in schedules:
        data = grouped[s["id"]]
        if not data:
            continue
        ordered.append((s, sorted(data.items())))
    ctx = {"conference": conference, "events": ordered}
    return render(request, "conference/covers.html", ctx)
Exemplo n.º 3
0
def CONFERENCE_VIDEO_COVER_EVENTS(conference):
    from conference import dataaccess

    def valid(e):
        if e['tags'] & set(['special', 'break']):
            return False
        # evening events are not recorded
        if e['time'].hour >= 20:
            return False
        return True

    return [x['id'] for x in filter(valid, dataaccess.events(conf=conference))]
Exemplo n.º 4
0
def CONFERENCE_VIDEO_COVER_EVENTS(conference):
    from conference import dataaccess

    def valid(e):
        if e['tags'] & set(['special', 'break']):
            return False
        # evening events are not recorded
        if e['time'].hour >= 20:
            return False
        return True

    return [x['id'] for x in filter(valid, dataaccess.events(conf=conference))]
Exemplo n.º 5
0
    def fromEvents(cls, sid, eids):
        from conference import dataaccess
        qs = Event.objects\
            .filter(schedule=sid, id__in=eids)\
            .values_list('id', flat=True)
        events = dataaccess.events(eids=qs)
        events.sort(key=lambda x: x['time'])
        tracks = defaultdict(list)
        for e in events:
            for t in e['tracks']:
                tracks[t].append(e)

        return cls(sid, dict(tracks))
Exemplo n.º 6
0
    def fromEvents(cls, sid, eids):
        from conference import dataaccess
        qs = Event.objects\
            .filter(schedule=sid, id__in=eids)\
            .values_list('id', flat=True)
        events = dataaccess.events(eids=qs)
        events.sort(key=lambda x: x['time'])
        tracks = defaultdict(list)
        for e in events:
            for t in e['tracks']:
                tracks[t].append(e)

        return cls(sid, dict(tracks))
Exemplo n.º 7
0
def CONFERENCE_VIDEO_COVER_EVENTS(conference):
    from conference import dataaccess
    from conference import models
    from datetime import timedelta
    conf = models.Conference.objects.get(code=conference)
    def valid(e):
        if e['tags'] & set(['special', 'break']):
            return False
        # gli ultimi due giorni si tengono gli sprint
        if e['time'].date() >= conf.conference_end - timedelta(days=1):
            return False
        # gli eventi serali non vengono ripresi
        if e['time'].hour >= 20:
            return False
        if len(e['tracks']) == 1 and (e['tracks'][0] in ('helpdesk1', 'helpdesk2')):
            return False
        return True
    return [ x['id'] for x in filter(valid, dataaccess.events(conf=conference)) ]
Exemplo n.º 8
0
def CONFERENCE_VIDEO_COVER_EVENTS(conference):
    from conference import dataaccess
    from conference import models
    from datetime import timedelta
    conf = models.Conference.objects.get(code=conference)

    def valid(e):
        if e['tags'] & set(['special', 'break']):
            return False
        # gli ultimi due giorni si tengono gli sprint
        if e['time'].date() >= conf.conference_end - timedelta(days=1):
            return False
        # gli eventi serali non vengono ripresi
        if e['time'].hour >= 20:
            return False
        if len(e['tracks']) == 1 and (e['tracks'][0]
                                      in ('helpdesk1', 'helpdesk2')):
            return False
        return True

    return [x['id'] for x in filter(valid, dataaccess.events(conf=conference))]
Exemplo n.º 9
0
def CONFERENCE_VIDEO_COVER_EVENTS(conference):
    from conference import dataaccess
    from conference import models
    from datetime import timedelta

    conf = models.Conference.objects.get(code=conference)

    def valid(e):
        if e['tags'] & set(['special', 'break']):
            return False
        # sprints are in the last two days
        if e['time'].date() >= conf.conference_end - timedelta(days=1):
            return False
        # evening events are not recorded
        if e['time'].hour >= 20:
            return False
        if len(e['tracks']) == 1 and (e['tracks'][0]
                                      in ('helpdesk1', 'helpdesk2')):
            return False
        return True

    return [x['id'] for x in filter(valid, dataaccess.events(conf=conference))]
Exemplo n.º 10
0
def render_archive(context, conference):
    ctx = Context(context)

    def match(e, exclude_tags=set(('partner0', 'partner1', 'sprint1', 'sprint2', 'sprint3'))):
        if e['tags'] & exclude_tags:
            return False
        if not e['talk']:
            return False
        return True
    events = { x['id']:x for x in filter(match, cdataaccess.events(conf=conference)) }
    talks = {}
    for e in events.values():
        t = e['talk']
        if t['id'] in talks:
            continue
        t['dates'] = sorted([ (events[x]['time'], events[x]['talk']['video_url']) for x in t['events_id'] ])
        talks[t['id']] = t

    ctx.update({
        'conference': conference,
        'talks': sorted(talks.values(), key=lambda x: x['title']),
    })
    return ctx
Exemplo n.º 11
0
def covers(request, conference):
    events = settings.VIDEO_COVER_EVENTS(conference)
    if not events:
        raise http.Http404()

    schedules = dataaccess.schedules_data(
        models.Schedule.objects\
            .filter(conference=conference)\
            .order_by('date')\
            .values_list('id', flat=True)
    )

    from collections import defaultdict
    tracks = defaultdict(dict)
    for s in schedules:
        for t in s['tracks'].values():
            tracks[s['id']][t.track] = t.title

    grouped = defaultdict(lambda: defaultdict(list))
    for e in dataaccess.events(eids=events):
        if not e['tracks']:
            continue
        sid = e['schedule_id']
        t = tracks[sid][e['tracks'][0]]
        grouped[sid][t].append(e)

    ordered = []
    for s in schedules:
        data = grouped[s['id']]
        if not data:
            continue
        ordered.append((s, sorted(data.items())))
    ctx = {
        'conference': conference,
        'events': ordered,
    }
    return render(request, 'conference/covers.html', ctx)
Exemplo n.º 12
0
def covers(request, conference):
    events = settings.VIDEO_COVER_EVENTS(conference)
    if not events:
        raise http.Http404()

    schedules = dataaccess.schedules_data(
        models.Schedule.objects\
            .filter(conference=conference)\
            .order_by('date')\
            .values_list('id', flat=True)
    )

    from collections import defaultdict
    tracks = defaultdict(dict)
    for s in schedules:
        for t in s['tracks'].values():
            tracks[s['id']][t.track] = t.title

    grouped = defaultdict(lambda: defaultdict(list))
    for e in dataaccess.events(eids=events):
        if not e['tracks']:
            continue
        sid = e['schedule_id']
        t = tracks[sid][e['tracks'][0]]
        grouped[sid][t].append(e)

    ordered = []
    for s in schedules:
        data = grouped[s['id']]
        if not data:
            continue
        ordered.append((s, sorted(data.items())))
    ctx = {
        'conference': conference,
        'events': ordered,
    }
    return render(request, 'conference/covers.html', ctx)
Exemplo n.º 13
0
def _VIDEO_COVER_EVENTS(conference):
    from conference import dataaccess
    return [ x['id'] for x in dataaccess.events(conf=conference) ]
Exemplo n.º 14
0
def conference_speakers_day(conf, code=None):
    from p3 import dataaccess
    from conference.dataaccess import talks_data
    from conference.dataaccess import events

    schedules = cmodels.Schedule.objects.filter(conference=conf)
    data = {}
    for s in schedules:
        people = dataaccess.profiles_data(s.speakers()\
            .order_by('user__first_name', 'user__last_name')\
            .values_list('user', flat=True))
        people_data = []
        for p in people:
            o = {
                'uid': p['id'],
                'email': p['email'],
                'name': p['name'],
                'phones': [p['phone']],
                'talks': p['talks']['accepted'].get(conf, []),
            }
            people_data.append(o)
        data[s.date.strftime('%Y-%m-%d')] = people_data
    if code is None:
        output = []
        for date, peoples in sorted(data.items()):
            output.append({
                'id': 'd%s' % date,
                'title': date,
                'total': len(peoples),
            })
        return output
    else:
        people_data = data[code[1:]]
        conf_events = dict([(x['id'], x) for x in events(conf='ep2013')])
        tracks = defaultdict(list)
        for p in people_data:
            tickets = [
                tid for tid, _, fare, complete in dataaccess.all_user_tickets(p['uid'], conf)
                if complete and fare.startswith('SIM') ]
            if tickets:
                p['phones'].extend(
                    models.TicketSIM.objects\
                        .filter(ticket__in=tickets)\
                        .values_list('number', flat=True))
            p['phones'] = filter(None, p['phones'])
            for talk in talks_data(p['talks']):
                for event_id in talk['events_id']:
                    if conf_events[event_id]['time'].date().strftime('%Y-%m-%d') == code[1:]:
                        for track in conf_events[event_id]['tracks']:
                            if p not in tracks[track]:
                                tracks[track].append(p)
        output = {
            'columns': (
                ('name', 'Name'),
                ('email', 'Email'),
                ('phones', 'Phones'),
                ('track', 'Track'),
            ),
            'data': [],
        }
        data = output['data']
        for track, people in sorted(tracks.items()):
            for x in people:
                data.append({
                    'name': '<a href="%s">%s</a>' % (
                        reverse('admin:auth_user_change', args=(x['uid'],)),
                        x['name']),
                    'email': x['email'],
                    'uid': x['uid'],
                    'phones': ', '.join(x['phones']),
                    'track': track,
                })
        return output
Exemplo n.º 15
0
def _VIDEO_COVER_EVENTS(conference):
    from conference import dataaccess
    return [x['id'] for x in dataaccess.events(conf=conference)]
Exemplo n.º 16
0
def conference_speakers_day(conf, code=None):
    from p3 import dataaccess
    from conference.dataaccess import talks_data
    from conference.dataaccess import events

    schedules = cmodels.Schedule.objects.filter(conference=conf)
    data = {}
    for s in schedules:
        people = dataaccess.profiles_data(s.speakers()\
            .order_by('user__first_name', 'user__last_name')\
            .values_list('user', flat=True))
        people_data = []
        for p in people:
            o = {
                'uid': p['id'],
                'email': p['email'],
                'name': p['name'],
                'phones': [p['phone']],
                'talks': p['talks']['accepted'].get(conf, []),
            }
            people_data.append(o)
        data[s.date.strftime('%Y-%m-%d')] = people_data
    if code is None:
        output = []
        for date, peoples in sorted(data.items()):
            output.append({
                'id': 'd%s' % date,
                'title': date,
                'total': len(peoples),
            })
        return output
    else:
        people_data = data[code[1:]]
        conf_events = dict([(x['id'], x) for x in events(conf=conf)])
        tracks = defaultdict(list)
        for p in people_data:
            tickets = [
                tid for tid, _, fare, complete in dataaccess.all_user_tickets(
                    p['uid'], conf) if complete and fare.startswith('SIM')
            ]
            if tickets:
                p['phones'].extend(
                    models.TicketSIM.objects\
                        .filter(ticket__in=tickets)\
                        .values_list('number', flat=True))
            p['phones'] = filter(None, p['phones'])
            for talk in talks_data(p['talks']):
                for event_id in talk['events_id']:
                    if conf_events[event_id]['time'].date().strftime(
                            '%Y-%m-%d') == code[1:]:
                        for track in conf_events[event_id]['tracks']:
                            if p not in tracks[track]:
                                tracks[track].append(p)
        output = {
            'columns': (
                ('name', 'Name'),
                ('email', 'Email'),
                ('phones', 'Phones'),
                ('track', 'Track'),
            ),
            'data': [],
        }
        data = output['data']
        for track, people in sorted(tracks.items()):
            for x in people:
                data.append({
                    'name':
                    '<a href="%s">%s</a>' %
                    (reverse('admin:auth_user_change',
                             args=(x['uid'], )), x['name']),
                    'email':
                    x['email'],
                    'uid':
                    x['uid'],
                    'phones':
                    ', '.join(x['phones']),
                    'track':
                    track,
                })
        return output
Exemplo n.º 17
0
def conference_speakers_day(conf, code=None):
    from p3 import dataaccess
    from conference.dataaccess import talks_data
    from conference.dataaccess import events

    schedules = cmodels.Schedule.objects.filter(conference=conf)
    data = {}
    for s in schedules:
        people = dataaccess.profiles_data(
            s.speakers().order_by("user__first_name", "user__last_name").values_list("user", flat=True)
        )
        people_data = []
        for p in people:
            o = {
                "uid": p["id"],
                "email": p["email"],
                "name": p["name"],
                "phones": [p["phone"]],
                "talks": p["talks"]["accepted"].get(conf, []),
            }
            people_data.append(o)
        data[s.date.strftime("%Y-%m-%d")] = people_data
    if code is None:
        output = []
        for date, peoples in sorted(data.items()):
            output.append({"id": "d%s" % date, "title": date, "total": len(peoples)})
        return output
    else:
        people_data = data[code[1:]]
        conf_events = dict([(x["id"], x) for x in events(conf=conf)])
        tracks = defaultdict(list)
        for p in people_data:
            tickets = [
                tid
                for tid, _, fare, complete in dataaccess.all_user_tickets(p["uid"], conf)
                if complete and fare.startswith("SIM")
            ]
            if tickets:
                p["phones"].extend(models.TicketSIM.objects.filter(ticket__in=tickets).values_list("number", flat=True))
            p["phones"] = filter(None, p["phones"])
            for talk in talks_data(p["talks"]):
                for event_id in talk["events_id"]:
                    if conf_events[event_id]["time"].date().strftime("%Y-%m-%d") == code[1:]:
                        for track in conf_events[event_id]["tracks"]:
                            if p not in tracks[track]:
                                tracks[track].append(p)
        output = {
            "columns": (("name", "Name"), ("email", "Email"), ("phones", "Phones"), ("track", "Track")),
            "data": [],
        }
        data = output["data"]
        for track, people in sorted(tracks.items()):
            for x in people:
                data.append(
                    {
                        "name": '<a href="%s">%s</a>'
                        % (reverse("admin:auth_user_change", args=(x["uid"],)), x["name"]),
                        "email": x["email"],
                        "uid": x["uid"],
                        "phones": ", ".join(x["phones"]),
                        "track": track,
                    }
                )
        return output