avoid ['']
This commit is contained in:
parent
0bb44fc4ef
commit
1efe02c87c
2 changed files with 9 additions and 2 deletions
|
@ -251,7 +251,7 @@ def findMetadata(data):
|
||||||
j = items[m.data_hash]
|
j = items[m.data_hash]
|
||||||
for key in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]:
|
for key in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]:
|
||||||
if key in j and not isinstance(j[key], list):
|
if key in j and not isinstance(j[key], list):
|
||||||
j[key] = [j[key]]
|
j[key] = [j[key]] if j[key] else []
|
||||||
else:
|
else:
|
||||||
items[m.data_hash]['users'].append(m.user_id)
|
items[m.data_hash]['users'].append(m.user_id)
|
||||||
response['items'] = list(items.values())
|
response['items'] = list(items.values())
|
||||||
|
@ -279,7 +279,7 @@ def getMetadata(data):
|
||||||
response.update(models.Metadata.load(key, value))
|
response.update(models.Metadata.load(key, value))
|
||||||
for key in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]:
|
for key in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]:
|
||||||
if key in response and not isinstance(response[key], list):
|
if key in response and not isinstance(response[key], list):
|
||||||
response[key] = [response[key]]
|
response[key] = [response[key]] if response[key] else []
|
||||||
return response
|
return response
|
||||||
actions.register(getMetadata)
|
actions.register(getMetadata)
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ from . import txt
|
||||||
from . import opf
|
from . import opf
|
||||||
|
|
||||||
from meta.utils import decode_html_data, to_isbn13
|
from meta.utils import decode_html_data, to_isbn13
|
||||||
|
import settings
|
||||||
|
|
||||||
def get_id(f=None, data=None):
|
def get_id(f=None, data=None):
|
||||||
if data:
|
if data:
|
||||||
|
@ -106,5 +107,11 @@ def metadata(f, from_=None):
|
||||||
if not data['title'].strip():
|
if not data['title'].strip():
|
||||||
del data['title']
|
del data['title']
|
||||||
data = decode_html_data(data)
|
data = decode_html_data(data)
|
||||||
|
for key in list(data):
|
||||||
|
if not data[key]:
|
||||||
|
del data[key]
|
||||||
|
for key in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]:
|
||||||
|
if key in data and not isinstance(data[key], list):
|
||||||
|
data[key] = [data[key]] if data[key] else []
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue