Пример #1
0
def group_detail(request, groupid, page_no=1, page_size=60):
    try:
        group = Group.objects.get(id=groupid)
        django_users = DjangoUser.objects.only("id",
                                               "username").filter(groups=group)
        page = get_page(django_users, page_no, page_size)
    except ObjectDoesNotExist:
        raise Http404

    breadcrumb = [{
        "name": SITE_NAME,
        "url": "/"
    }, {
        "name": _("Permission Center"),
        "url": reverse("privilege.views.permission.permission_list")
    }, {
        "name":
        _("Group Center"),
        "url":
        reverse("privilege.views.group.group_list", args=(1, ))
    }, {
        'name': group.name
    }]
    url_prefix = reverse("privilege.views.group.group_detail",
                         args=(
                             groupid,
                             page_no,
                         )).rstrip("/")[:-2]
    permissions = get_latest_permissions()

    return render_template("privilege/group_detail.html",
                           page_title=breadcrumb[-1]["name"],
                           CURRENT_MENU=CURRENT_MENU,
                           LEFT_MENUS=LEFT_MENUS,
                           **locals())
Пример #2
0
def search(request, pageno=1, pagesize=PRIVILEGE_PAGE_SIZE):
    default_redirect = reverse("privilege.views.group.group_list", args=(1, ))
    keyword, source_url = _get_keyword_source_url(request)

    if not keyword or not source_url:
        return redirect(default_redirect)

    if source_url.find("group") > 0:
        objlist = Group.objects.filter(name__contains=keyword)
        template = "privilege/group_list.html"
        current_menu = _("Group Center")
    else:
        objlist = DjangoUser.objects.filter(username__contains=keyword)
        template = "privilege/user_list.html"
        current_menu = _("User Center")
    page = get_page(objlist, pageno, pagesize)

    url_prefix = reverse("privilege.views.user.search",
                         args=(1, )).rstrip("/")[:-2]
    groups = get_latest_groups()
    permissions = get_latest_permissions()
    breadcrumb = [{
        "name": SITE_NAME,
        "url": "/"
    }, {
        "name": _("Permission Center"),
        "url": reverse("privilege.views.permission.permission_list")
    }, {
        "name": u"Search'%s'" % keyword
    }]

    return render_template(page_title=breadcrumb[-1]["name"],
                           CURRENT_MENU=current_menu,
                           LEFT_MENUS=LEFT_MENUS,
                           **locals())
Пример #3
0
def search(request, pageno=1, pagesize=PRIVILEGE_PAGE_SIZE):
    default_redirect = reverse("privilege.views.group.group_list", args=(1,))
    keyword, source_url = _get_keyword_source_url(request)

    if not keyword or not source_url:
        return redirect(default_redirect)

    if source_url.find("group") > 0:
        objlist = Group.objects.filter(name__contains=keyword)
        template = "privilege/group_list.html"
        current_menu = _("Group Center")
    else:
        objlist = DjangoUser.objects.filter(username__contains=keyword)
        template = "privilege/user_list.html"
        current_menu = _("User Center")
    page = get_page(objlist, pageno, pagesize)

    url_prefix = reverse("privilege.views.user.search", args=(1, )).rstrip("/")[:-2]
    groups = get_latest_groups()
    permissions = get_latest_permissions()
    breadcrumb = [
        {"name": SITE_NAME, "url": "/"},
        {"name": _("Permission Center"), "url": reverse("privilege.views.permission.permission_list")},
        {"name": u"Search'%s'" % keyword}
    ]

    return render_template(page_title=breadcrumb[-1]["name"], CURRENT_MENU=current_menu,
                           LEFT_MENUS=LEFT_MENUS, **locals())
Пример #4
0
def permission_list(request):
    breadcrumb = [{"name": SITE_NAME, "url": "/"},
                  {"name": _("Permission Center")},
                  ]
    permissions = get_latest_permissions()

    return render_template("privilege/permission_list.html", page_title=breadcrumb[-1]["name"],
                           CURRENT_MENU=CURRENT_MENU, LEFT_MENUS=LEFT_MENUS, **locals())
Пример #5
0
def group_list(request, pageno=1, pagesize=PRIVILEGE_PAGE_SIZE):
    breadcrumb = [
        {"name": SITE_NAME, "url": "/"},
        {"name": _("Permission Center"), "url": reverse("privilege.views.permission.permission_list")},
        {'name': _("Group Center")}
    ]
    groups = get_latest_groups()
    page = get_page(groups, pageno, pagesize)
    permissions = get_latest_permissions()
    url_prefix = reverse("privilege.views.group.group_list", args=(1, )).rstrip("/")[:-2]

    return render_template("privilege/group_list.html", page_title=breadcrumb[-1]["name"],
                           CURRENT_MENU=CURRENT_MENU, LEFT_MENUS=LEFT_MENUS, **locals())
