def setup_routes(config): """Function which will setup the routes of the ringo application""" # SINGLE PAGES ############## config.add_route('start_test_case', '_test_case/start') config.add_route('stop_test_case', '_test_case/stop') config.add_route('login', 'auth/login') config.add_route('register_user', 'auth/register_user') config.add_route('confirm_user', 'auth/confirm_user/{token}') config.add_route('forgot_password', 'auth/forgot_password') config.add_route('reset_password', 'auth/reset_password/{token}') config.add_route('logout', 'auth/logout') config.add_route('autologout', 'auth/autologout') config.add_route('accountdisabled', 'auth/disabled') config.add_route('version', 'version') config.add_route('contact', 'contact') config.add_route('about', 'about') config.add_route('home', '/') # Helpers ######### config.add_route('set_current_form_page', 'set_current_form_page') config.add_route('users-changepassword', 'users/changepassword/{id}', factory=get_resource_factory(User)) config.add_route('usergroups-setstandin', 'usergroups/setstandin/{id}', factory=get_resource_factory(Usergroup)) config.add_route('rules-evaluate', 'rest/rule/evaluate') config.add_route('form-render', 'rest/form/render') config.add_route('keepalive', 'rest/keepalive') return config
def includeme(config): # Now configure the application and optionally overwrite previously translators.append(TranslationStringFactory('plorma')) config.add_translation_dirs('plorma:locale/') config.add_static_view('plorma-static', path='plorma:static', cache_max_age=3600) config.add_route('renderburndown', 'sprints/burndown/{id}', factory=get_resource_factory(Sprint)) config.add_route(get_action_routename(Sprint, 'board'), 'sprintboard/{id}', factory=get_resource_factory(Sprint))
def _setup_rest_action(config, action, clazz, view_mapping): """Setup a route and a view for given action and clazz. The routes will have the follwoing following name and url: * Name: $modulname-$actionname * Url: $modulname/$actionurl Note, that the actionname can be configured only as admin. Further a clazz specific factory will be added to the route which is later used to setup the ACL of items of the modul. :config: Configuration :action: Action item :clazz: clazz item :view_mapping: Dictionary with action items :returns: @todo """ action_method_mapping = { "list": "GET", "create": "POST", "read": "GET", "update": "PUT", "delete": "DELETE" } name = clazz.__tablename__ action_name = action.name.lower() view_func = get_action_view(view_mapping, action_name, name) if not view_func: return route_name = get_action_routename(clazz, action_name, prefix="rest") tmpurl = action.url.split("/") if len(tmpurl) > 1: route_url = "rest/%s/%s" % (name, tmpurl[1]) else: route_url = "rest/%s" % (name) log.debug("Adding REST route: %s, %s" % (route_name, route_url)) method = action_method_mapping[action_name] config.add_route(route_name, route_url, request_method=method, factory=get_resource_factory(clazz)) log.debug("Adding REST view: %s, %s, %s" % (view_func, route_name, method)) settings = config.registry.settings http_cache = settings.get('security.page_http_cache', '0') config.add_view(view_func, route_name=route_name, request_method=method, renderer='json', permission=action.permission or action_name, http_cache=int(http_cache))
def includeme(config): # Now configure the application and optionally overwrite previously translators.append(TranslationStringFactory('trainable')) config.add_translation_dirs('trainable:locale/') config.add_static_view('trainable-static', path='trainable:static', cache_max_age=3600) config.add_route("syncstrava", "/strava/sync") config.add_route("authstrava", "/strava/authorisation") config.add_route("mapdata", "/activity/mapdata/{id}", factory=get_resource_factory(Activity))
def setup_routes(config): """Function which will setup the routes of the ringo application""" # SINGLE PAGES ############## config.add_route('start_test_case', '_test_case/start') config.add_route('stop_test_case', '_test_case/stop') config.add_route('login', 'auth/login') config.add_route('register_user', 'auth/register_user') config.add_route('confirm_user', 'auth/confirm_user/{token}') config.add_route('forgot_password', 'auth/forgot_password') config.add_route('reset_password', 'auth/reset_password/{token}') config.add_route('logout', 'auth/logout') config.add_route('autologout', 'auth/autologout') config.add_route('accountdisabled', 'auth/disabled') config.add_route('version', 'version') config.add_route('contact', 'contact') config.add_route('about', 'about') config.add_route('home', '/') # Helpers ######### config.add_route('set_current_form_page', 'set_current_form_page') config.add_route('users-changepassword', 'users/changepassword/{id}', factory=get_resource_factory(User)) config.add_route('users-removeaccount', 'users/removeaccount/{id}', factory=get_resource_factory(User)) config.add_route('users-accountremoved', 'users/accountremoved') config.add_route('usergroups-setstandin', 'usergroups/setstandin/{id}', factory=get_resource_factory(Usergroup)) config.add_route('rules-evaluate', 'rest/rule/evaluate') config.add_route('form-render', 'rest/form/render') config.add_route('keepalive', 'rest/keepalive') return config
def includeme(config): """Registers a new modul for ringo. :config: Dictionary with configuration of the new modul """ modul = register_modul(config, modul_config) News._modul_id = modul.get_value("id") translators.append(TranslationStringFactory('ringo_news')) config.add_translation_dirs('ringo_news:locale/') config.add_route(get_action_routename(News, 'markasread', prefix="rest"), 'rest/news/{id}/markasread', factory=get_resource_factory(News)) config.scan()
def _setup_web_action(config, action, clazz, view_mapping): """Setup a route and a view for given action and clazz. The routes will have the follwoing following name and url: * Name: $modulname-$actionname * Url: $modulname/$actionurl Note, that the actionname can be configured only as admin. Further a clazz specific factory will be added to the route which is later used to setup the ACL of items of the modul. :config: Configuration :action: Action item :clazz: clazz item :view_mapping: Dictionary with action items :returns: @todo """ name = clazz.__tablename__ action_name = action.name.lower() route_name = get_action_routename(clazz, action_name) route_url = "%s/%s" % (name, action.url) log.debug("Adding WEB route: %s, %s" % (route_name, route_url)) config.add_route(route_name, route_url, factory=get_resource_factory(clazz)) settings = config.registry.settings http_cache = settings.get('security.page_http_cache', '0') view_func = get_action_view(view_mapping, action_name, name) if view_func: if action_name == "delete": template = "confirm" renderer = '/default/%s.mako' % template elif action_name == "download": renderer = None else: template = action_name renderer = '/default/%s.mako' % template config.add_view(view_func, route_name=route_name, renderer=renderer, permission=action.permission or action_name, http_cache=int(http_cache)) ## Add bundle action. if action_name == "list": action_name = "bundle" route_name = "%s-%s" % (name, action_name) route_url = "%s/%s" % (name, action_name) view_func = get_action_view(view_mapping, action_name, name) log.debug("Adding route: %s, %s" % (route_name, route_url)) config.add_route(route_name, route_url, factory=get_resource_factory(clazz)) config.add_view(view_func, route_name=route_name, renderer='/default/bundle.mako', permission='list') ## Add permission action. if action_name == "read": action_name = "ownership" route_name = "%s-%s" % (name, action_name) route_url = "%s/%s/{id}" % (name, action_name) view_func = get_action_view(view_mapping, action_name, name) log.debug("Adding route: %s, %s" % (route_name, route_url)) config.add_route(route_name, route_url, factory=get_resource_factory(clazz)) config.add_view(view_func, route_name=route_name, renderer='/default/update.mako', permission='read')