Managers: bit of cleanup for 05a3d04b

This commit is contained in:
carlfeberhard
2016-02-08 11:25:32 -05:00
parent 05a3d04b60
commit d07677bba1
6 changed files with 18 additions and 7 deletions
+3
View File
@@ -504,6 +504,8 @@ class HasAModelManager( object ):
#: the class used to create this serializer's generically accessible model_manager
model_manager_class = None
# examples where this doesn't really work are ConfigurationSerializer (no manager)
# and contents (2 managers)
def __init__( self, app, manager=None, **kwargs ):
self._manager = manager
@@ -515,6 +517,7 @@ class HasAModelManager( object ):
if not self._manager:
# TODO: pass this serializer to it
self._manager = self.model_manager_class( self.app )
# this will error for unset model_manager_class'es
return self._manager
+2 -1
View File
@@ -16,6 +16,7 @@ log = logging.getLogger( __name__ )
# TODO: for lack of a manager file for the config. May well be better in config.py? Circ imports?
class ConfigSerializer( base.ModelSerializer ):
"""Configuration (galaxy.ini) settings viewable by all users"""
def __init__( self, app ):
super( ConfigSerializer, self ).__init__( app )
@@ -75,7 +76,7 @@ class ConfigSerializer( base.ModelSerializer ):
class AdminConfigSerializer( ConfigSerializer ):
# config attributes viewable by admin users
"""Configuration attributes viewable only by admin users"""
def add_serializers( self ):
super( AdminConfigSerializer, self ).add_serializers()
+4 -1
View File
@@ -133,10 +133,11 @@ class DatasetRBACPermissions( object ):
class DatasetSerializer( base.ModelSerializer, deletable.PurgableSerializerMixin ):
model_manager_class = DatasetManager
def __init__( self, app ):
super( DatasetSerializer, self ).__init__( app )
self.dataset_manager = DatasetManager( app )
self.dataset_manager = self.manager
# needed for admin test
self.user_manager = users.UserManager( app )
@@ -274,6 +275,8 @@ class DatasetAssociationManager( base.ModelManager,
# Instead, a dataset association HAS a dataset but contains metadata specific to a library (lda) or user (hda)
model_class = model.DatasetInstance
# NOTE: model_manager_class should be set in HDA/LDA subclasses
def __init__( self, app ):
super( DatasetAssociationManager, self ).__init__( app )
self.dataset_manager = DatasetManager( app )
+3 -3
View File
@@ -243,12 +243,11 @@ class HDASerializer( # datasets._UnflattenedMetadataDatasetAssociationSerialize
datasets.DatasetAssociationSerializer,
taggable.TaggableSerializerMixin,
annotatable.AnnotatableSerializerMixin ):
# TODO: inherit from datasets.DatasetAssociationSerializer
# TODO: move what makes sense into DatasetSerializer
model_manager_class = HDAManager
def __init__( self, app ):
super( HDASerializer, self ).__init__( app )
self.hda_manager = HDAManager( app )
self.hda_manager = self.manager
self.default_view = 'summary'
self.add_view( 'summary', [
@@ -463,6 +462,7 @@ class HDADeserializer( datasets.DatasetAssociationDeserializer,
class HDAFilterParser( datasets.DatasetAssociationFilterParser,
taggable.TaggableFilterMixin,
annotatable.AnnotatableFilterMixin ):
model_manager_class = HDAManager
model_class = model.HistoryDatasetAssociation
def _add_parsers( self ):
+4 -1
View File
@@ -239,13 +239,14 @@ class UserManager( base.ModelManager, deletable.PurgableManagerMixin ):
class UserSerializer( base.ModelSerializer, deletable.PurgableSerializerMixin ):
model_manager_class = UserManager
def __init__( self, app ):
"""
Convert a User and associated data to a dictionary representation.
"""
super( UserSerializer, self ).__init__( app )
self.user_manager = UserManager( app )
self.user_manager = self.manager
self.default_view = 'summary'
self.add_view( 'summary', [
@@ -288,6 +289,7 @@ class UserSerializer( base.ModelSerializer, deletable.PurgableSerializerMixin ):
class CurrentUserSerializer( UserSerializer ):
model_manager_class = UserManager
def serialize( self, user, keys, **kwargs ):
"""
@@ -324,6 +326,7 @@ class CurrentUserSerializer( UserSerializer ):
class AdminUserFilterParser( base.ModelFilterParser, deletable.PurgableFiltersMixin ):
model_manager_class = UserManager
model_class = model.User
def _add_parsers( self ):
+2 -1
View File
@@ -42,11 +42,12 @@ class VisualizationSerializer( sharable.SharableModelSerializer ):
"""
Interface/service object for serializing visualizations into dictionaries.
"""
model_manager_class = VisualizationManager
SINGLE_CHAR_ABBR = 'v'
def __init__( self, app ):
super( VisualizationSerializer, self ).__init__( app )
self.visualizations_manager = VisualizationManager( app )
self.visualization_manager = self.manager
self.default_view = 'summary'
self.add_view( 'summary', [] )