def test_translated(self, client, root): """ /a can point to either dutch or english content on different nodes """ n1 = root.add(langslugs=dict(nl="a", en="b")) n2 = root.add(langslugs=dict(en="a", nl="b")) translation.activate('nl') res = MainHandler.resolve("a") assert res == n1 translation.activate('en') res = MainHandler.resolve("a") assert res == n2
def setup_handler(self, user=None, method="GET", with_instance=False, state="private"): """ setup the mainhandler """ root = Node.root() if with_instance: cont = Type1Type.create(node=root, state=state).save() cont.assign_perms() request = create_request(method, "/", data={'type':Type1.get_name()}) if self.provide_user(): request.user = self.provide_user() handler = MainHandler() handler.init_from_request(request) handler.instance = root return handler
def test_handler_create(self, superuser, client): """ The handler *can* set the user """ request = create_request("POST", "/create", data=dict(title="Test", slug="test", language="en", type=Type1.get_name())) request.user = superuser handler = MainHandler() res = handler.dispatch(request, nodepath="", handlerpath="create") assert res.status_code == 302 node = Node.get("/test") assert node.content().title == "Test" assert node.content().owner == superuser
def test_translated(self, client): """ /a can point to either dutch or english content on different nodes """ root = Node.root() n1 = root.add(langslugs=dict(nl="a", en="b")) n2 = root.add(langslugs=dict(en="a", nl="b")) from django.utils import translation translation.activate('nl') res = MainHandler.coerce(dict(instance="a")) assert res['instance'] == n1 translation.activate('en') res = MainHandler.coerce(dict(instance="a")) assert res['instance'] == n2
def test_coerce_parent(self, client): """ coerce a dict holding an parent path """ root = Node.root() a = root.add("a") res = MainHandler.coerce(dict(parent="a")) assert 'parent' in res assert res['parent'] == a assert 'instance' not in res
def test_coerce_instance_parent(self, client): """ coerce a dict holding both instance and parent """ root = Node.root() a = root.add("a") b = a.add("b") res = MainHandler.coerce(dict(instance="b", parent="a")) assert 'instance' in res assert 'parent' in res assert res['instance'] == b assert res['parent'] == a
from wheelcms_axle.userena_custom import UserenaDetailsFormExtra handler500 = wheel_500 handler404 = wheel_404 urlpatterns = patterns('', (r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': dict(default=ContentSitemap())}), (r'^robots\.txt$', 'wheelcms_axle.robots.robots_txt'), url(r'^accounts/(?P<username>[\.\w-]+)/edit/$', 'userena.views.profile_edit', name='userena_profile_edit', kwargs={'edit_profile_form': UserenaDetailsFormExtra}), (r'^accounts/', include('userena.urls')), ) main_actions = "({0})".format("|".join(MainHandler.url_actions())) urlpatterns += patterns('', url("@/search", SearchHandler.as_view(), name="haystack_search"), ## Special url for configuration; issue #553 url("@/configuration", ConfigurationHandler.as_view(), name="wheel_config"), ## nodepath with optional action. Should have higher precedence, ## else next entry will match as nodepath url("^(?P<nodepath>.*?)/(\+(?P<action>.+))?$", MainHandler.as_view(), name="wheel_main"), ## nodepath with optional handler url("^(?P<nodepath>.*?)/((?P<handlerpath>{0}))?$".format(main_actions), MainHandler.as_view(), name="wheel_main"),