def schedule_current(): def add_event(event): event["text"] = html.escape(event["title"]) event["description"] = urlize(event["description"]) event["start_date"] = event["start_date"].strftime("%Y-%m-%d %H:%M:00") event["end_date"] = event["end_date"].strftime("%Y-%m-%d %H:%M:00") event["venue"] = slugify(event["venue"]) return event # {id:1, text:"Meeting", start_date:"04/11/2013 14:00",end_date:"04/11/2013 17:00"} schedule_data = _get_scheduled_proposals() venues_with_events = set([e["venue"] for e in schedule_data]) venues = _get_priority_sorted_venues(venues_with_events) schedule_data = [add_event(e) for e in schedule_data] token = None if current_user.is_authenticated: token = generate_api_token(app.config["SECRET_KEY"], current_user.id) return render_template( "schedule/user_schedule.html", venues=venues, schedule_data=schedule_data, token=token, )
def favourites(): if current_user.is_anonymous: return redirect(url_for('users.login', next=url_for('.favourites'))) proposals = current_user.favourites externals = current_user.calendar_favourites token = generate_api_token(app.config['SECRET_KEY'], current_user.id) return render_template('schedule/favourites.html', proposals=proposals, externals=externals, token=token)
def schedule_current(): token = None if current_user.is_authenticated: token = generate_api_token(app.config["SECRET_KEY"], current_user.id) return render_template( "schedule/user_schedule.html", token=token, debug=app.config.get("DEBUG"), year=event_year(), )
def favourites(): if (request.method == "POST") and current_user.is_authenticated: event_id = int(request.form["fave"]) event_type = request.form["event_type"] if event_type == "proposal": proposal = Proposal.query.get_or_404(event_id) if proposal in current_user.favourites: current_user.favourites.remove(proposal) else: current_user.favourites.append(proposal) db.session.commit() return redirect( url_for(".favourites") + "#proposal-{}".format(proposal.id)) else: event = CalendarEvent.query.get_or_404(event_id) if event in current_user.calendar_favourites: current_user.calendar_favourites.remove(event) else: current_user.calendar_favourites.append(event) db.session.commit() return redirect( url_for(".favourites") + "#event-{}".format(event.id)) if current_user.is_anonymous: return redirect(url_for("users.login", next=url_for(".favourites"))) proposals = current_user.favourites externals = current_user.calendar_favourites token = generate_api_token(app.config["SECRET_KEY"], current_user.id) return render_template( "schedule/favourites.html", proposals=proposals, externals=externals, token=token, )
def favourites(): if (request.method == 'POST') and current_user.is_authenticated: event_id = int(request.form['fave']) event_type = request.form['event_type'] if event_type == 'proposal': proposal = Proposal.query.get_or_404(event_id) if proposal in current_user.favourites: current_user.favourites.remove(proposal) else: current_user.favourites.append(proposal) db.session.commit() return redirect( url_for('.favourites') + '#proposal-{}'.format(proposal.id)) else: event = CalendarEvent.query.get_or_404(event_id) if event in current_user.calendar_favourites: current_user.calendar_favourites.remove(event) else: current_user.calendar_favourites.append(event) db.session.commit() return redirect( url_for('.favourites') + '#event-{}'.format(event.id)) if current_user.is_anonymous: return redirect(url_for('users.login', next=url_for('.favourites'))) proposals = current_user.favourites externals = current_user.calendar_favourites token = generate_api_token(app.config['SECRET_KEY'], current_user.id) return render_template('schedule/favourites.html', proposals=proposals, externals=externals, token=token)
def test_api_token(): expected = "1-LEvbdun5bP1yuOK9L_8K" result = generate_api_token("abc", 1) assert expected == result
def test_api_token(): expected = '1-LEvbdun5bP1yuOK9L_8K' result = generate_api_token('abc', 1) assert expected == result