diff options
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 |
commit | 875462381bc57b13a8ca6b68a52ad1ca065ef95e (patch) | |
tree | 68d54bb40b2006fc2a3d5ae938108e9b950eca59 /ishtar_common/utils.py | |
parent | fdd0231543be132b846e3bf12127cd01860f55bf (diff) | |
download | Ishtar-875462381bc57b13a8ca6b68a52ad1ca065ef95e.tar.bz2 Ishtar-875462381bc57b13a8ca6b68a52ad1ca065ef95e.zip |
Document form: add related fields (refs #4107)
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 21 |
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 |