def home(request): # load the featured elections featured_elections = Election.get_featured() user = get_user(request) create_p = can_create_election(request) output = _('NoFeatured') if create_p: elections_administered = Election.get_by_user_as_admin(user, archived_p=False, limit=5) else: elections_administered = None if user: elections_voted = Election.get_by_user_as_voter(user, limit=5) else: elections_voted = None auth_systems = copy.copy(settings.AUTH_ENABLED_SYSTEMS) try: auth_systems.remove('password') except: pass login_box = auth_views.login_box_raw(request, return_url="/", auth_systems=auth_systems) return render_template(request, "index", {'elections': featured_elections, 'elections_administered' : elections_administered, 'elections_voted' : elections_voted, 'create_p':create_p, 'login_box' : login_box})
def home(request): # load the featured elections elections = Election.objects.all().order_by('-created_at') user = get_user(request) create_p = can_create_election(request) elections_administered = Election.get_by_user_as_admin(user, archived_p=False, limit=5) if user: elections_voted = Election.get_by_user_as_voter(user, limit=5) else: elections_voted = None institutions = Institution.objects.all() institutions_list = [] for institution in institutions: institutions_list.append({ 'pk': institution.pk, 'name': institution.name, 'elections_new': institution.elections_new(), 'elections_in_progress' : institution.elections_in_progress(), 'elections_done': institution.elections_done(), }) return render_template(request, "index", {'elections': elections, 'elections_administered' : elections_administered, 'elections_voted' : elections_voted, 'create_p':create_p, 'institutions': institutions_list})
def home(request): from helios.models import Election import heliosinstitution user = get_user(request) if user and user.user_type == 'shibboleth': return HttpResponseRedirect(reverse(heliosinstitution.views.home)) # load the featured elections featured_elections = Election.get_featured() create_p = can_create_election(request) if create_p: elections_administered = Election.get_by_user_as_admin(user, archived_p=False, limit=5) else: elections_administered = None if user: elections_voted = Election.get_by_user_as_voter(user, limit=5) else: elections_voted = None auth_systems = copy.copy(settings.AUTH_ENABLED_AUTH_SYSTEMS) try: auth_systems.remove('password') except: pass login_box = auth_views.login_box_raw(request, return_url="/", auth_systems=auth_systems) return render_template(request, "index", {'elections': featured_elections, 'elections_administered' : elections_administered, 'elections_voted' : elections_voted, 'create_p':create_p, 'login_box' : login_box})
def getElection(pk): queryset = Election.get_by_uuid(pk) if (queryset): return queryset queryset = Election.get_by_short_name(pk) if (queryset): return queryset raise_exception(404, 'Election not Found.')
def elections_administered(request, user_pk): user = get_user(request) elections_administered = [] if user.pk == int(user_pk): elections_administered = utils.elections_as_json(Election.get_by_user_as_admin(user)) return render_template(request, "elections_administered", { "elections_administered": elections_administered, })
def elections_administered(request, user_pk): user = get_user(request) elections_administered = [] if user.pk == int(user_pk): elections_administered = utils.elections_as_json( Election.get_by_user_as_admin(user)) return render_template(request, "elections_administered", { "elections_administered": elections_administered, })
def home(request): # load the featured elections elections = Election.objects.all().order_by('-created_at') user = get_user(request) create_p = can_create_election(request) elections_administered = Election.get_by_user_as_admin(user, archived_p=False, limit=5) if user: elections_voted = Election.get_by_user_as_voter(user, limit=5) else: elections_voted = None institutions = Institution.objects.all() institutions_list = [] for institution in institutions: institutions_list.append({ 'pk': institution.pk, 'name': institution.name, 'elections_new': institution.elections_new(), 'elections_in_progress': institution.elections_in_progress(), 'elections_done': institution.elections_done(), }) return render_template( request, "index", { 'elections': elections, 'elections_administered': elections_administered, 'elections_voted': elections_voted, 'create_p': create_p, 'institutions': institutions_list })
def home(request): from helios.models import Election import heliosinstitution user = get_user(request) if user and user.user_type == 'shibboleth': return HttpResponseRedirect(reverse(heliosinstitution.views.home)) # load the featured elections featured_elections = Election.get_featured() create_p = can_create_election(request) if create_p: elections_administered = Election.get_by_user_as_admin( user, archived_p=False, limit=5) else: elections_administered = None if user: elections_voted = Election.get_by_user_as_voter(user, limit=5) else: elections_voted = None auth_systems = copy.copy(settings.AUTH_ENABLED_AUTH_SYSTEMS) try: auth_systems.remove('password') except: pass login_box = auth_views.login_box_raw(request, return_url="/", auth_systems=auth_systems) return render_template( request, "index", { 'elections': featured_elections, 'elections_administered': elections_administered, 'elections_voted': elections_voted, 'create_p': create_p, 'login_box': login_box })
def home(request): # load the featured elections featured_elections = Election.get_featured() user = get_user(request) create_p = can_create_election(request) if create_p: elections_administered = Election.get_by_user_as_admin( user, archived_p=False, limit=5 ) else: elections_administered = None if user: elections_voted = Election.get_by_user_as_voter(user, limit=5) else: elections_voted = None auth_systems = copy.copy(settings.AUTH_ENABLED_AUTH_SYSTEMS) try: auth_systems.remove("password") except: pass login_box = auth_views.login_box_raw( request, return_url="/", auth_systems=auth_systems ) return render_template( request, "index", { "elections": featured_elections, "elections_administered": elections_administered, "elections_voted": elections_voted, "create_p": create_p, "login_box": login_box, }, )
def putQuestions(election, field, value): if (field == "questions"): Election.save_questions_safely(election, value) election.save() elif (field == "shortName"): election.short_name = value election.save() elif (field == "name"): election.name = value election.save() elif (field == "description"): election.description = value election.save() elif (field == "helpEmail"): election.help_email = value election.save() elif (field == "votingStartsAt"): election.voting_starts_at = value election.save() elif (field == "votingEndsAt"): election.voting_ends_at = value election.save() else: raise_exception(400, 'Field: %s not exists.' % (field))
def get_election_by_uuid(uuid): if not uuid: raise Exception("no election ID") return Election.get_by_uuid(uuid)
def get_cast_vote(election_pk, voter_pk): '''Get cast vote by election and voter keys.''' election = Election.get_by_uuid(election_pk) voter = Voter.get_by_election_and_uuid(election, voter_pk) return CastVote.get_by_voter(voter)