summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-06-07 16:52:02 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-06-12 10:46:13 +0200
commit8b3347dd635eef93e7af1a71c4183630277a7f5f (patch)
tree68d54bb40b2006fc2a3d5ae938108e9b950eca59 /ishtar_common/utils.py
parent07f24f648504004adbb57b16bd18fbd23a3c3998 (diff)
downloadIshtar-8b3347dd635eef93e7af1a71c4183630277a7f5f.tar.bz2
Ishtar-8b3347dd635eef93e7af1a71c4183630277a7f5f.zip
Document form: add related fields (refs #4107)
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