Merge "Use plural for class_definition"

This commit is contained in:
Jenkins 2014-04-10 12:09:22 +00:00 committed by Gerrit Code Review
commit c04cad9a3c
3 changed files with 6 additions and 5 deletions

View File

@ -28,7 +28,7 @@ PKG_PARAMS_MAP = {'display_name': 'name',
'package_type': 'type',
'description': 'description',
'author': 'author',
'classes': 'class_definition'}
'classes': 'class_definitions'}
def get_draft(environment_id=None, session_id=None):

View File

@ -280,7 +280,7 @@ def package_search(filters, context):
if 'search' in filters.keys():
fk_fields = {'categories': 'Category',
'tags': 'Tag',
'class_definition': 'Class'}
'class_definitions': 'Class'}
conditions = []
for attr in dir(pkg):
@ -357,7 +357,7 @@ def package_upload(values, tenant_id):
composite_attr_to_func = {'categories': _get_categories,
'tags': _get_tags,
'class_definition': _get_class_definitions}
'class_definitions': _get_class_definitions}
with session.begin():
for attr, func in composite_attr_to_func.iteritems():
if values.get(attr):

View File

@ -281,7 +281,8 @@ class Package(BASE, ModificationsTrackedObject):
secondary=package_to_category,
cascade='save-update, merge',
lazy='joined')
class_definition = sa_orm.relationship("Class", lazy='joined')
class_definitions = sa_orm.relationship(
"Class", cascade='save-update, merge, delete', lazy='joined')
def to_dict(self):
d = self.__dict__.copy()
@ -289,7 +290,7 @@ class Package(BASE, ModificationsTrackedObject):
'archive',
'logo',
'ui_definition']
nested_objects = ['categories', 'tags', 'class_definition']
nested_objects = ['categories', 'tags', 'class_definitions']
for key in not_serializable:
if key in d.keys():
del d[key]