From 9c0ee6ee690f176dd6c944d263ec45678ebec49e Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 13 Sep 2019 14:13:46 +0200 Subject: Delete action: context records, files, finds, treatments, treatments files, admin acts --- ishtar_common/views.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'ishtar_common/views.py') diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 5a4abdc38..abd2b79d8 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -65,7 +65,7 @@ from ishtar_common.models import get_current_profile from ishtar_common.templatetags.link_to_window import simple_link_to_window from ishtar_common.utils import clean_session_cache, CSV_OPTIONS, \ get_field_labels_from_path, get_random_item_image_link, shortify, \ - dict_to_tuple + dict_to_tuple, put_session_message from ishtar_common.widgets import JQueryAutoComplete from .views_item import CURRENT_ITEM_KEYS, CURRENT_ITEM_KEYS_DICT, \ @@ -78,6 +78,25 @@ def status(request): return HttpResponse('OK') +def wizard_is_available(wizard, request, model, pk): + try: + wizard(request) + except IndexError: # no step available + put_session_message( + request.session.session_key, + _(u"You don't have sufficient permissions to do this action."), + 'warning' + ) + return + q = model.objects.filter(pk=pk) + if not q.count(): + raise Http404() + obj = q.all()[0] + if hasattr(obj, "locked") and obj.locked: + raise Http404() + return obj + + def tiny_redirect(request, url_id): db_id = models.TinyUrl.decode_id(url_id) link_db = get_object_or_404(models.TinyUrl, id=db_id) @@ -96,8 +115,8 @@ def index(request): profile = get_current_profile() if profile.slug == 'default': dct['warnings'].append(_( - u"The slug of your current profile is set to \"default\". Change it " - u"on the administration page (or ask your admin to do it).")) + "The slug of your current profile is set to \"default\". Change it " + "on the administration page (or ask your admin to do it).")) image = get_random_item_image_link(request) if hasattr(profile, 'homepage') and profile.homepage: dct['homepage'] = markdown(profile.homepage) -- cgit v1.2.3