Ejemplo n.º 1
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})
Ejemplo n.º 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})
Ejemplo n.º 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
        })
Ejemplo n.º 4
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,
        },
    )