Esempio n. 1
0
class ReviewedRepositoriesIOwnGrid(RepositoriesWithReviewsGrid):
    title = "Reviewed repositories I own"
    columns = [
        RepositoriesWithReviewsGrid.NameColumn("Repository name",
                                               key="name",
                                               link=(lambda item: dict(operation="view_or_manage_repository", id=item.id)),
                                               attach_popup=True),
        RepositoriesWithReviewsGrid.WithReviewsRevisionColumn("Reviewed revisions"),
        RepositoriesWithReviewsGrid.WithoutReviewsRevisionColumn("Revisions for review"),
        RepositoriesWithReviewsGrid.ReviewersColumn("Reviewers", attach_popup=False),
        RepositoryGrid.DeprecatedColumn("Deprecated")
    ]
    columns.append(grids.MulticolFilterColumn("Search repository name",
                                              cols_to_filter=[columns[0]],
                                              key="free-text-search",
                                              visible=False,
                                              filterable="standard"))
    operations = [
        grids.GridOperation("Inspect repository revisions",
                            allow_multiple=False,
                            condition=(lambda item: not item.deleted),
                            async_compatible=False)
    ]

    def build_initial_query(self, trans, **kwd):
        return trans.sa_session.query(model.Repository) \
                               .join((model.RepositoryReview.table, model.RepositoryReview.table.c.repository_id == model.Repository.table.c.id)) \
                               .filter(model.Repository.table.c.user_id == trans.user.id) \
                               .join((model.User.table, model.User.table.c.id == model.RepositoryReview.table.c.user_id)) \
                               .outerjoin((model.ComponentReview.table, model.ComponentReview.table.c.repository_review_id == model.RepositoryReview.table.c.id)) \
                               .outerjoin((model.Component.table, model.Component.table.c.id == model.ComponentReview.table.c.component_id))
Esempio n. 2
0
class AdminRepositoryGrid(RepositoryGrid):
    class DeletedColumn(grids.BooleanColumn):
        def get_value(self, trans, grid, repository):
            if repository.deleted:
                return 'yes'
            return ''

    columns = [
        RepositoryGrid.NameColumn(
            "Name",
            key="name",
            link=(lambda item: dict(operation="view_or_manage_repository",
                                    id=item.id)),
            attach_popup=True),
        RepositoryGrid.HeadsColumn("Heads"),
        RepositoryGrid.UserColumn(
            "Owner",
            model_class=model.User,
            link=(lambda item: dict(operation="repositories_by_user",
                                    id=item.id)),
            attach_popup=False,
            key="User.username"),
        RepositoryGrid.DeprecatedColumn("Deprecated",
                                        key="deprecated",
                                        attach_popup=False),
        # Columns that are valid for filtering but are not visible.
        DeletedColumn("Deleted", key="deleted", attach_popup=False)
    ]
    columns.append(
        grids.MulticolFilterColumn("Search repository name",
                                   cols_to_filter=[columns[0]],
                                   key="free-text-search",
                                   visible=False,
                                   filterable="standard"))
    operations = [operation for operation in RepositoryGrid.operations]
    operations.append(
        grids.GridOperation("Delete",
                            allow_multiple=False,
                            condition=(lambda item: not item.deleted),
                            async_compatible=False))
    operations.append(
        grids.GridOperation("Undelete",
                            allow_multiple=False,
                            condition=(lambda item: item.deleted),
                            async_compatible=False))
    standard_filters = []
    default_filter = {}

    def build_initial_query(self, trans, **kwd):
        return trans.sa_session.query(model.Repository) \
                               .join(model.User.table)