def __init__(self, *args, **kwargs): stage_id = kwargs.pop('stage_id') self.base_columns['actions'] = ActionsColumn( [ { 'title': '<i class="glyphicon glyphicon-file"></i>', 'url': 'hosts_host_detail', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'View Host', 'data-delay': '{ "show": 300, "hide": 0 }' } }, { 'title': '<i class="glyphicon glyphicon-trash"></i>', 'url': 'projects_stage_unmaphost', 'args': [ stage_id, tables.A('pk'), ], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Remove Host from Stage', 'data-delay': '{ "show": 300, "hide": 0 }' } }, ], delimiter='   ') super(StageHostTable, self).__init__(*args, **kwargs)
class HostTable(PaginateTable): name = tables.LinkColumn('hosts_host_detail', args=[tables.A('pk')], verbose_name='Name') alias = tables.Column(verbose_name='Alias') actions = ActionsColumn([ { 'title': '<i class="glyphicon glyphicon-pencil"></i>', 'url': 'hosts_host_update', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Edit Host', 'data-delay': '{ "show": 300, "hide": 0 }' } }, { 'title': '<i class="glyphicon glyphicon-trash"></i>', 'url': 'hosts_host_delete', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Delete Host', 'data-delay': '{ "show": 300, "hide": 0 }' } }, ], delimiter='   ') class Meta: model = models.Host attrs = {"class": "table table-striped"} fields = ('name', 'alias', 'actions')
class DeploymentTable(PaginateTable): """Table used to show the deployments Also provides actions to view individual deployment""" actions = ActionsColumn([ { 'title': '<i class="glyphicon glyphicon-file"></i>', 'url': 'projects_deployment_detail', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'View Deployment Details', 'data-delay': '{ "show": 300, "hide": 0 }' } }, ], delimiter='   ') task_name = tables.Column(accessor='task.name', verbose_name='Task') #Prettify the status status = tables.TemplateColumn( '<span style="font-size:13px;" class="label label-{% if record.status == "success" %}success{% elif record.status == "failed" %}danger{% else %}info{% endif %}"><i class="glyphicon glyphicon-{% if record.status == "success" %}ok{% elif record.status == "failed" %}warning-sign{% else %}time{% endif %}"></i>  {{ record.get_status_display }}</span>' ) class Meta: model = models.Deployment attrs = {"class": "table table-striped"} sequence = fields = ('date_created', 'stage', 'task_name', 'status', 'actions')
class RecentDeploymentsTable(tables.Table): """Table used to show the recent deployments of a user""" project = tables.Column(accessor='stage.project.name', verbose_name='Project', orderable=False) stage = tables.Column(accessor='stage.name', verbose_name='Stage', orderable=False) task_name = tables.Column(accessor='task.name', verbose_name='Task', orderable=False) status = tables.TemplateColumn( template_name='projects/pieces/deployment_status_column.html', verbose_name='Status' ) actions = ActionsColumn( [ { 'title': '<i class="glyphicon glyphicon-file"></i>', 'url': 'projects_deployment_detail', 'args': [tables.A('stage.project_id'), tables.A('stage_id'), tables.A('pk')], 'attrs': {'data-toggle': 'tooltip', 'title': 'View Deployment Details', 'data-delay': '{ "show": 300, "hide": 0 }'} }, ], delimiter='   ' ) class Meta: model = models.Deployment attrs = {"class": "table table-striped"} sequence = fields = ( 'project', 'stage', 'task_name', 'status', 'actions', )
class UserListTable(PaginateTable): """ Table for displaying users. """ actions = ActionsColumn([ { 'title': '<i class="glyphicon glyphicon-file"></i>', 'url': 'accounts_user_view', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'View User', 'data-delay': '{ "show": 300, "hide": 0 }' } }, { 'title': '<i class="glyphicon glyphicon-pencil"></i>', 'url': 'accounts_user_change', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Edit User', 'data-delay': '{ "show": 300, "hide": 0 }' } }, { 'title': '<i class="glyphicon glyphicon-trash"></i>', 'url': 'accounts_user_delete', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Delete User', 'data-delay': '{ "show": 300, "hide": 0 }', 'class': 'js-delete' } }, ], delimiter='   ') email = tables.Column(verbose_name='Email') first_name = tables.Column(verbose_name='First Name') last_name = tables.Column(verbose_name='Last Name') user_level = tables.Column(verbose_name='User Level', accessor='group_strigify', order_by='groups') class Meta: model = get_user_model() sequence = fields = ( 'first_name', 'last_name', 'is_active', 'email', 'user_level', ) attrs = {'class': 'table table-striped table-bordered table-hover'} def __init__(self, *args, **kwargs): super(UserListTable, self).__init__(*args, **kwargs)
class StageTable(PaginateTable): """Table used to show the stages Also provides actions for view, edit, and delete""" actions = ActionsColumn([ { 'title': '<i class="glyphicon glyphicon-file"></i>', 'url': 'projects_stage_view', 'args': [tables.A('project_id'), tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'View Stage Details', 'data-delay': '{ "show": 300, "hide": 0 }' } }, { 'title': '<i class="glyphicon glyphicon-pencil"></i>', 'url': 'projects_stage_update', 'args': [tables.A('project_id'), tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Edit Stage', 'data-delay': '{ "show": 300, "hide": 0 }' } }, { 'title': '<i class="glyphicon glyphicon-trash"></i>', 'url': 'projects_stage_delete', 'args': [tables.A('project_id'), tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Delete Stage', 'data-delay': '{ "show": 300, "hide": 0 }' } }, ], delimiter='   ') hosts = tables.Column(accessor='host_count', verbose_name='# Hosts') deployments = tables.Column(accessor='deployment_count', verbose_name='# Deployments', order_by='deployment_count') class Meta: model = models.Stage attrs = {"class": "table table-striped"} sequence = fields = ( 'name', 'hosts', 'deployments', 'actions', )
class DeploymentTable(PaginateTable): """Table used to show the deployments Also provides actions to view individual deployment""" date_created = tables.Column(verbose_name='Created') user = LinkColumn('accounts_user_view', accessor='user.email', args=[tables.A('user.pk')], attrs={ 'data-toggle': 'tooltip', 'title': 'View user details', 'data-delay': '{ "show": 300, "hide": 0 }' }, verbose_name='Deployer') stage = tables.Column(verbose_name='Stage') task_name = tables.Column(accessor='task.name', verbose_name='Task') status = tables.TemplateColumn( template_name='projects/pieces/deployment_status_column.html', verbose_name='Status') actions = ActionsColumn([ { 'title': '<i class="glyphicon glyphicon-file"></i>', 'url': 'projects_deployment_detail', 'args': [ tables.A('stage.project_id'), tables.A('stage_id'), tables.A('pk') ], 'attrs': { 'data-toggle': 'tooltip', 'title': 'View Deployment Details', 'data-delay': '{ "show": 300, "hide": 0 }' } }, ], delimiter='   ') class Meta: model = models.Deployment attrs = {"class": "table table-striped"} sequence = fields = ( 'date_created', 'user', 'stage', 'task_name', 'status', 'actions', )
class ConfigurationTable(PaginateTable): """Table used to show the configurations Also provides actions to edit and delete""" actions = ActionsColumn([ { 'title': '<i class="glyphicon glyphicon-pencil"></i>', 'url': 'projects_configuration_update', 'args': [tables.A('project_id'), tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Edit Configuration', 'data-delay': '{ "show": 300, "hide": 0 }' } }, { 'title': '<i class="glyphicon glyphicon-trash"></i>', 'url': 'projects_configuration_delete', 'args': [tables.A('project_id'), tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Delete Configuration', 'data-delay': '{ "show": 300, "hide": 0 }' } }, ], delimiter='   ') key = tables.LinkColumn('projects_configuration_update', kwargs={ 'project_id': tables.A('project_id'), 'pk': tables.A('pk') }, verbose_name='Key') value = tables.Column(accessor='get_display_value', orderable=False) # Clean up the labels a little task_argument = BooleanColumn(verbose_name="Argument?", ) prompt_me_for_input = BooleanColumn(verbose_name="Prompt?", ) sensitive_value = BooleanColumn(verbose_name="Sensitive?", ) class Meta: model = models.Configuration attrs = {"class": "table table-striped"} sequence = fields = ( 'key', 'value', 'task_argument', 'prompt_me_for_input', 'sensitive_value', )
class ProjectTable(PaginateTable): """Table used to display the projects Also provides actions to edit, view, and delete""" actions = ActionsColumn([ { 'title': '<i class="glyphicon glyphicon-pencil"></i>', 'url': 'projects_project_update', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Edit Project', 'data-delay': '{ "show": 300, "hide": 0 }' } }, { 'title': '<i class="glyphicon glyphicon-trash"></i>', 'url': 'projects_project_delete', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Delete Project', 'data-delay': '{ "show": 300, "hide": 0 }' } }, { 'title': '<i class="glyphicon glyphicon-duplicate"></i>', 'url': 'projects_project_copy', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Copy Project', 'data-delay': '{ "show": 300, "hide": 0 }' } }, ], delimiter='   ') name = tables.LinkColumn('projects_project_view', kwargs={'pk': tables.A('pk')}, verbose_name='Name') deployments = tables.Column(accessor='get_deployment_count', verbose_name='# Deployments', orderable=False) class Meta: model = models.Project attrs = {"class": "table table-striped"} sequence = fields = ( 'name', 'deployments', )
class LaunchWindowTable(PaginateTable): actions = ActionsColumn([ {'title': '<i class="glyphicon glyphicon-file"></i>', 'url': 'launch_window_launchwindow_detail', 'args': [tables.A('pk')], 'attrs':{'data-toggle': 'tooltip', 'title': 'View Launch Window', 'data-delay': '{ "show": 300, "hide": 0 }'}}, {'title': '<i class="glyphicon glyphicon-pencil"></i>', 'url': 'launch_window_launchwindow_update', 'args': [tables.A('pk')], 'attrs':{'data-toggle': 'tooltip', 'title': 'Edit Launch Window', 'data-delay': '{ "show": 300, "hide": 0 }'}}, {'title': '<i class="glyphicon glyphicon-trash"></i>', 'url': 'launch_window_launchwindow_delete', 'args': [tables.A('pk')], 'attrs':{'data-toggle': 'tooltip', 'title': 'Delete Launch Window', 'data-delay': '{ "show": 300, "hide": 0 }'}}, ], delimiter='   ') class Meta: model = models.LaunchWindow attrs = {"class": "table table-striped"} exclude = ('id',)
class UserListTable(PaginateTable): """ Table for displaying users. """ actions = ActionsColumn([ { 'title': '<i class="glyphicon glyphicon-pencil"></i>', 'url': 'accounts_user_change', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Edit User', 'data-delay': '{ "show": 300, "hide": 0 }' } }, { 'title': '<i class="glyphicon glyphicon-trash"></i>', 'url': 'accounts_user_delete', 'args': [tables.A('pk')], 'attrs': { 'data-toggle': 'tooltip', 'title': 'Delete User', 'data-delay': '{ "show": 300, "hide": 0 }', 'class': 'js-delete' } }, ], delimiter='   ') email = tables.LinkColumn('accounts_user_view', args=[tables.A('pk')], verbose_name='Email') first_name = tables.Column(verbose_name='First Name') last_name = tables.Column(verbose_name='Last Name') is_active = BooleanColumn(verbose_name='Active') user_level = tables.Column(verbose_name='User Level', accessor='group_strigify', order_by='groups') class Meta: model = DeployUser sequence = fields = ( 'email', 'first_name', 'last_name', 'is_active', 'user_level', ) attrs = {'class': 'table table-striped table-hover'}
class HookTable(PaginateTable): """Table used to show the configurations Also provides actions to edit and delete""" actions = ActionsColumn([ {'title': '<i class="glyphicon glyphicon-pencil"></i>', 'url': 'hooks_hook_update', 'args': [tables.A('pk')], 'attrs':{'data-toggle': 'tooltip', 'title': 'Edit Hook', 'data-delay': '{ "show": 300, "hide": 0 }'}}, {'title': '<i class="glyphicon glyphicon-trash"></i>', 'url': 'hooks_hook_delete', 'args': [tables.A('pk')], 'attrs':{'data-toggle': 'tooltip', 'title': 'Delete Hook', 'data-delay': '{ "show": 300, "hide": 0 }'}}, ], delimiter='   ') class Meta: model = models.Hook attrs = {"class": "table table-striped"} sequence = fields = ( 'project', 'url', )