Esempio n. 1
0
 def get(self, request):
     """
     """
     user = request.user
     groups = user.group_set.all()
     providers = []
     records = CoreMaintenanceRecord.objects.none()
     for g in groups:
         for p in g.providers.all():
             if p not in providers:
                 providers.append(p)
     if 'active' in request.GET:
         if request.GET['active'].lower() == "true":
             now_time = timezone.now()
             for p in providers:
                 records |= CoreMaintenanceRecord.active(p)
         else:
             all_records = CoreMaintenanceRecord.objects.all()
             now_time = timezone.now()
             for p in providers:
                 records |= CoreMaintenanceRecord.active(p)
             records = all_records.exclude(id__in=records)
     else:
         records = CoreMaintenanceRecord.objects.filter(
             Q(provider__in=providers) | Q(provider=None))
     return Response(MaintenanceRecordSerializer(records, many=True).data)
Esempio n. 2
0
 def get(self, request):
     query = request.GET
     user = request.user
     providers = []
     records = CoreMaintenanceRecord.objects.none()
     active_records = query.get('active', 'false').lower() == "true"
     if user and type(user) != AnonymousUser:
         groups = user.group_set.all()
         for group in groups:
             provider_ids = group.identities.filter(
                 only_current_provider(),
                 provider__active=True).values_list('provider',
                                                    flat=True)
             providers = Provider.objects.filter(id__in=provider_ids)
             for p in providers:
                 if active_records:
                     records |= CoreMaintenanceRecord.active(p)
                 else:
                     records |= CoreMaintenanceRecord.objects.filter(
                         provider=p)
     if active_records:
         global_records = CoreMaintenanceRecord.active()
     else:
         global_records = CoreMaintenanceRecord.objects.filter(
             provider=None)
     records |= global_records
     return Response(MaintenanceRecordSerializer(records, many=True).data)
Esempio n. 3
0
 def get(self, request):
     """
     """
     user = request.user
     groups = user.group_set.all()
     providers = []
     records = CoreMaintenanceRecord.objects.none()
     for g in groups:
         for p in g.providers.all():
             if p not in providers:
                 providers.append(p)
     if 'active' in request.GET:
         if request.GET['active'].lower() == "true":
             now_time = timezone.now()
             for p in providers:
                 records |= CoreMaintenanceRecord.active(p)
         else:
             all_records = CoreMaintenanceRecord.objects.all()
             now_time = timezone.now()
             for p in providers:
                 records |= CoreMaintenanceRecord.active(p)
             records = all_records.exclude(id__in=records)
     else:
         records = CoreMaintenanceRecord.objects.filter(
             Q(provider__in=providers) | Q(provider=None))
     return Response(MaintenanceRecordSerializer(records, many=True).data)
Esempio n. 4
0
def login(request):
    """
     CAS Login : Phase 1/3 Call CAS Login
    """
    #logger.info("Login Request:%s" % request)
    #Form Sets 'next' when user clicks login
    records = MaintenanceRecord.active()
    disable_login = False
    for record in records:
        if record.disable_login:
            disable_login = True

    if 'next' in request.POST:
        return auth_loginRedirect(request,
                                  settings.REDIRECT_URL + '/application/')
    else:
        template = get_template('application/login.html')

        variables = RequestContext(
            request, {
                'site_root': settings.REDIRECT_URL,
                'records': [r.json() for r in records],
                'disable_login': disable_login
            })
        output = template.render(variables)
        return HttpResponse(output)
Esempio n. 5
0
def login(request):
    """
     CAS Login : Phase 1/3 Call CAS Login
    """
    # logger.info("Login Request:%s" % request)
    # Form Sets 'next' when user clicks login
    records = MaintenanceRecord.active()
    disable_login = False
    for record in records:
        if record.disable_login:
            disable_login = True

    if "next" in request.POST:
        return cas_loginRedirect(request, settings.REDIRECT_URL + "/application/")
    else:
        template = get_template("application/login.html")

        variables = RequestContext(
            request,
            {
                "site_root": settings.REDIRECT_URL,
                "records": [r.json() for r in records],
                "disable_login": disable_login,
            },
        )
        output = template.render(variables)
        return HttpResponse(output)
Esempio n. 6
0
def s_login(request):
    """
     SAML Login: Phase 1/2 Call SAML Login
    """
    # Form Sets 'next' when user clicks login
    records = MaintenanceRecord.active()
    disable_login = False
    for record in records:
        if record.disable_login:
            disable_login = True
    return saml_loginRedirect(request)
Esempio n. 7
0
def s_login(request):
    """
     SAML Login: Phase 1/2 Call SAML Login
    """
    #logger.info("Login Request:%s" % request)
    #Form Sets 'next' when user clicks login
    records = MaintenanceRecord.active()
    disable_login = False
    for record in records:
        if record.disable_login:
            disable_login = True
    return saml_loginRedirect(request)
Esempio n. 8
0
def s_login(request):
    """
     SAML Login: Phase 1/2 Call SAML Login
    """
    #logger.info("Login Request:%s" % request)
    #Form Sets 'next' when user clicks login
    records = MaintenanceRecord.active()
    disable_login = False
    for record in records:
        if record.disable_login:
            disable_login = True
    return saml_loginRedirect(request, settings.REDIRECT_URL+"/login/")
Esempio n. 9
0
def app(request):
    try:
        if MaintenanceRecord.disable_login_access(request):
            return HttpResponseRedirect("/login/")
        template = get_template("cf2/index.html")
        context = RequestContext(
            request, {"site_root": settings.REDIRECT_URL, "debug": settings.DEBUG, "year": datetime.now().year}
        )
        output = template.render(context)
        return HttpResponse(output)
    except KeyError, e:
        logger.debug("User not logged in.. Redirecting to CAS login")
        return cas_loginRedirect(request, settings.REDIRECT_URL + "/application")
 def get(self, request):
     query = request.GET
     user = request.user
     providers = []
     records = CoreMaintenanceRecord.objects.none()
     active_records = query.get('active', 'false').lower() == "true"
     if user and not isinstance(user, AnonymousUser):
         groups = user.group_set.all()
         for group in groups:
             providers = group.current_providers.all()
             for p in providers:
                 if active_records:
                     records |= CoreMaintenanceRecord.active(p)
                 else:
                     records |= CoreMaintenanceRecord.objects.filter(
                         provider=p)
     if active_records:
         global_records = CoreMaintenanceRecord.active()
     else:
         global_records = CoreMaintenanceRecord.objects.filter(
             provider=None)
     records |= global_records
     return Response(MaintenanceRecordSerializer(records, many=True).data)
Esempio n. 11
0
 def get(self, request):
     query = request.GET
     user = request.user
     providers = []
     records = CoreMaintenanceRecord.objects.none()
     active_records = query.get('active', 'false').lower() == "true"
     if user and not isinstance(user, AnonymousUser):
         memberships = user.memberships.select_related('group')
         for membership in memberships:
             group = membership.group
             providers = group.current_providers.all()
             for p in providers:
                 if active_records:
                     records |= CoreMaintenanceRecord.active(p)
                 else:
                     records |= CoreMaintenanceRecord.objects.filter(
                         provider=p)
     if active_records:
         global_records = CoreMaintenanceRecord.active()
     else:
         global_records = CoreMaintenanceRecord.objects.filter(
             provider=None)
     records |= global_records
     return Response(MaintenanceRecordSerializer(records, many=True).data)
Esempio n. 12
0
 def get(self, request):
     """
     """
     query = request.GET
     user = request.user
     providers = []
     records = CoreMaintenanceRecord.objects.none()
     active_records = query.get('active', 'false').lower() == "true"
     if user and type(user) != AnonymousUser:
         groups = user.group_set.all()
         for g in groups:
             for p in g.providers.all():
                 if active_records:
                     records |= CoreMaintenanceRecord.active(p)
                 else:
                     records |= CoreMaintenanceRecord.objects.filter(
                         provider=p)
     if active_records:
         global_records = CoreMaintenanceRecord.active()
     else:
         global_records = CoreMaintenanceRecord.objects.filter(
             provider=None)
     records |= global_records
     return Response(MaintenanceRecordSerializer(records, many=True).data)
Esempio n. 13
0
def app(request):
    try:
        if MaintenanceRecord.disable_login_access(request):
            return HttpResponseRedirect('/login/')
#        template = get_template("cf2/index.html")
#        output = template.render(context)
        logger.debug("render to response.")
        return render_to_response("cf2/index.html", {
            'site_root': settings.REDIRECT_URL,
            'debug': settings.DEBUG,
            'year': datetime.now().year},
            context_instance=RequestContext(request))
#HttpResponse(output)
    except KeyError, e:
        logger.debug("User not logged in.. Redirecting to CAS login")
        return cas_loginRedirect(request, settings.REDIRECT_URL+'/application')
Esempio n. 14
0
def app(request):
    try:
        if MaintenanceRecord.disable_login_access(request):
            return HttpResponseRedirect('/login/')
#        template = get_template("cf2/index.html")
#        output = template.render(context)
        logger.debug("render to response.")
        return render_to_response("cf2/index.html", {
            'site_root': settings.REDIRECT_URL,
            'debug': settings.DEBUG,
            'year': datetime.now().year},
            context_instance=RequestContext(request))
#HttpResponse(output)
    except KeyError, e:
        logger.debug("User not logged in.. Redirecting to CAS login")
        return auth_loginRedirect(request, settings.REDIRECT_URL+'/application')
Esempio n. 15
0
def login(request):
    """
     CAS Login : Phase 1/3 Call CAS Login
    """
    # Form Sets 'next' when user clicks login
    records = MaintenanceRecord.active()
    disable_login = False
    for record in records:
        if record.disable_login:
            disable_login = True

    if 'next' in request.POST:
        return auth_loginRedirect(request,
                                  settings.REDIRECT_URL + '/application/')
    else:
        template = get_template('application/login.html')

        variables = RequestContext(request, {
            'site_root': settings.REDIRECT_URL,
            'records': [r.json() for r in records],
            'disable_login': disable_login})
        output = template.render(variables)
        return HttpResponse(output)