コード例 #1
0
ファイル: urls.py プロジェクト: masindeandrew/shuup
def get_urls():
    urls = []
    urls.extend(get_module_urls())

    urls.extend([
        admin_url(r'^$', DashboardView.as_view(), name='dashboard'),
        admin_url(r'^search/$', SearchView.as_view(), name='search'),
        admin_url(r'^select/$', MultiselectAjaxView.as_view(), name='select'),
        admin_url(r'^menu/$', MenuView.as_view(), name='menu'),
        admin_url(r'^login/$',
                  login,
                  kwargs={"template_name": "shuup/admin/auth/login.jinja"},
                  name='login',
                  require_authentication=False),
        admin_url(r'^logout/$',
                  auth_views.logout,
                  kwargs={"template_name": "shuup/admin/auth/logout.jinja"},
                  name='logout',
                  require_authentication=False),
        admin_url(r'^set-language/$',
                  csrf_exempt(set_language),
                  name="set-language"),
    ])

    for u in urls:  # pragma: no cover
        if not isinstance(u, AdminRegexURLPattern):
            warnings.warn("Admin URL %r is not an AdminRegexURLPattern" % u)

    # Add Django javascript catalog url
    urls.append(url(r'^i18n.js$', javascript_catalog_all, name='js-catalog'))

    return tuple(urls)
コード例 #2
0
def test_url_auth(rf):
    def did_disallow(view, request):
        try:
            return isinstance(view(request), HttpResponseRedirect)
        except Problem as prob:
            return True  # Problems are fine here

    with replace_modules([ATestModule]):
        urls = dict((u.name, u) for u in get_module_urls())
        request = rf.get("/")

        request.user = AnonymousUser()
        assert did_disallow(urls["test-auth"].callback, request)
        assert did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)

        request.user = AuthenticatedUser()
        assert did_disallow(urls["test-auth"].callback, request)
        assert did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)

        request.user = StaffUser()
        assert not did_disallow(urls["test-auth"].callback, request)
        assert did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)

        request.user = SuperUser()  # Can access all
        assert not did_disallow(urls["test-auth"].callback, request)
        assert not did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)
コード例 #3
0
ファイル: test_modules.py プロジェクト: suutari/shoop
def test_url_auth(rf):
    def did_disallow(view, request):
        try:
            return isinstance(view(request), HttpResponseRedirect)
        except Problem as prob:
            return True  # Problems are fine here

    with replace_modules([ATestModule]):
        urls = dict((u.name, u) for u in get_module_urls())
        request = rf.get("/")

        request.user = AnonymousUser()
        assert did_disallow(urls["test-auth"].callback, request)
        assert did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)
        request.user = AuthenticatedUser()
        assert did_disallow(urls["test-auth"].callback, request)
        assert did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)
        request.user = StaffUser()
        assert not did_disallow(urls["test-auth"].callback, request)
        assert did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)
        request.user = SuperUser()
        assert not did_disallow(urls["test-auth"].callback, request)
        assert not did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)
