diff options
Diffstat (limited to 'ishtar_common/views.py')
-rw-r--r-- | ishtar_common/views.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/ishtar_common/views.py b/ishtar_common/views.py index e49918d78..e8a7efb40 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -283,10 +283,18 @@ def shortcut_menu(request): if 'SHORTCUT_SHOW' in request.session else 'on' } + current_selected_labels = [] for lbl, model in CURRENT_ITEMS: model_name = model.SLUG current = model_name in request.session \ and request.session[model_name] + if current: + try: + item = model.objects.get(pk=int(current)) + item_label = shortify(unicode(item), 60) + current_selected_labels.append(item_label) + except model.DoesNotExist: + pass dct['menu'].append(( lbl, model_name, current or 0, JQueryAutoComplete( @@ -294,6 +302,7 @@ def shortcut_menu(request): model).render( model.SLUG + '-shortcut', value=current, attrs={'id': 'current_' + model.SLUG}))) + dct['current_selected_labels'] = current_selected_labels return render( request, 'ishtar/blocks/advanced_shortcut_menu.html', dct ) @@ -302,7 +311,9 @@ def shortcut_menu(request): 'SHORTCUT_SHOW': request.session['SHORTCUT_SHOW'] if 'SHORTCUT_SHOW' in request.session else 'off' } + current_selected_labels = [] current_selected_item = {} + labels = {} for lbl, model in CURRENT_ITEMS: new_selected_item = None model_name = model.SLUG @@ -310,6 +321,7 @@ def shortcut_menu(request): current = model_name in request.session and request.session[model_name] items = [] current_items = [] + labels[model_name] = {} for item, shortmenu_class in model.get_owns( request.user, menu_filtr=current_selected_item, limit=100, values=['id', 'cached_label'], get_short_menu_class=True): @@ -321,17 +333,21 @@ def shortcut_menu(request): continue current_items.append(pk) selected = pk == current + item_label = shortify(item['cached_label'], 60) if selected: cls = shortmenu_class new_selected_item = pk - items.append((pk, shortify(item['cached_label'], 60), + labels[model_name][str(pk)] = item_label + items.append((pk, item_label, selected, shortmenu_class)) # selected is not in owns - add it to the list if not new_selected_item and current: try: item = model.objects.get(pk=int(current)) new_selected_item = item.pk - items.append((item.pk, shortify(unicode(item), 60), + item_label = shortify(unicode(item), 60) + labels[model_name][str(item.pk)] = item_label + items.append((item.pk, item_label, True, item.get_short_menu_class(item.pk))) except (model.DoesNotExist, ValueError): pass @@ -339,6 +355,10 @@ def shortcut_menu(request): dct['current_menu'].append((lbl, model_name, cls, items)) if new_selected_item: current_selected_item[model_name] = new_selected_item + if str(new_selected_item) in labels[model_name]: + current_selected_labels.append( + labels[model_name][str(new_selected_item)]) + dct['current_selected_labels'] = current_selected_labels return render(request, 'ishtar/blocks/shortcut_menu.html', dct) |