summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 443a22111..b089ddcee 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -791,7 +791,7 @@ def create_default_json_fields(model):
)
-def get_urls_for_model(model, views):
+def get_urls_for_model(model, views, own=False, autocomplete=False):
"""
Generate get and show url for a model
"""
@@ -804,9 +804,28 @@ def get_urls_for_model(model, views):
check_rights(['view_' + model.SLUG, 'view_own_' + model.SLUG])(
getattr(views, 'display_' + model.SLUG)),
name='display-' + model.SLUG),
+ ]
+ if own:
+ urls += [
+ url(r'get-{}/own/(?P<type>.+)?$'.format(model.SLUG),
+ check_rights(['view_' + model.SLUG, 'view_own_' + model.SLUG])(
+ getattr(views, 'get_' + model.SLUG)),
+ name="get-own-" + model.SLUG, kwargs={'force_own': True}),
+ ]
+
+ urls += [
url(r'get-{}/(?P<type>.+)?$'.format(model.SLUG),
check_rights(['view_' + model.SLUG, 'view_own_' + model.SLUG])(
getattr(views, 'get_' + model.SLUG)),
name="get-" + model.SLUG),
]
+
+ if autocomplete:
+ urls += [
+ url(r'autocomplete-{}/$'.format(model.SLUG),
+ check_rights(['view_' + model.SLUG, 'view_own_' + model.SLUG])(
+ getattr(views, 'autocomplete_' + model.SLUG)),
+ name='autocomplete-' + model.SLUG),
+ ]
+
return urls