Skip to content

Commit

Permalink
item_attrs: Refactor _get_annotation_assoc_class out of mixin into st…
Browse files Browse the repository at this point in the history
…andalone method.
  • Loading branch information
jmchilton committed Feb 11, 2019
1 parent 572d742 commit 79642f3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/galaxy/model/item_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_item_annotation_str(self, db_session, user, item):
def get_item_annotation_obj(self, db_session, user, item):
""" Returns a user's annotation object for an item. """
# Get annotation association class.
annotation_assoc_class = self._get_annotation_assoc_class(item)
annotation_assoc_class = _get_annotation_assoc_class(item)
if not annotation_assoc_class:
return None

Expand Down Expand Up @@ -133,7 +133,7 @@ def add_item_annotation(self, db_session, user, item, annotation):
# Get/create annotation association object.
annotation_assoc = self.get_item_annotation_obj(db_session, user, item)
if not annotation_assoc:
annotation_assoc_class = self._get_annotation_assoc_class(item)
annotation_assoc_class = _get_annotation_assoc_class(item)
if not annotation_assoc_class:
return None
annotation_assoc = annotation_assoc_class()
Expand All @@ -158,10 +158,11 @@ def copy_item_annotation(self, db_session, source_user, source_item, target_user
return annotation
return None

def _get_annotation_assoc_class(self, item):
""" Returns an item's item-annotation association class. """
class_name = '%sAnnotationAssociation' % item.__class__.__name__
return getattr(galaxy.model, class_name, None)

def _get_annotation_assoc_class(item):
""" Returns an item's item-annotation association class. """
class_name = '%sAnnotationAssociation' % item.__class__.__name__
return getattr(galaxy.model, class_name, None)


def get_foreign_key(source_class, target_class):
Expand Down

0 comments on commit 79642f3

Please sign in to comment.