don't fail on invalid arrays
This commit is contained in:
parent
54362e8b41
commit
c17cc6d5cf
1 changed files with 8 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -42,6 +43,7 @@ from user.utils import update_groups
|
||||||
from user.models import Group
|
from user.models import Group
|
||||||
import archive.models
|
import archive.models
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
|
@ -855,7 +857,7 @@ class Item(models.Model):
|
||||||
values = list(set(values))
|
values = list(set(values))
|
||||||
else:
|
else:
|
||||||
values = self.get(key, '')
|
values = self.get(key, '')
|
||||||
if isinstance(values, list):
|
if values and isinstance(values, list) and isinstance(values[0], str):
|
||||||
save(key, '\n'.join(values))
|
save(key, '\n'.join(values))
|
||||||
else:
|
else:
|
||||||
save(key, values)
|
save(key, values)
|
||||||
|
@ -1099,7 +1101,11 @@ class Item(models.Model):
|
||||||
_current_values.append(value[0])
|
_current_values.append(value[0])
|
||||||
current_values = _current_values
|
current_values = _current_values
|
||||||
|
|
||||||
current_values = list(set(current_values))
|
try:
|
||||||
|
current_values = list(set(current_values))
|
||||||
|
except:
|
||||||
|
logger.error('invalid facet data for %s: %s', key, current_values)
|
||||||
|
current_values = []
|
||||||
current_values = [ox.decode_html(ox.strip_tags(v)) for v in current_values]
|
current_values = [ox.decode_html(ox.strip_tags(v)) for v in current_values]
|
||||||
current_values = [unicodedata.normalize('NFKD', v) for v in current_values]
|
current_values = [unicodedata.normalize('NFKD', v) for v in current_values]
|
||||||
self.update_facet_values(key, current_values)
|
self.update_facet_values(key, current_values)
|
||||||
|
|
Loading…
Reference in a new issue