コード例 #1
0
def browsers(request):
    """ Shows list of all browsers.
    """
    ret = {}
    custom_log(request, "Admin: list of browsers")
    ret["entries"] = paginate(request, Browser.objects.all())
    return render_to_response("admin_frontend/browsers.html", ret, context_instance=RequestContext(request))
コード例 #2
0
def logs(request, **kwargs):
    """ Shows log entries for browser, user or for all users """
    ret = {}
    custom_log(request, "Admin: logs")
    bid_public = kwargs.get("bid_public")
    username = kwargs.get("username")
    if bid_public:
        entries = Log.objects.filter(bid_public=bid_public)
        username = None
        try:
            ret["abrowser"] = Browser.objects.get(bid_public=bid_public)
            if ret["abrowser"].user:
                username = ret["abrowser"].user.username
        except Browser.DoesNotExist:
            ret["missing_browser"] = True
        custom_log(request, "Admin: entries for %s (%s)" % (bid_public, username))

    elif username:
        ret["auser"] = get_object_or_404(User, username=username)
        entries = Log.objects.filter(user=ret["auser"])
        custom_log(request, "Admin: entries for %s" % username)
    else:
        custom_log(request, "Admin: all entries")
        entries = Log.objects.all()

    ret["entries"] = paginate(request, entries)


    return render_to_response("admin_frontend/logs.html", ret, context_instance=RequestContext(request))
コード例 #3
0
ファイル: views.py プロジェクト: futurice/sso-frontend
def logs(request, **kwargs):
    """ Shows log entries for browser, user or for all users """
    ret = {}
    custom_log(request, "Admin: logs")
    bid_public = kwargs.get("bid_public")
    username = kwargs.get("username")
    if bid_public:
        entries = Log.objects.filter(bid_public=bid_public)
        username = None
        try:
            ret["abrowser"] = Browser.objects.get(bid_public=bid_public)
            if ret["abrowser"].user:
                username = ret["abrowser"].user.username
        except Browser.DoesNotExist:
            ret["missing_browser"] = True
        custom_log(request, "Admin: entries for %s (%s)" % (bid_public, username))

    elif username:
        ret["auser"] = get_object_or_404(User, username=username)
        entries = Log.objects.filter(user=ret["auser"])
        custom_log(request, "Admin: entries for %s" % username)
    else:
        custom_log(request, "Admin: all entries")
        entries = Log.objects.all()

    ret["entries"] = paginate(request, entries)


    return render_to_response("admin_frontend/logs.html", ret, context_instance=RequestContext(request))
コード例 #4
0
def logins(request):
    """ Shows list of active logins for all users. """
    ret = {}
    custom_log(request, "Admin: list of active logins")
    entries = BrowserLogin.objects.filter(signed_out=False).filter(expires_at__gte=timezone.now())
    ret["entries"] = paginate(request, entries)
    return render_to_response("admin_frontend/logins.html", ret, context_instance=RequestContext(request))
コード例 #5
0
ファイル: views.py プロジェクト: futurice/sso-frontend
def browsers(request):
    """ Shows list of all browsers.
    """
    ret = {}
    custom_log(request, "Admin: list of browsers")
    ret["entries"] = paginate(request, Browser.objects.all())
    return render_to_response("admin_frontend/browsers.html", ret, context_instance=RequestContext(request))
コード例 #6
0
ファイル: views.py プロジェクト: futurice/sso-frontend
def logins(request):
    """ Shows list of active logins for all users. """
    ret = {}
    custom_log(request, "Admin: list of active logins")
    entries = BrowserLogin.objects.filter(signed_out=False).filter(expires_at__gte=timezone.now())
    ret["entries"] = paginate(request, entries)
    return render_to_response("admin_frontend/logins.html", ret, context_instance=RequestContext(request))
コード例 #7
0
ファイル: views.py プロジェクト: futurice/sso-frontend
def yubikeys(request):
    """ Shows list of configured Yubikeys """
    ret = {}
    custom_log(request, "Admin: list of Yubikeys")
    entries = Yubikey.objects.all()
    ret["entries"] = paginate(request, entries)
    return render_to_response("admin_frontend/yubikeys.html", ret, context_instance=RequestContext(request))
コード例 #8
0
def users(request):
    """ Returns list of users.
    """
    custom_log(request, "Admin: users")
    ret = {}
    entries = User.objects.all().order_by('username')
    ret["entries"] = paginate(request, entries)
    return render_to_response("admin_frontend/users.html", ret, context_instance=RequestContext(request))
コード例 #9
0
ファイル: views.py プロジェクト: futurice/sso-frontend
def users(request):
    """ Returns list of users.
    """
    custom_log(request, "Admin: users")
    ret = {}
    entries = User.objects.all().order_by('username')
    ret["entries"] = paginate(request, entries)
    return render_to_response("admin_frontend/users.html", ret, context_instance=RequestContext(request))
コード例 #10
0
ファイル: views.py プロジェクト: imbi7py/sso-frontend-old
def view_log(request, **kwargs):
    """ Shows log entries to the user """
    ret = {}

    browsers = {}
    ret["browsers"] = []
    list_of_browsers = Log.objects.filter(user=request.browser.user).order_by(
        "bid_public").values("bid_public").distinct()
    for item in list_of_browsers:
        try:
            browser_item = Browser.objects.get(bid_public=item["bid_public"])
        except Browser.DoesNotExist:
            continue
        browsers[item["bid_public"]] = browser_item
        ret["browsers"].append(browser_item)

    entries = Log.objects.filter(
        user=request.browser.user).order_by("-timestamp")
    bid_public = kwargs.get("bid_public")
    if bid_public:
        entries = entries.filter(bid_public=bid_public)
        try:
            ret["this_browser"] = Browser.objects.get(bid_public=bid_public)
        except Browser.DoesNotExist:
            pass

    entries = paginate(request, entries)

    for entry in entries:
        browser = browsers.get(entry.bid_public)
        if not browser:
            try:
                browser = Browser.objects.get(bid_public=entry.bid_public)
                browsers[entry.bid_public] = browser
            except Browser.DoesNotExist:
                pass
        entry.browser = browser

    ret["entries"] = entries

    response = render_to_response("login_frontend/view_log.html",
                                  ret,
                                  context_instance=RequestContext(request))
    return response
コード例 #11
0
ファイル: views.py プロジェクト: futurice/sso-frontend
def view_log(request, **kwargs):
    """ Shows log entries to the user """
    ret = {}

    browsers = {}
    ret["browsers"] = []
    list_of_browsers = Log.objects.filter(user=request.browser.user).order_by("bid_public").values("bid_public").distinct()
    for item in list_of_browsers:
        try:
            browser_item = Browser.objects.get(bid_public=item["bid_public"])
        except Browser.DoesNotExist:
            continue
        browsers[item["bid_public"]] = browser_item
        ret["browsers"].append(browser_item)

    entries = Log.objects.filter(user=request.browser.user).order_by("-timestamp")
    bid_public = kwargs.get("bid_public")
    if bid_public:
        entries = entries.filter(bid_public=bid_public)
        try:
            ret["this_browser"] = Browser.objects.get(bid_public=bid_public)
        except Browser.DoesNotExist:
            pass

    entries = paginate(request, entries)

    for entry in entries:
        browser = browsers.get(entry.bid_public)
        if not browser:
            try:
                browser = Browser.objects.get(bid_public=entry.bid_public)
                browsers[entry.bid_public] = browser
            except Browser.DoesNotExist:
                pass
        entry.browser = browser

    ret["entries"] = entries

    response = render_to_response("login_frontend/view_log.html", ret, context_instance=RequestContext(request))
    return response