1 from django.conf.urls.defaults import *
2 from madrona.common.utils import get_class
3 from madrona.features import registered_models, registered_links
4 from madrona.features import get_collection_models
5 from madrona.features import FeatureConfigurationError
6 import re
7
8 urlpatterns = []
9 for model in registered_models:
10 options = model.get_options()
11 urlpatterns += patterns('madrona.features.views',
12 url(r'^%s/form/$' % (options.slug,), 'form_resources',
13 kwargs={'model': model},
14 name="%s_create_form" % (options.slug, )),
15
16 url(r'^%s/(?P<uid>[\w_]+)/$' % (options.slug, ), 'resource',
17 kwargs={'model': model},
18 name='%s_resource' % (options.slug, )),
19
20 url(r'^%s/(?P<uid>[\w_]+)/form/$' % (options.slug, ),
21 'form_resources', kwargs={'model': model},
22 name='%s_update_form' % (options.slug,)),
23
24 url(r'^%s/(?P<uid>[\w_]+)/share/$' % (options.slug, ),
25 'share_form', kwargs={'model': model},
26 name='%s_share_form' % (options.slug,)),
27 )
28
29 for model in get_collection_models():
30 options = model.get_options()
31 urlpatterns += patterns('madrona.features.views',
32 url(r'^%s/(?P<collection_uid>[\w_]+)/remove/(?P<uids>[\w_,]+)$' % (options.slug, ),
33 'manage_collection', kwargs={'collection_model': model, 'action': 'remove'},
34 name='%s_remove_features' % (options.slug,)),
35
36 url(r'^%s/(?P<collection_uid>[\w_]+)/add/(?P<uids>[\w_,]+)$' % (options.slug, ),
37 'manage_collection', kwargs={'collection_model': model, 'action': 'add'},
38 name='%s_add_features' % (options.slug,)),
39 )
40
41 for link in registered_links:
42 path = r'^%s/links/%s/(?P<uids>[\w_,]+)/$' % (link.parent_slug, link.slug)
43 urlpatterns += patterns('madrona.features.views',
44 url(path, 'handle_link', kwargs={'link': link},
45 name=link.url_name)
46 )
47
48 urlpatterns += patterns('madrona.features.views',
49 url(r'^(?P<username>\w+)/workspace-owner.json', 'workspace', kwargs={"is_owner": True}, name='workspace-owner-json'),
50 url(r'^(?P<username>\w+)/workspace-shared.json', 'workspace', kwargs={"is_owner": False}, name='workspace-shared-json'),
51 url(r'^workspace-public.json', 'workspace', kwargs={"is_owner": False, "username": ''}, name='workspace-public-json'),
52 url(r'^feature_tree.css', 'feature_tree_css', name='feature-tree-css'),
53 )
54