コード例 #4
0
ファイル: urls.py プロジェクト: kafura0/OranKids
def get_urls():
    urls = []
    urls.extend(get_module_urls())

    urls.extend([
        admin_url(r'^$', DashboardView.as_view(), name='dashboard', permissions=()),
        admin_url(r'^home/$', HomeView.as_view(), name='home', permissions=()),
        admin_url(r'^wizard/$', WizardView.as_view(), name='wizard', permissions=()),
        admin_url(r'^tour/$', TourView.as_view(), name='tour', permissions=()),
        admin_url(r'^search/$', SearchView.as_view(), name='search', permissions=()),
        admin_url(r'^select/$', MultiselectAjaxView.as_view(), name='select', permissions=()),
        admin_url(r'^edit/$', EditObjectView.as_view(), name='edit', permissions=()),
        admin_url(r'^menu/$', MenuView.as_view(), name='menu', permissions=()),
        admin_url(r'^toggle-menu/$', MenuToggleView.as_view(), name='menu_toggle', permissions=()),
        admin_url(
            r'^login/$',
            login,
            kwargs={"template_name": "shuup/admin/auth/login.jinja"},
            name='login',
            require_authentication=False,
            permissions=()
        ),
        admin_url(
            r'^logout/$',
            auth_views.logout,
            kwargs={"template_name": "shuup/admin/auth/logout.jinja"},
            name='logout',
            require_authentication=False,
            permissions=()
        ),
        admin_url(
            r'^recover-password/(?P<uidb64>.+)/(?P<token>.+)/$',
            ResetPasswordView,
            name='recover_password',
            require_authentication=False,
            permissions=()
        ),
        admin_url(
            r'^request-password/$',
            RequestPasswordView,
            name='request_password',
            require_authentication=False,
            permissions=()
        ),
        admin_url(
            r'^set-language/$',
            csrf_exempt(set_language),
            name="set-language",
            permissions=()
        ),
    ])

    for u in urls:  # pragma: no cover
        if not isinstance(u, AdminRegexURLPattern):
            warnings.warn("Admin URL %r is not an AdminRegexURLPattern" % u)

    # Add Django javascript catalog url
    urls.append(url(r'^i18n.js$', javascript_catalog_all, name='js-catalog'))

    return tuple(urls)
コード例 #5
0
ファイル: test_modules.py プロジェクト: suutari/shoop
def test_modules_in_core_admin_work(rf, admin_user):
    get_default_shop()
    request = rf.get("/")
    apply_request_middleware(request, user=admin_user)
    request = apply_request_middleware(rf.get("/"), user=admin_user)
    with replace_modules(ShuupAdminAppConfig.provides["admin_module"]):
        assert all(get_module_urls())
        assert get_menu_entry_categories(request)
コード例 #6
0
def test_modules_in_core_admin_work(rf, admin_user):
    get_default_shop()
    request = rf.get("/")
    apply_request_middleware(request, user=admin_user)
    request = apply_request_middleware(rf.get("/"), user=admin_user)
    with replace_modules(ShuupAdminAppConfig.provides["admin_module"]):
        assert all(get_module_urls())
        assert get_menu_entry_categories(request)
コード例 #7
0
ファイル: urls.py プロジェクト: gurch101/shuup
def get_urls():
    urls = []
    urls.extend(get_module_urls())

    urls.extend([
        admin_url(r'^$', DashboardView.as_view(), name='dashboard'),
        admin_url(r'^home/$', HomeView.as_view(), name='home'),
        admin_url(r'^wizard/$', WizardView.as_view(), name='wizard'),
        admin_url(r'^tour/$', TourView.as_view(), name='tour'),
        admin_url(r'^search/$', SearchView.as_view(), name='search'),
        admin_url(r'^select/$', MultiselectAjaxView.as_view(), name='select'),
        admin_url(r'^menu/$', MenuView.as_view(), name='menu'),
        admin_url(
            r'^login/$',
            login,
            kwargs={"template_name": "shuup/admin/auth/login.jinja"},
            name='login',
            require_authentication=False
        ),
        admin_url(
            r'^logout/$',
            auth_views.logout,
            kwargs={"template_name": "shuup/admin/auth/logout.jinja"},
            name='logout',
            require_authentication=False
        ),
        admin_url(
            r'^set-language/$',
            csrf_exempt(set_language),
            name="set-language"
        ),
    ])

    for u in urls:  # pragma: no cover
        if not isinstance(u, AdminRegexURLPattern):
            warnings.warn("Admin URL %r is not an AdminRegexURLPattern" % u)

    # Add Django javascript catalog url
    urls.append(url(r'^i18n.js$', javascript_catalog_all, name='js-catalog'))

    return tuple(urls)
