def p3_profile(request, slug, profile=None, full_access=False, format_="html"): if format_ == "json": pdata = dataaccess.profile_data(profile.user_id) from conference.templatetags.conference import markdown2 pdata["bio"] = markdown2(pdata["bio"], "smarty-pants,code-color") return http.HttpResponse(json_dumps(pdata), content_type="text/javascript") tpl = "conference/profile_publicdata_form.html" if request.method == "POST": section = request.POST.get("section") if section == "public-data": fc = p3forms.P3ProfilePublicDataForm tpl = "conference/profile_publicdata_form.html" elif section == "bio": fc = p3forms.P3ProfileBioForm tpl = "conference/profile_bio_form.html" elif section == "visibility": fc = p3forms.P3ProfileVisibilityForm tpl = "conference/profile_visibility_form.html" elif section == "picture": fc = p3forms.P3ProfilePictureForm tpl = "conference/profile_picture_form.html" else: fc = p3forms.P3ProfileForm form = fc(instance=profile, data=request.POST, files=request.FILES) if form.is_valid(): form.save() else: form = p3forms.P3ProfileForm(instance=profile) ctx = {"form": form, "full_access": full_access, "profile": profile} return render(request, tpl, ctx)
def p3_profile(request, slug, profile=None, full_access=False, format_='html'): if format_ == 'json': pdata = dataaccess.profile_data(profile.user_id) from conference.templatetags.conference import markdown2 pdata['bio'] = markdown2(pdata['bio'], "smarty-pants,code-color") return http.HttpResponse(json_dumps(pdata), content_type='text/javascript') tpl = 'conference/profile_publicdata_form.html' if request.method == 'POST': section = request.POST.get('section') if section == 'public-data': fc = p3forms.P3ProfilePublicDataForm tpl = 'conference/profile_publicdata_form.html' elif section == 'bio': fc = p3forms.P3ProfileBioForm tpl = 'conference/profile_bio_form.html' elif section == 'visibility': fc = p3forms.P3ProfileVisibilityForm tpl = 'conference/profile_visibility_form.html' elif section == 'picture': fc = p3forms.P3ProfilePictureForm tpl = 'conference/profile_picture_form.html' else: fc = p3forms.P3ProfileForm form = fc(instance=profile, data=request.POST, files=request.FILES) if form.is_valid(): form.save() else: form = p3forms.P3ProfileForm(instance=profile) ctx = { 'form': form, 'full_access': full_access, 'profile': profile, } return render(request, tpl, ctx)
def render_profile_box(context, profile, conference=None, user_message="auto"): if conference is None: conference = settings.CONFERENCE_CONFERENCE if isinstance(profile, int): profile = dataaccess.profile_data(profile) ctx = Context(context) ctx.update({ 'profile': profile, 'conference': conference, 'user_message': user_message if user_message in ('auto', 'always', 'none') else 'auto', }) return render_to_string('p3/fragments/render_profile_box.html', ctx)
def p3_profile(request, slug, profile=None, full_access=False, format_='html'): if format_ == 'json': pdata = dataaccess.profile_data(profile.user_id) from conference.templatetags.conference import markdown2 pdata['bio'] = markdown2(pdata['bio'], "smarty-pants,code-color") return http.HttpResponse( json_dumps(pdata), content_type='text/javascript') tpl = 'conference/profile_publicdata_form.html' if request.method == 'POST': section = request.POST.get('section') if section == 'public-data': fc = p3forms.P3ProfilePublicDataForm tpl = 'conference/profile_publicdata_form.html' elif section == 'bio': fc = p3forms.P3ProfileBioForm tpl = 'conference/profile_bio_form.html' elif section == 'visibility': fc = p3forms.P3ProfileVisibilityForm tpl = 'conference/profile_visibility_form.html' elif section == 'picture': fc = p3forms.P3ProfilePictureForm tpl = 'conference/profile_picture_form.html' else: fc = p3forms.P3ProfileForm form = fc(instance=profile, data=request.POST, files=request.FILES) if form.is_valid(): form.save() else: form = p3forms.P3ProfileForm(instance=profile) ctx = { 'form': form, 'full_access': full_access, 'profile': profile, } return render(request, tpl, ctx)
def live_events(request): conf, date = _live_conference() sid = cmodels.Schedule.objects\ .values('id')\ .get(conference=conf.code, date=date) tt = TimeTable2.fromSchedule(sid['id']) tt.removeEventsByTag('special') t0 = datetime.datetime.now().time() tracks = settings.P3_LIVE_TRACKS.keys() events = {} for track, tevts in tt.iterOnTracks(start=('current', t0)): curr = None try: curr = dict(tevts[0]) curr['next'] = dict(tevts[1]) except IndexError: pass # I've deleted all special events, t0 could be on one of them if curr and (curr['time'] + datetime.timedelta( seconds=curr['duration'] * 60)).time() < t0: curr = None if track not in tracks: continue events[track] = curr def event_url(event): if event.get('talk'): return reverse('conference-talk', kwargs={'slug': event['talk']['slug']}) else: return None output = {} for track, event in events.items(): if event is None: output[track] = { 'id': None, 'embed': settings.P3_LIVE_EMBED(request, track=track), } continue url = event_url(event) if event.get('talk'): speakers = [(reverse('conference-speaker', kwargs={'slug': s['slug']}), s['name'], dataaccess.profile_data(s['id'])['image']) for s in event['talk']['speakers']] else: speakers = None if event.get('next'): next = { 'name': event['next']['name'], 'url': event_url(event['next']), 'time': event['next']['time'], } else: next = None output[track] = { 'id': event['id'], 'name': event['name'], 'url': url, 'speakers': speakers, 'start': event['time'], 'end': event['time'] + datetime.timedelta(seconds=event['duration'] * 60), 'tags': event['talk']['tags'] if event.get('talk') else [], 'embed': settings.P3_LIVE_EMBED(request, event=event), 'next': next, } return output
def p3_profile_data(uid): return dataaccess.profile_data(uid)
def live_events(request): conf, date = _live_conference() sid = cmodels.Schedule.objects\ .values('id')\ .get(conference=conf.code, date=date) tt = TimeTable2.fromSchedule(sid['id']) tt.removeEventsByTag('special') t0 = datetime.datetime.now().time() tracks = settings.P3_LIVE_TRACKS.keys() events = {} for track, tevts in tt.iterOnTracks(start=('current', t0)): curr = None try: curr = dict(tevts[0]) curr['next'] = dict(tevts[1]) except IndexError: pass # Ho eliminato gli eventi special, t0 potrebbe cadere su uno di questi if curr and (curr['time'] + datetime.timedelta(seconds=curr['duration']*60)).time() < t0: curr = None if track not in tracks: continue events[track] = curr def event_url(event): if event.get('talk'): return reverse('conference-talk', kwargs={'slug': event['talk']['slug']}) else: return None output = {} for track, event in events.items(): if event is None: output[track] = { 'id': None, 'embed': settings.P3_LIVE_EMBED(request, track=track), } continue url = event_url(event) if event.get('talk'): speakers = [ ( reverse('conference-speaker', kwargs={'slug': s['slug']}), s['name'], dataaccess.profile_data(s['id'])['image'] ) for s in event['talk']['speakers'] ] else: speakers = None if event.get('next'): next = { 'name': event['next']['name'], 'url': event_url(event['next']), 'time': event['next']['time'], } else: next = None output[track] = { 'id': event['id'], 'name': event['name'], 'url': url, 'speakers': speakers, 'start': event['time'], 'end': event['time'] + datetime.timedelta(seconds=event['duration'] * 60), 'tags': event['talk']['tags'] if event.get('talk') else [], 'embed': settings.P3_LIVE_EMBED(request, event=event), 'next': next, } return output