suport descriptions of array itemKeys, add description to studio, name
This commit is contained in:
parent
4d36b0ed16
commit
e76b620d73
2 changed files with 30 additions and 12 deletions
|
@ -204,6 +204,7 @@
|
||||||
"title": "Studio",
|
"title": "Studio",
|
||||||
"type": ["string"],
|
"type": ["string"],
|
||||||
"autocomplete": true,
|
"autocomplete": true,
|
||||||
|
"description": true,
|
||||||
"columnWidth": 180,
|
"columnWidth": 180,
|
||||||
"filter": true,
|
"filter": true,
|
||||||
"find": true,
|
"find": true,
|
||||||
|
@ -286,6 +287,7 @@
|
||||||
"title": "Name",
|
"title": "Name",
|
||||||
"type": ["string"],
|
"type": ["string"],
|
||||||
"autocomplete": true,
|
"autocomplete": true,
|
||||||
|
"description": true,
|
||||||
"find": true
|
"find": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -224,8 +224,14 @@ class Item(models.Model):
|
||||||
for k in keys:
|
for k in keys:
|
||||||
key = '%sdescription' % k
|
key = '%sdescription' % k
|
||||||
if key in data:
|
if key in data:
|
||||||
value = data.get(k, self.get(k, ''))
|
|
||||||
description = data.pop(key)
|
description = data.pop(key)
|
||||||
|
if isinstance(description, dict):
|
||||||
|
for value in description:
|
||||||
|
d, created = Description.objects.get_or_create(key=k, value=value)
|
||||||
|
d.description = ox.sanitize_html(description[value])
|
||||||
|
d.save()
|
||||||
|
else:
|
||||||
|
value = data.get(k, self.get(k, ''))
|
||||||
if not description:
|
if not description:
|
||||||
description = ''
|
description = ''
|
||||||
d, created = Description.objects.get_or_create(key=k, value=value)
|
d, created = Description.objects.get_or_create(key=k, value=value)
|
||||||
|
@ -573,12 +579,23 @@ class Item(models.Model):
|
||||||
if keys:
|
if keys:
|
||||||
dkeys = filter(lambda k: k in keys, dkeys)
|
dkeys = filter(lambda k: k in keys, dkeys)
|
||||||
for key in dkeys:
|
for key in dkeys:
|
||||||
qs = Description.objects.filter(key=key, value=self.get(key, ''))
|
k = filter(lambda i: i['id'] == key, settings.CONFIG['itemKeys'])
|
||||||
if qs.count() == 0:
|
if isinstance((k and k[0].get('type') or ''), list):
|
||||||
i['%sdescription'%key] = ''
|
i['%sdescription'%key] = {}
|
||||||
|
if key == 'name':
|
||||||
|
values = []
|
||||||
|
for ikey in filter(lambda i: i.get('sortType') == 'person',
|
||||||
|
settings.CONFIG['itemKeys']):
|
||||||
|
values += i.get(ikey['id'], [])
|
||||||
|
values = list(set(values))
|
||||||
else:
|
else:
|
||||||
i['%sdescription'%key] = qs[0].description
|
values = self.get(key)
|
||||||
|
if values:
|
||||||
|
for d in Description.objects.filter(key=key, value__in=values):
|
||||||
|
i['%sdescription'%key][d.value] = d.description
|
||||||
|
else:
|
||||||
|
qs = Description.objects.filter(key=key, value=self.get(key, ''))
|
||||||
|
i['%sdescription'%key] = '' if qs.count() == 0 else qs[0].description
|
||||||
if keys:
|
if keys:
|
||||||
info = {}
|
info = {}
|
||||||
for key in keys:
|
for key in keys:
|
||||||
|
@ -1434,4 +1451,3 @@ class Description(models.Model):
|
||||||
key = models.CharField(max_length=200, db_index=True)
|
key = models.CharField(max_length=200, db_index=True)
|
||||||
value = models.CharField(max_length=1000, db_index=True)
|
value = models.CharField(max_length=1000, db_index=True)
|
||||||
description = models.TextField()
|
description = models.TextField()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue