Handle empty attachments (no slug nor oid) and reject duplicate slugs
This commit is contained in:
parent
2a5b3dc53e
commit
90c6fdc377
@ -132,7 +132,18 @@ def attachment_form_group_set_data(db_prop_value, schema_prop, field_list):
|
|||||||
def attachment_form_parse_post_data(data):
|
def attachment_form_parse_post_data(data):
|
||||||
"""Returns a dict that can be stored in the node.properties.attachments."""
|
"""Returns a dict that can be stored in the node.properties.attachments."""
|
||||||
|
|
||||||
# Moar ugly hardcodedness.
|
attachments = {}
|
||||||
attachments = {allprops['slug']: {'oid': allprops['oid']}
|
|
||||||
for allprops in data}
|
# 'allprops' contains all properties, including the slug (which should be a key).
|
||||||
|
for allprops in data:
|
||||||
|
oid = allprops['oid']
|
||||||
|
slug = allprops['slug']
|
||||||
|
|
||||||
|
if not allprops['slug'] and not oid:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if slug in attachments:
|
||||||
|
raise ValueError('Slug "%s" is used more than once' % slug)
|
||||||
|
attachments[slug] = {'oid': oid}
|
||||||
|
|
||||||
return attachments
|
return attachments
|
||||||
|
Loading…
x
Reference in New Issue
Block a user