コード例 #8
0
ファイル: urls.py プロジェクト: suutari/shoop
def get_urls():
    urls = []
    urls.extend(get_module_urls())

    urls.extend(
        [
            admin_url(r"^$", DashboardView.as_view(), name="dashboard"),
            admin_url(r"^home/$", HomeView.as_view(), name="home"),
            admin_url(r"^wizard/$", WizardView.as_view(), name="wizard"),
            admin_url(r"^tour/$", TourView.as_view(), name="tour"),
            admin_url(r"^search/$", SearchView.as_view(), name="search"),
            admin_url(r"^select/$", MultiselectAjaxView.as_view(), name="select"),
            admin_url(r"^menu/$", MenuView.as_view(), name="menu"),
            admin_url(
                r"^login/$",
                login,
                kwargs={"template_name": "shuup/admin/auth/login.jinja"},
                name="login",
                require_authentication=False,
            ),
            admin_url(
                r"^logout/$",
                auth_views.logout,
                kwargs={"template_name": "shuup/admin/auth/logout.jinja"},
                name="logout",
                require_authentication=False,
            ),
            admin_url(r"^set-language/$", csrf_exempt(set_language), name="set-language"),
        ]
    )

    for u in urls:  # pragma: no cover
        if not isinstance(u, AdminRegexURLPattern):
            warnings.warn("Admin URL %r is not an AdminRegexURLPattern" % u)

    # Add Django javascript catalog url
    urls.append(url(r"^i18n.js$", javascript_catalog_all, name="js-catalog"))

    return tuple(urls)
コード例 #9
0
ファイル: test_modules.py プロジェクト: suutari/shoop
def test_module_loading_and_urls():
    with replace_modules([
        ATestModule,
        "shuup_tests.admin.fixtures.test_module:ATestModule"
    ]):
        assert all(u.name.startswith("test") for u in get_module_urls())
コード例 #10
0
def test_module_loading_and_urls():
    with replace_modules([ATestModule, "shuup_tests.admin.fixtures.test_module:ATestModule"]):
        assert all(u.name.startswith("test") for u in get_module_urls())
コード例 #11
0
ファイル: urls.py プロジェクト: yurkobb/shuup
def get_urls():
    urls = []
    urls.extend(get_module_urls())

    urls.extend([
        admin_url(r"^$",
                  DashboardView.as_view(),
                  name="dashboard",
                  permissions=()),
        admin_url(r"^home/$", HomeView.as_view(), name="home", permissions=()),
        admin_url(r"^wizard/$",
                  WizardView.as_view(),
                  name="wizard",
                  permissions=()),
        admin_url(r"^tour/$", TourView.as_view(), name="tour", permissions=()),
        admin_url(r"^search/$",
                  SearchView.as_view(),
                  name="search",
                  permissions=()),
        admin_url(r"^select/$",
                  MultiselectAjaxView.as_view(),
                  name="select",
                  permissions=()),
        admin_url(r"^edit/$",
                  EditObjectView.as_view(),
                  name="edit",
                  permissions=()),
        admin_url(r"^menu/$", MenuView.as_view(), name="menu", permissions=()),
        admin_url(r"^toggle-menu/$",
                  MenuToggleView.as_view(),
                  name="menu_toggle",
                  permissions=()),
        admin_url(
            r"^stop-impersonating-staff/$",
            stop_impersonating_staff,
            name="stop-impersonating-staff",
            permissions=(),
        ),
        admin_url(
            r"^login/$",
            login,
            kwargs={"template_name": "shuup/admin/auth/login.jinja"},
            name="login",
            require_authentication=False,
            permissions=(),
        ),
        admin_url(r"^logout/$",
                  LogoutView,
                  name="logout",
                  require_authentication=False,
                  permissions=()),
        admin_url(
            r"^recover-password/(?P<uidb64>.+)/(?P<token>.+)/$",
            ResetPasswordView,
            name="recover_password",
            require_authentication=False,
            permissions=(),
        ),
        admin_url(
            r"^request-password/$",
            RequestPasswordView,
            name="request_password",
            require_authentication=False,
            permissions=(),
        ),
        admin_url(r"^set-language/$",
                  csrf_exempt(set_language),
                  name="set-language",
                  permissions=()),
    ])

    for u in urls:  # pragma: no cover
        if not isinstance(u, AdminRegexURLPattern):
            warnings.warn(
                "Warning! Admin URL %r is not an `AdminRegexURLPattern`." % u)

    # Add Django javascript catalog url
    urls.append(url(r"^i18n.js$", javascript_catalog_all, name="js-catalog"))

    return tuple(urls)