Commit 634720863276261f604ca0f9ece1f68375bb8cb4
1 parent
0ee7be00
poprawiony spowalniający błąd przy zapisywaniu leksemu
Showing
2 changed files
with
10 additions
and
10 deletions
dictionary/ajax_lexeme_slickgrid.py
... | ... | @@ -137,10 +137,11 @@ class LexemeQuery(SlickGridQuery): |
137 | 137 | key += vocabulary.id |
138 | 138 | return md5(key).hexdigest() |
139 | 139 | |
140 | - def get_cached_lexemes(self): | |
140 | + def get_cached_lexemes(self, refresh=True): | |
141 | 141 | key = self.cache_key() |
142 | 142 | cached = cache.get(key) |
143 | - cache.set(key, cached) | |
143 | + if refresh: | |
144 | + cache.set(key, cached) | |
144 | 145 | return cached |
145 | 146 | |
146 | 147 | def cache_lexemes(self, id_list): |
... | ... | @@ -151,9 +152,9 @@ class LexemeQuery(SlickGridQuery): |
151 | 152 | key_list.append(key) |
152 | 153 | cache.set('key_list', key_list) |
153 | 154 | |
154 | - def get_id_list(self, force_reload=False): | |
155 | + def get_id_list(self, force_reload=False, refresh=True): | |
155 | 156 | if not force_reload: |
156 | - id_list = self.get_cached_lexemes() | |
157 | + id_list = self.get_cached_lexemes(refresh=refresh) | |
157 | 158 | else: |
158 | 159 | id_list = None |
159 | 160 | if id_list is None: |
... | ... |
dictionary/ajax_lexeme_view.py
... | ... | @@ -347,7 +347,7 @@ def update_lexeme(request, form_data): |
347 | 347 | if attr_form.is_valid(): |
348 | 348 | if not attr.closed: |
349 | 349 | value = attr_form.cleaned_data['value'] |
350 | - av, new_lexeme = LexemeAttributeValue.objects.get_or_create( | |
350 | + av, created = LexemeAttributeValue.objects.get_or_create( | |
351 | 351 | attribute=attr, value=value) |
352 | 352 | else: |
353 | 353 | av = attr_form.cleaned_data['value'] |
... | ... | @@ -381,12 +381,11 @@ def update_lexeme(request, form_data): |
381 | 381 | query = LexemeQuery( |
382 | 382 | filter=request.session['filter'], sort_rules=sort_rules, |
383 | 383 | user=request.user) |
384 | + id_list = query.get_id_list() | |
385 | + index = bisect_left(id_list, l.entry, cmp=query.lexeme_cmp()) | |
386 | + id_list.insert(index, l.id) | |
384 | 387 | key = query.cache_key() |
385 | - id_list = cache.get(key) | |
386 | - if id_list: | |
387 | - index = bisect_left(id_list, l.entry, cmp=query.lexeme_cmp()) | |
388 | - id_list = id_list.insert(index, l.id) | |
389 | - cache.set(key, id_list) | |
388 | + cache.set(key, id_list) | |
390 | 389 | return {} |
391 | 390 | |
392 | 391 | |
... | ... |