Example #1
0
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})
Example #2
0
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})
Example #3
0
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})
Example #4
0
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
        })
Example #5
0
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
        })
Example #6
0
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,
        },
    )