diff options
| -rw-r--r-- | ishtar_common/forms_common.py | 9 | ||||
| -rw-r--r-- | ishtar_common/migrations/0042_auto_20180409_1901.py | 8 | ||||
| -rw-r--r-- | ishtar_common/models.py | 2 | ||||
| -rw-r--r-- | ishtar_common/utils.py | 9 | 
4 files changed, 16 insertions, 12 deletions
| diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 5b4566a31..af16e6deb 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -43,7 +43,7 @@ from ishtar_common.templatetags.link_to_window import link_to_window  from forms import FinalForm, FormSet, reverse_lazy, name_validator, \      TableSelect, ManageOldType, CustomForm, FieldType, \      FormSetWithDeleteSwitches, IshtarForm, get_data_from_formset -from ishtar_common.utils import is_downloadable +from ishtar_common.utils import is_downloadable, clean_session_cache  def get_town_field(label=_(u"Town"), required=True): @@ -829,12 +829,7 @@ class ProfilePersonForm(forms.Form):          profile.current = True          profile.save() -        # clean session cache -        cache_key_list = 'sessionlist-{}'.format(session.session_key) -        key_list = cache.get(cache_key_list, []) -        for key in key_list: -            cache.set(key, None, settings.CACHE_TIMEOUT) -        cache.set(cache_key_list, [], settings.CACHE_TIMEOUT) +        clean_session_cache(session)  class TownForm(forms.Form): diff --git a/ishtar_common/migrations/0042_auto_20180409_1901.py b/ishtar_common/migrations/0042_auto_20180409_1901.py index a2faa24e4..0b377b9d8 100644 --- a/ishtar_common/migrations/0042_auto_20180409_1901.py +++ b/ishtar_common/migrations/0042_auto_20180409_1901.py @@ -29,10 +29,10 @@ def initialize_profiles(apps, schema_editor):      # match profile type with person types      for person in Person.objects.filter(ishtaruser__isnull=False): -        # is current if only one person_type is concerned -        current = person.person_types.count() == 1 -        # only person with an account are concerned -        for person_type in person.person_types.all(): +        # order by txt_idx in order to put administrator first +        for idx, person_type in enumerate( +                person.person_types.order_by('txt_idx').all()): +            current = not(idx)  # first is current              UserProfile.objects.create(                  profile_type=profile_types[person_type.txt_idx],                  person=person, diff --git a/ishtar_common/models.py b/ishtar_common/models.py index e4c6d0e9a..a5bf6cf3a 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2680,7 +2680,7 @@ class Person(Address, Merge, OwnPerms, ValueGetter):              res = cache.get(cache_key)              if res in (True, False):                  return res -            # list all cache key in order to clean them on profiel change +            # list all cache key in order to clean them on profile change              cache_key_list = 'sessionlist-{}'.format(session.session_key)              key_list = cache.get(cache_key_list, [])              key_list.append(cache_key) diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index b2ba2bc24..fa98549ba 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -425,6 +425,15 @@ def get_session_var(session_key, key):      return session[key] +def clean_session_cache(session): +    # clean session cache +    cache_key_list = 'sessionlist-{}'.format(session.session_key) +    key_list = cache.get(cache_key_list, []) +    for key in key_list: +        cache.set(key, None, settings.CACHE_TIMEOUT) +    cache.set(cache_key_list, [], settings.CACHE_TIMEOUT) + +  def get_field_labels_from_path(model, path):      """      :param model: base model | 
