4 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/934fe4d500ec/ Changeset: 934fe4d500ec Branch: page-api User: Kyle Ellrott Date: 2013-11-21 22:50:59 Summary: Adding page search to the search API. Also adding plural id encoding (a list named '*_ids' will get id encoded) Affected #: 3 files diff -r 253f888144aaa4ae4eadaf15de493b3144fc5cd3 -r 934fe4d500ec7fba8d41c634eb70dc0381dee41c lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -3140,7 +3140,8 @@ self.session = session self.openid = openid -class Page( object ): +class Page( object, Dictifiable ): + dict_element_visible_keys = [ 'id', 'title', 'latest_revision_id', 'slug' ] def __init__( self ): self.id = None self.user = None @@ -3151,6 +3152,14 @@ self.importable = None self.published = None + def to_dict( self, view='element' ): + rval = super( Page, self ).to_dict( view=view ) + rev = [] + for a in self.revisions: + rev.append(a.id) + rval['revision_ids'] = rev + return rval + class PageRevision( object ): def __init__( self ): self.user = None diff -r 253f888144aaa4ae4eadaf15de493b3144fc5cd3 -r 934fe4d500ec7fba8d41c634eb70dc0381dee41c lib/galaxy/model/search.py --- a/lib/galaxy/model/search.py +++ b/lib/galaxy/model/search.py @@ -35,7 +35,8 @@ History, Library, LibraryFolder, LibraryDataset,StoredWorkflowTagAssociation, StoredWorkflow, HistoryTagAssociation,HistoryDatasetAssociationTagAssociation, ExtendedMetadata, ExtendedMetadataIndex, HistoryAnnotationAssociation, Job, JobParameter, -JobToInputLibraryDatasetAssociation, JobToInputDatasetAssociation, JobToOutputDatasetAssociation, ToolVersion ) +JobToInputLibraryDatasetAssociation, JobToInputDatasetAssociation, JobToOutputDatasetAssociation, ToolVersion, +Page ) from galaxy.util.json import to_json_string from sqlalchemy import and_ @@ -469,6 +470,20 @@ +################## +#Page Searching +################## + +class PageView(ViewQueryBaseClass): + DOMAIN = "page" + FIELDS = { + 'id' : ViewField('id', sqlalchemy_field=Page.id, id_decode=True), + 'title' : ViewField('title', sqlalchemy_field=Page.title), + } + + def search(self, trans): + self.query = trans.sa_session.query( Page ) + """ The view mapping takes a user's name for a table and maps it to a View class that will handle queries @@ -486,6 +501,7 @@ 'workflow' : WorkflowView, 'tool' : ToolView, 'job' : JobView, + 'page' : PageView } """ diff -r 253f888144aaa4ae4eadaf15de493b3144fc5cd3 -r 934fe4d500ec7fba8d41c634eb70dc0381dee41c lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -166,6 +166,14 @@ rval[k] = trans.security.encode_id( v ) except: pass # probably already encoded + if (k.endswith("_ids") and type(v) == list): + try: + o = [] + for i in v: + o.append(trans.security.encode_id( i )) + rval[k] = o + except: + pass else: if recursive and type(v) == dict: rval[k] = self.encode_all_ids(trans, v, recursive) https://bitbucket.org/galaxy/galaxy-central/commits/ebe7a63e01e9/ Changeset: ebe7a63e01e9 Branch: page-api User: Kyle Ellrott Date: 2013-11-21 23:07:52 Summary: Adding page revisions to search api Affected #: 2 files diff -r 934fe4d500ec7fba8d41c634eb70dc0381dee41c -r ebe7a63e01e91bc75e447c5c159a2f142b7b894c lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -3160,12 +3160,19 @@ rval['revision_ids'] = rev return rval -class PageRevision( object ): +class PageRevision( object, Dictifiable ): + dict_element_visible_keys = [ 'id', 'page_id', 'title', 'content' ] def __init__( self ): self.user = None self.title = None self.content = None + def to_dict( self, view='element' ): + rval = super( PageRevision, self ).to_dict( view=view ) + rval['create_time'] = str(self.create_time) + rval['update_time'] = str(self.update_time) + return rval + class PageUserShareAssociation( object ): def __init__( self ): self.page = None diff -r 934fe4d500ec7fba8d41c634eb70dc0381dee41c -r ebe7a63e01e91bc75e447c5c159a2f142b7b894c lib/galaxy/model/search.py --- a/lib/galaxy/model/search.py +++ b/lib/galaxy/model/search.py @@ -36,7 +36,7 @@ StoredWorkflow, HistoryTagAssociation,HistoryDatasetAssociationTagAssociation, ExtendedMetadata, ExtendedMetadataIndex, HistoryAnnotationAssociation, Job, JobParameter, JobToInputLibraryDatasetAssociation, JobToInputDatasetAssociation, JobToOutputDatasetAssociation, ToolVersion, -Page ) +Page, PageRevision ) from galaxy.util.json import to_json_string from sqlalchemy import and_ @@ -484,6 +484,27 @@ def search(self, trans): self.query = trans.sa_session.query( Page ) + + + +################## +#Page Revision Searching +################## + + +class PageRevisionView(ViewQueryBaseClass): + DOMAIN = "page_revision" + FIELDS = { + 'id' : ViewField('id', sqlalchemy_field=PageRevision.id, id_decode=True), + 'title' : ViewField('title', sqlalchemy_field=PageRevision.title), + 'page_id' : ViewField('page_id', sqlalchemy_field=PageRevision.page_id, id_decode=True), + } + + def search(self, trans): + self.query = trans.sa_session.query( PageRevision ) + + + """ The view mapping takes a user's name for a table and maps it to a View class that will handle queries @@ -501,7 +522,8 @@ 'workflow' : WorkflowView, 'tool' : ToolView, 'job' : JobView, - 'page' : PageView + 'page' : PageView, + 'page_revision' : PageRevisionView, } """ https://bitbucket.org/galaxy/galaxy-central/commits/d50335029705/ Changeset: d50335029705 Branch: page-api User: Kyle Ellrott Date: 2013-11-21 23:29:42 Summary: Adding security checks to pages found via search api. Also fixing some bugs related to search security checks. Affected #: 1 file diff -r ebe7a63e01e91bc75e447c5c159a2f142b7b894c -r d50335029705d4e587a7a6428b9da6e4fc4890cf lib/galaxy/webapps/galaxy/api/search.py --- a/lib/galaxy/webapps/galaxy/api/search.py +++ b/lib/galaxy/webapps/galaxy/api/search.py @@ -5,7 +5,7 @@ from galaxy import web from galaxy.web.base.controller import SharableItemSecurityMixin, BaseAPIController from galaxy.model.search import GalaxySearchEngine - +from galaxy.exceptions import ItemAccessibilityException log = logging.getLogger( __name__ ) @@ -37,15 +37,28 @@ if trans.user_is_admin(): append = True if not append: - if type( item ) in ( trans.app.model.LibraryFolder, trans.app.model.LibraryDatasetDatasetAssociation, trans.app.model.LibraryDataset ): + if type( item ) in [ trans.app.model.LibraryFolder, trans.app.model.LibraryDatasetDatasetAssociation, trans.app.model.LibraryDataset ]: if (trans.app.security_agent.can_access_library_item( trans.get_current_user_roles(), item, trans.user ) ): append = True - elif type( item ) in trans.app.model.Job: + elif type( item ) in [ trans.app.model.Job ]: if item.used_id == trans.user or trans.user_is_admin(): append = True + elif type( item ) in [ trans.app.model.Page ]: + try: + if self.security_check( trans, item, False, True): + append = True + except ItemAccessibilityException: + append = False + elif type ( item ) in [ trans.app.model.PageRevision ]: + try: + if self.security_check( trans, item.page, False, True): + append = True + except ItemAccessibilityException: + append = False elif hasattr(item, 'dataset'): if trans.app.security_agent.can_access_dataset( current_user_roles, item.dataset ): append = True + if append: row = query.item_to_api_value(item) out.append( self.encode_all_ids( trans, row, True) ) https://bitbucket.org/galaxy/galaxy-central/commits/359a822b2e5d/ Changeset: 359a822b2e5d User: jmchilton Date: 2013-11-26 15:04:27 Summary: Merged in kellrott/galaxy-central/page-api (pull request #266) Adding Pages and PageRevisions to the search API Affected #: 4 files diff -r c0384bad246d60a0ca737685cc67eb17331b36fa -r 359a822b2e5da89973ce042942a9a10dd2b229e1 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -3140,7 +3140,8 @@ self.session = session self.openid = openid -class Page( object ): +class Page( object, Dictifiable ): + dict_element_visible_keys = [ 'id', 'title', 'latest_revision_id', 'slug' ] def __init__( self ): self.id = None self.user = None @@ -3151,12 +3152,27 @@ self.importable = None self.published = None -class PageRevision( object ): + def to_dict( self, view='element' ): + rval = super( Page, self ).to_dict( view=view ) + rev = [] + for a in self.revisions: + rev.append(a.id) + rval['revision_ids'] = rev + return rval + +class PageRevision( object, Dictifiable ): + dict_element_visible_keys = [ 'id', 'page_id', 'title', 'content' ] def __init__( self ): self.user = None self.title = None self.content = None + def to_dict( self, view='element' ): + rval = super( PageRevision, self ).to_dict( view=view ) + rval['create_time'] = str(self.create_time) + rval['update_time'] = str(self.update_time) + return rval + class PageUserShareAssociation( object ): def __init__( self ): self.page = None diff -r c0384bad246d60a0ca737685cc67eb17331b36fa -r 359a822b2e5da89973ce042942a9a10dd2b229e1 lib/galaxy/model/search.py --- a/lib/galaxy/model/search.py +++ b/lib/galaxy/model/search.py @@ -35,7 +35,8 @@ History, Library, LibraryFolder, LibraryDataset,StoredWorkflowTagAssociation, StoredWorkflow, HistoryTagAssociation,HistoryDatasetAssociationTagAssociation, ExtendedMetadata, ExtendedMetadataIndex, HistoryAnnotationAssociation, Job, JobParameter, -JobToInputLibraryDatasetAssociation, JobToInputDatasetAssociation, JobToOutputDatasetAssociation, ToolVersion ) +JobToInputLibraryDatasetAssociation, JobToInputDatasetAssociation, JobToOutputDatasetAssociation, ToolVersion, +Page, PageRevision ) from galaxy.util.json import to_json_string from sqlalchemy import and_ @@ -469,6 +470,41 @@ +################## +#Page Searching +################## + +class PageView(ViewQueryBaseClass): + DOMAIN = "page" + FIELDS = { + 'id' : ViewField('id', sqlalchemy_field=Page.id, id_decode=True), + 'title' : ViewField('title', sqlalchemy_field=Page.title), + } + + def search(self, trans): + self.query = trans.sa_session.query( Page ) + + + + +################## +#Page Revision Searching +################## + + +class PageRevisionView(ViewQueryBaseClass): + DOMAIN = "page_revision" + FIELDS = { + 'id' : ViewField('id', sqlalchemy_field=PageRevision.id, id_decode=True), + 'title' : ViewField('title', sqlalchemy_field=PageRevision.title), + 'page_id' : ViewField('page_id', sqlalchemy_field=PageRevision.page_id, id_decode=True), + } + + def search(self, trans): + self.query = trans.sa_session.query( PageRevision ) + + + """ The view mapping takes a user's name for a table and maps it to a View class that will handle queries @@ -486,6 +522,8 @@ 'workflow' : WorkflowView, 'tool' : ToolView, 'job' : JobView, + 'page' : PageView, + 'page_revision' : PageRevisionView, } """ diff -r c0384bad246d60a0ca737685cc67eb17331b36fa -r 359a822b2e5da89973ce042942a9a10dd2b229e1 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -166,6 +166,14 @@ rval[k] = trans.security.encode_id( v ) except: pass # probably already encoded + if (k.endswith("_ids") and type(v) == list): + try: + o = [] + for i in v: + o.append(trans.security.encode_id( i )) + rval[k] = o + except: + pass else: if recursive and type(v) == dict: rval[k] = self.encode_all_ids(trans, v, recursive) diff -r c0384bad246d60a0ca737685cc67eb17331b36fa -r 359a822b2e5da89973ce042942a9a10dd2b229e1 lib/galaxy/webapps/galaxy/api/search.py --- a/lib/galaxy/webapps/galaxy/api/search.py +++ b/lib/galaxy/webapps/galaxy/api/search.py @@ -5,7 +5,7 @@ from galaxy import web from galaxy.web.base.controller import SharableItemSecurityMixin, BaseAPIController from galaxy.model.search import GalaxySearchEngine - +from galaxy.exceptions import ItemAccessibilityException log = logging.getLogger( __name__ ) @@ -37,15 +37,28 @@ if trans.user_is_admin(): append = True if not append: - if type( item ) in ( trans.app.model.LibraryFolder, trans.app.model.LibraryDatasetDatasetAssociation, trans.app.model.LibraryDataset ): + if type( item ) in [ trans.app.model.LibraryFolder, trans.app.model.LibraryDatasetDatasetAssociation, trans.app.model.LibraryDataset ]: if (trans.app.security_agent.can_access_library_item( trans.get_current_user_roles(), item, trans.user ) ): append = True - elif type( item ) in trans.app.model.Job: + elif type( item ) in [ trans.app.model.Job ]: if item.used_id == trans.user or trans.user_is_admin(): append = True + elif type( item ) in [ trans.app.model.Page ]: + try: + if self.security_check( trans, item, False, True): + append = True + except ItemAccessibilityException: + append = False + elif type ( item ) in [ trans.app.model.PageRevision ]: + try: + if self.security_check( trans, item.page, False, True): + append = True + except ItemAccessibilityException: + append = False elif hasattr(item, 'dataset'): if trans.app.security_agent.can_access_dataset( current_user_roles, item.dataset ): append = True + if append: row = query.item_to_api_value(item) out.append( self.encode_all_ids( trans, row, True) ) 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.