예제 #1
0
    def election_view_wrapper(request, election_uuid=None, *args, **kw):
      election = get_election_by_uuid(election_uuid)

      if not election:
        raise Http404

      if election.canceled_at:
        from helios.views import render_template
        return render_template(request, 'election_canceled',
                           {'election': election})

      # do checks
      do_election_checks(election, checks)

      # if private election, only logged in voters
      if election.private_p and not checks.get('allow_logins',False):
        from views import password_voter_login
        if not user_can_see_election(request, election):
          return_url = request.get_full_path()
          return HttpResponseRedirect("%s?%s" % (reverse(password_voter_login, args=[election.uuid]), urllib.urlencode({
                  'return_url' : return_url
                  })))

      try:
        return func(request, election, *args, **kw)
      except Exception, e:
        import traceback
        #traceback.print_exc()
        raise
예제 #2
0
파일: security.py 프로젝트: vinilios/zeus
        def election_admin_wrapper(request, election_uuid=None, *args, **kw):
            election = get_election_by_uuid(election_uuid)

            if not election:
                raise Http404

            if election.canceled_at:
                from helios.views import render_template
                return render_template(request, 'election_canceled',
                                       {'election': election})

            user = get_user(request)
            skip_admin_check = False
            if user and user.superadmin_p and checks.get(
                    'allow_superadmin', False):
                skip_admin_check = True

            if not user_can_admin_election(user,
                                           election) and not skip_admin_check:
                raise PermissionDenied('5')

            # do checks
            do_election_checks(election, checks)

            return func(request, election, *args, **kw)
예제 #3
0
  def trustee_check_wrapper(request, election_uuid, trustee_uuid, *args, **kwargs):
    election = get_election_by_uuid(election_uuid)

    trustee = Trustee.get_by_election_and_uuid(election, trustee_uuid)

    if not election:
      raise Http404

    if election.canceled_at:
      from helios.views import render_template
      return render_template(request, 'election_canceled',
                         {'election': election})

    if trustee == get_logged_in_trustee(request):
      return func(request, election, trustee, *args, **kwargs)
    else:
      raise PermissionDenied('6')
예제 #4
0
파일: security.py 프로젝트: vinilios/zeus
    def trustee_check_wrapper(request, election_uuid, trustee_uuid, *args,
                              **kwargs):
        election = get_election_by_uuid(election_uuid)

        trustee = Trustee.get_by_election_and_uuid(election, trustee_uuid)

        if not election:
            raise Http404

        if election.canceled_at:
            from helios.views import render_template
            return render_template(request, 'election_canceled',
                                   {'election': election})

        if trustee == get_logged_in_trustee(request):
            return func(request, election, trustee, *args, **kwargs)
        else:
            raise PermissionDenied('6')
예제 #5
0
    def election_view_wrapper(request, election_uuid=None, *args, **kw):
      election = get_election_by_uuid(election_uuid)

      if not election:
        raise Http404

      if election.canceled_at:
        from helios.views import render_template
        return render_template(request, 'election_canceled',
                           {'election': election})

      # do checks
      do_election_checks(election, checks)

      try:
        return func(request, election, *args, **kw)
      except Exception, e:
        import traceback
        #traceback.print_exc()
        raise
예제 #6
0
파일: security.py 프로젝트: vinilios/zeus
        def election_view_wrapper(request, election_uuid=None, *args, **kw):
            election = get_election_by_uuid(election_uuid)

            if not election:
                raise Http404

            if election.canceled_at:
                from helios.views import render_template
                return render_template(request, 'election_canceled',
                                       {'election': election})

            # do checks
            do_election_checks(election, checks)

            try:
                return func(request, election, *args, **kw)
            except Exception, e:
                import traceback
                #traceback.print_exc()
                raise
예제 #7
0
    def election_admin_wrapper(request, election_uuid=None, *args, **kw):
      election = get_election_by_uuid(election_uuid)

      if not election:
        raise Http404

      if election.canceled_at:
        from helios.views import render_template
        return render_template(request, 'election_canceled',
                           {'election': election})

      user = get_user(request)
      skip_admin_check = False
      if user and user.superadmin_p and checks.get('allow_superadmin', False):
        skip_admin_check = True

      if not user_can_admin_election(user, election) and not skip_admin_check:
        raise PermissionDenied('5')

      # do checks
      do_election_checks(election, checks)

      return func(request, election, *args, **kw)