diff options
Diffstat (limited to 'ishtar_common/views.py')
| -rw-r--r-- | ishtar_common/views.py | 28 | 
1 files changed, 16 insertions, 12 deletions
| diff --git a/ishtar_common/views.py b/ishtar_common/views.py index b0817fc59..dbbc3d538 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -256,7 +256,6 @@ def shortcut_menu(request):              model_name = model.SLUG              current = model_name in request.session \                  and request.session[model_name] -              dct['menu'].append((                  lbl, model_name, current or 0,                  JQueryAutoComplete( @@ -275,23 +274,28 @@ def shortcut_menu(request):          cls = ''          current = model_name in request.session and request.session[model_name]          items = [] -        for item in model.get_owns(request.user, -                                   menu_filtr=current_selected_item, -                                   limit=100): -            pk = unicode(item.pk) -            if item.IS_BASKET: +        current_items = [] +        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): +            pk = unicode(item['id']) +            if shortmenu_class == 'basket':                  pk = "basket-" + pk +            # prevent duplicates +            if pk in current_items: +                continue +            current_items.append(pk)              selected = pk == current              if selected: -                cls = item.get_short_menu_class() -                new_selected_item = item -            items.append((pk, shortify(unicode(item), 60), -                          selected, item.get_short_menu_class())) +                cls = shortmenu_class +                new_selected_item = pk +            items.append((pk, shortify(item['cached_label'], 60), +                          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 +                new_selected_item = item.pk                  items.append((item.pk, shortify(unicode(item), 60),                                True, item.get_short_menu_class()))              except (model.DoesNotExist, ValueError): @@ -323,7 +327,7 @@ def get_current_items(request):  def unpin(request, item_type):      if item_type not in ('find', 'contextrecord', 'operation', 'file', -                          'treatment', 'treatmentfile'): +                         'treatment', 'treatmentfile'):          logger.warning("unpin unknow type: {}".format(item_type))          return HttpResponse('nok')      request.session['treatment'] = '' | 