Пример #6
0
def user_list(request, pageno=1, pagesize=PRIVILEGE_PAGE_SIZE):
    breadcrumb = [
        {"name": SITE_NAME, "url": "/"},
        {"name": _("Permission Center"), "url": reverse("privilege.views.permission.permission_list")},
        {'name': _("User Center")}
    ]

    users = DjangoUser.objects.only("id", "username", "is_staff").all()
    page = get_page(users, pageno, pagesize)
    groups = get_latest_groups()
    permissions = get_latest_permissions()
    url_prefix = reverse("privilege.views.user.user_list", args=(1, )).rstrip("/")[:-2]

    return render_template("privilege/user_list.html", page_title=breadcrumb[-1]["name"], 
                           CURRENT_MENU=CURRENT_MENU, LEFT_MENUS=LEFT_MENUS, **locals())
Пример #7
0
def permission_list(request):
    breadcrumb = [
        {
            "name": SITE_NAME,
            "url": "/"
        },
        {
            "name": _("Permission Center")
        },
    ]
    permissions = get_latest_permissions()

    return render_template("privilege/permission_list.html",
                           page_title=breadcrumb[-1]["name"],
                           CURRENT_MENU=CURRENT_MENU,
                           LEFT_MENUS=LEFT_MENUS,
                           **locals())
Пример #8
0
def group_detail(request, groupid, page_no=1, page_size=60):
    try:
        group = Group.objects.get(id=groupid)
        django_users = DjangoUser.objects.only("id", "username").filter(groups=group)
        page = get_page(django_users, page_no, page_size)
    except ObjectDoesNotExist:
        raise Http404

    breadcrumb = [
        {"name": SITE_NAME, "url": "/"},
        {"name": _("Permission Center"), "url": reverse("privilege.views.permission.permission_list")},
        {"name": _("Group Center"), "url": reverse("privilege.views.group.group_list", args=(1,))},
        {'name': group.name}
    ]
    url_prefix = reverse("privilege.views.group.group_detail", args=(groupid, page_no, )).rstrip("/")[:-2]
    permissions = get_latest_permissions()

    return render_template("privilege/group_detail.html", page_title=breadcrumb[-1]["name"], 
                           CURRENT_MENU=CURRENT_MENU, LEFT_MENUS=LEFT_MENUS, **locals())
Пример #9
0
def group_list(request, pageno=1, pagesize=PRIVILEGE_PAGE_SIZE):
    breadcrumb = [{
        "name": SITE_NAME,
        "url": "/"
    }, {
        "name": _("Permission Center"),
        "url": reverse("privilege.views.permission.permission_list")
    }, {
        'name': _("Group Center")
    }]
    groups = get_latest_groups()
    page = get_page(groups, pageno, pagesize)
    permissions = get_latest_permissions()
    url_prefix = reverse("privilege.views.group.group_list",
                         args=(1, )).rstrip("/")[:-2]

    return render_template("privilege/group_list.html",
                           page_title=breadcrumb[-1]["name"],
                           CURRENT_MENU=CURRENT_MENU,
                           LEFT_MENUS=LEFT_MENUS,
                           **locals())
Пример #10
0
def user_list(request, pageno=1, pagesize=PRIVILEGE_PAGE_SIZE):
    breadcrumb = [{
        "name": SITE_NAME,
        "url": "/"
    }, {
        "name": _("Permission Center"),
        "url": reverse("privilege.views.permission.permission_list")
    }, {
        'name': _("User Center")
    }]

    users = DjangoUser.objects.only("id", "username", "is_staff").all()
    page = get_page(users, pageno, pagesize)
    groups = get_latest_groups()
    permissions = get_latest_permissions()
    url_prefix = reverse("privilege.views.user.user_list",
                         args=(1, )).rstrip("/")[:-2]

    return render_template("privilege/user_list.html",
                           page_title=breadcrumb[-1]["name"],
                           CURRENT_MENU=CURRENT_MENU,
                           LEFT_MENUS=LEFT_MENUS,
                           **locals())
Пример #11
0
 def test_get_latest_permissions(self):
     self.assertTrue(utils.get_latest_permissions() is not None)