1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/3de5356639ef/ Changeset: 3de5356639ef User: carlfeberhard Date: 2015-02-09 16:34:47+00:00 Summary: Managers, users: add tags_used and requests to user serializer to match info bootstrapped in galaxy.masthead.mako and galaxy_client_app.mako Affected #: 1 file diff -r 9903d71660073038dca04743c8b227bd1a9db5ff -r 3de5356639ef95ee8a6e9a16b56fe49c5f37f504 lib/galaxy/managers/users.py --- a/lib/galaxy/managers/users.py +++ b/lib/galaxy/managers/users.py @@ -199,6 +199,42 @@ #TODO: use quota manager return self.app.quota_agent.get_percent( user=user ) + def tags_used( self, trans, user, tag_models=None ): + """ + Return a list of distinct 'user_tname:user_value' strings that the + given user has used. + """ + #TODO: simplify and unify with tag manager + if self.is_anonymous( user ): + return [] + + # get all the taggable model TagAssociations + if not tag_models: + tag_models = [ v.tag_assoc_class for v in self.app.tag_handler.item_tag_assoc_info.values() ] + # create a union of subqueries for each for this user - getting only the tname and user_value + all_tags_query = None + for tag_model in tag_models: + subq = ( self.app.model.context.query( tag_model.user_tname, tag_model.user_value ) + .filter( tag_model.user == trans.user ) ) + all_tags_query = subq if all_tags_query is None else all_tags_query.union( subq ) + + # if nothing init'd the query, bail + if all_tags_query is None: + return [] + + # boil the tag tuples down into a sorted list of DISTINCT name:val strings + tags = all_tags_query.distinct().all() + tags = [( ( name + ':' + val ) if val else name ) for name, val in tags ] + return sorted( tags ) + + def has_requests( self, trans, user ): + """ + """ + if self.is_anonymous( user ): + return False + request_types = self.app.security_agent.get_accessible_request_types( trans, user ) + return ( user.requests or request_types ) + class UserSerializer( base.ModelSerializer, deletable.PurgableSerializerMixin ): @@ -214,21 +250,22 @@ 'id', 'email', 'username' ]) self.add_view( 'detailed', [ - 'update_time', - 'create_time', - - 'deleted', - 'purged', - 'active', + #'update_time', + #'create_time', 'total_disk_usage', 'nice_total_disk_usage', 'quota_percent' - # 'preferences', - # # all tags - # 'tags', - # # all annotations - # 'annotations' + + #'deleted', + #'purged', + #'active', + + #'preferences', + # all tags + 'tags_used', + ## all annotations + #'annotations' ], include_keys_from='summary' ) def add_serializers( self ): @@ -240,7 +277,13 @@ 'create_time' : self.serialize_date, 'update_time' : self.serialize_date, 'is_admin' : lambda t, i, k: self.user_manager.is_admin( t, i ), - 'quota_percent' : lambda t, i, k: self.user_manager.quota( t, i ) + + 'total_disk_usage' : lambda t, i, k: float( i.total_disk_usage ), + 'quota_percent' : lambda t, i, k: self.user_manager.quota( t, i ), + + 'tags_used' : lambda t, i, k: self.user_manager.tags_used( t, i ), + #TODO: 'has_requests' is more apt + 'requests' : lambda t, i, k: self.user_manager.has_requests( t, i ) }) def serialize_current_anonymous_user( self, trans, user, keys ): Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.