diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/context_processors.py | 14 | ||||
| -rw-r--r-- | ishtar_common/models.py | 7 | ||||
| -rw-r--r-- | ishtar_common/static/js/ishtar.js | 3 | ||||
| -rw-r--r-- | ishtar_common/static/media/style.css | 14 | ||||
| -rw-r--r-- | ishtar_common/templates/base.html | 8 | ||||
| -rw-r--r-- | ishtar_common/utils.py | 17 | 
6 files changed, 53 insertions, 10 deletions
diff --git a/ishtar_common/context_processors.py b/ishtar_common/context_processors.py index 293a5ad44..e3b14cdda 100644 --- a/ishtar_common/context_processors.py +++ b/ishtar_common/context_processors.py @@ -44,7 +44,7 @@ def get_base_context(request):      dct = {'URL_PATH':settings.URL_PATH}      dct["APP_NAME"] = Site.objects.get_current().name      dct["COUNTRY"] = settings.COUNTRY -    """  +    """      if 'MENU' not in request.session or \         request.session['MENU'].user != request.user:          menu = Menu(request.user) @@ -66,13 +66,17 @@ def get_base_context(request):      dct['current_menu'] = []      for lbl, model in CURRENT_ITEMS:          model_name = model.__name__.lower() +        cls = ''          current = model_name in request.session and request.session[model_name]          items = [] -        for item in sorted(model.get_owns(request.user), -                           key=lambda x:x.cached_label): +        for item in model.get_owns(request.user): +            selected = unicode(item.pk) == current +            if selected: +                cls = item.get_short_menu_class()              items.append((item.pk, shortify(unicode(item), 60), -                          unicode(item.pk) == current)) +                          selected, +                          item.get_short_menu_class()))          if items: -            dct['current_menu'].append((lbl, model_name, items)) +            dct['current_menu'].append((lbl, model_name, cls, items))      return dct diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 3c33928a9..9eba9ccd0 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -193,7 +193,7 @@ class OwnPerms:          query = cls.get_query_owns(user)          if not query:              return [] -        return cls.objects.filter(query).order_by(*cls._meta.ordering).all() +        return cls.objects.filter(query).order_by(*cls._meta.ordering)  class GeneralType(models.Model):      """ @@ -518,6 +518,11 @@ class BaseHistorizedItem(models.Model):              items.append('00000000')          return u"-".join([unicode(item) for item in items]) + +class ShortMenuItem(object): +    def get_short_menu_class(self): +        return '' +  class LightHistorizedItem(BaseHistorizedItem):      history_date = models.DateTimeField(default=datetime.datetime.now)      class Meta: diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 0a15bfc23..b91558194 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -51,6 +51,9 @@ $(document).ready(function(){      if ($.isFunction($(".prettyPhoto a").prettyPhoto)){          $(".prettyPhoto a").prettyPhoto({'social_tools':''});      } +    $('#current_items select').change(function(){ +        $(this).attr('class', $(this).children("option:selected").attr('class')); +    })  });  $('#to_bottom_arrow').live('click', function(){ diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 5a7de3694..8722b5d05 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -17,9 +17,11 @@ div.form {  }  /* color  */ +#context_menu .red,  a, a.remove {      color:#D14;  } +  a.add-button{      color:#61615C;  } @@ -28,6 +30,18 @@ a.add-button{      color:#fff;  } +#context_menu .orange { +    color:#dd6011; +} + +#context_menu .green { +    color:#13ae0c; +} + +#context_menu .normal{ +    color:#000; +} +  /* borders */  a.add-button, a.remove,  #progress-content, diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index cea906f26..bfacee069 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -63,13 +63,13 @@          <fieldset>          <legend>{% trans "Default selected items"%}</legend>          <table id='current_items'> -        {% for lbl, model_name, items in current_menu %} +        {% for lbl, model_name, main_cls, items in current_menu %}              <tr>                  <td><label for="current_{{model_name}}">{{lbl}}</label></td>                  <td> -                  <select id='current_{{model_name}}'> -                    <option value=''>--</option> -                    {% for val, label, selected in items %}<option value='{{val}}'{%if selected%} selected="selected"{%endif%}>{{label}}</option> +                  <select class='{{main_cls}}' id='current_{{model_name}}'> +                    <option class='normal' value=''>--</option> +                    {% for val, label, selected, cls in items %}<option class='{{cls}}' value='{{val}}'{%if selected%} selected="selected"{%endif%}>{{label}}</option>                    {% endfor %}</select>                  </td>{% with 'show-'|add:model_name as model_url%}                  <td><a href='#' onclick='load_current_window("{% url model_url 0 %}", "{{model_name}}");' class='display_details'>{% trans "Details" %}</a></td> diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index d5fc37276..f50031d5d 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -17,7 +17,24 @@  # See the file COPYING for details. +from django.core.cache import cache  from django.utils.translation import ugettext +from django.template.defaultfilters import slugify + +def get_cache(cls, extra_args=[]): +    cache_key = cls.__name__ +    for arg in extra_args: +        if not arg: +            cache_key += '-0' +        else: +            if type(arg) == dict: +                cache_key += '-' + "_".join([unicode(arg[k]) for k in arg]) +            elif type(arg) in (list, tuple): +                cache_key += '-' + "_".join([unicode(v) for v in arg]) +            else: +                cache_key += '-' + unicode(arg) +    cache_key = slugify(cache_key) +    return cache_key, cache.get(cache_key)  def cached_label_changed(sender, **kwargs):      if not kwargs.get('instance'):  | 
