summaryrefslogtreecommitdiff
path: root/ishtar_common/views_item.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/views_item.py')
-rw-r--r--ishtar_common/views_item.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index c40b2c75f..b0ec0bdce 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -166,6 +166,35 @@ def new_item(model, frm, many=False):
return func
+def new_qa_item(model, frm, many=False):
+ def func(request, parent_name, limits=''):
+ template = "ishtar/forms/qa_new_item.html"
+ model_name = model._meta.object_name
+ if not check_permission(request, 'add_' + model_name.lower()):
+ not_permitted_msg = ugettext(u"Operation not permitted.")
+ return HttpResponse(not_permitted_msg)
+ dct = {'page_name': str(_(u'New %s' % model_name.lower())),
+ 'url': reverse("new-" + model.SLUG, args=[parent_name]),
+ 'slug': model.SLUG,
+ 'parent_name': parent_name,
+ 'many': many}
+ if request.method == 'POST':
+ dct['form'] = frm(request.POST, limits=limits)
+ if dct['form'].is_valid():
+ new_item = dct['form'].save(request.user)
+ dct['new_item_label'] = str(new_item)
+ dct['new_item_pk'] = new_item.pk
+ dct['parent_pk'] = parent_name
+ if dct['parent_pk'] and '_select_' in dct['parent_pk']:
+ parents = dct['parent_pk'].split('_')
+ dct['parent_pk'] = "_".join([parents[0]] + parents[2:])
+ return render(request, template, dct)
+ else:
+ dct['form'] = frm(limits=limits)
+ return render(request, template, dct)
+ return func
+
+
def display_item(model, extra_dct=None, show_url=None):
def func(request, pk, **dct):
if show_url: