def election_results(election_alias): election = get_valid_election(election_alias, ended=True) if not isinstance(election, models.Election): # pragma: no cover return election elif election.embargoed: if is_authenticated() and ( is_admin(flask.g.fas_user) or is_election_admin(flask.g.fas_user, election.id)): flask.flash("You are only seeing this page because you are " "an admin.", "warning") flask.flash("The results for this election are currently " "embargoed pending formal announcement.", "warning") else: flask.flash("We are sorry. The results for this election " "cannot be viewed because they are currently " "embargoed pending formal announcement.") return safe_redirect_back() if is_authenticated() and ( is_admin(flask.g.fas_user) or is_election_admin(flask.g.fas_user, election.id)): flask.flash( "Check out the <a href='%s'>Text version</a> " "to send the annoucement" % flask.url_for( 'election_results_text', election_alias=election.alias) ) usernamemap = build_name_map(election) stats = models.Vote.get_election_stats(SESSION, election.id) cnt = 1 evolution_label = [] evolution_data = [] for delta in range((election.end_date - election.start_date).days + 1): day = ( election.start_date + timedelta(days=delta) ).strftime('%d-%m-%Y') evolution_label.append([cnt, day]) evolution_data.append([cnt, stats['vote_timestamps'].count(day)]) cnt += 1 return flask.render_template( 'results.html', election=election, usernamemap=usernamemap, stats=stats, evolution_label=evolution_label, evolution_data=evolution_data, )
def decorated_function(*args, **kwargs): if not is_authenticated(): return flask.redirect(flask.url_for( 'auth_login', next=flask.request.url)) if not is_admin(flask.g.fas_user): flask.abort(403) return f(*args, **kwargs)
def decorated_function(*args, **kwargs): if not is_authenticated(): return flask.redirect( flask.url_for('auth_login', next=flask.request.url)) if not is_admin(flask.g.fas_user): flask.abort(403) return f(*args, **kwargs)
def decorated_function(*args, **kwargs): if not is_authenticated(): return flask.redirect( flask.url_for('auth_login', next=flask.request.url)) elif not flask.g.fas_user.cla_done: flask.flash('You must sign the CLA to vote', 'error') return safe_redirect_back() elif len(flask.g.fas_user.groups) == 0: flask.flash('You need to be in one another group than CLA to vote', 'error') return safe_redirect_back() return f(*args, **kwargs)
def decorated_function(*args, **kwargs): if not is_authenticated(): return flask.redirect(flask.url_for( 'auth_login', next=flask.request.url)) elif not flask.g.fas_user.cla_done: flask.flash( 'You must sign the CLA to vote', 'error') return safe_redirect_back() elif len(flask.g.fas_user.groups) == 0: flask.flash( 'You need to be in one another group than CLA to vote', 'error') return safe_redirect_back() return f(*args, **kwargs)
def election_results_text(election_alias): election = get_valid_election(election_alias, ended=True) if not isinstance(election, models.Election): # pragma: no cover return election if not (is_authenticated() and (is_admin(flask.g.fas_user) or is_election_admin(flask.g.fas_user, election.id))): flask.flash( "The text results are only available to the admins", "error") return safe_redirect_back() usernamemap = build_name_map(election) stats = models.Vote.get_election_stats(SESSION, election.id) return flask.render_template( 'results_text.html', election=election, usernamemap=usernamemap, stats=stats, )
def election_results_text(election_alias): election = get_valid_election(election_alias, ended=True) if not isinstance(election, models.Election): # pragma: no cover return election if not (is_authenticated() and (is_admin(flask.g.fas_user) or is_election_admin(flask.g.fas_user, election.id))): flask.flash("The text results are only available to the admins", "error") return safe_redirect_back() usernamemap = build_name_map(election) stats = models.Vote.get_election_stats(SESSION, election.id) return flask.render_template( 'results_text.html', election=election, usernamemap=usernamemap, stats=stats, )