Exemple #1
0
def create_athena_connection_admintable() -> AthenaConnectionTableAdmin:
    """Create the table structure with the SQL connections for Admin.

    :return: Athena Connection Table Admin object.
    """
    op_column = OperationsColumn(
        verbose_name='',
        template_file='connection/includes/partial_adminop.html',
        template_context=lambda record: {
            'id':
            record['id'],
            'edit_url':
            reverse('dataops:athenaconn_edit', kwargs={'pk': record['id']}),
            'view_url':
            reverse('dataops:athenaconn_view', kwargs={'pk': record['id']}),
            'clone_url':
            reverse('dataops:athenaconn_clone', kwargs={'pk': record['id']}),
            'delete_url':
            reverse('dataops:athenaconn_delete', kwargs={'pk': record['id']})
        })

    return AthenaConnectionTableAdmin(
        models.AthenaConnection.objects.values('id', 'name',
                                               'description_text', 'enabled'),
        orderable=False,
        extra_columns=[('operations', op_column)])
Exemple #2
0
class ViewTable(tables.Table):
    """Table to display the set of views handled in a workflow."""

    name = tables.Column(verbose_name=_('Name'))

    description_text = tables.Column(empty_values=[],
                                     verbose_name=_('Description'))

    operations = OperationsColumn(
        verbose_name=_('Operations'),
        template_file='table/includes/partial_view_operations.html',
        template_context=lambda record: {'id': record['id']},
    )

    class Meta:
        """Select the model and specify fields, sequence and attributes."""

        model = models.View
        fields = ('operations', 'name', 'description_text')
        sequence = ('operations', 'name', 'description_text')
        attrs = {
            'class': 'table table-hover table-bordered shadow',
            'style': 'width: 100%;',
            'id': 'view-table',
        }
Exemple #3
0
    def extend_edit_context(
        self,
        workflow: models.Workflow,
        action: models.Action,
        context: Dict,
    ):
        """Get the context dictionary to render the GET request.

        :param workflow: Workflow being used
        :param action: Action being used
        :param context: Initial dictionary to extend
        :return: Nothing.
        """
        self.add_conditions(action, context)
        self.add_conditions_to_clone(action, context)
        self.add_columns_show_stats(action, context)

        # All tuples (action, column, condition) to consider
        tuples = action.column_condition_pair.all()

        context.update({
            'column_selected_table':
            ColumnSelectedTable(
                tuples.filter(column__is_key=False),
                orderable=False,
                extra_columns=[
                    ('operations',
                     OperationsColumn(
                         verbose_name=_('Operations'),
                         template_file=ColumnSelectedTable.ops_template,
                         template_context=lambda record: {
                             'id': record.column.id,
                             'aid': action.id
                         }))
                ],
                condition_list=context['conditions']),
            'columns_to_insert':
            workflow.columns.exclude(
                column_condition_pair__action=action, ).exclude(
                    is_key=True, ).distinct().order_by('position'),
            'any_empty_description':
            tuples.filter(
                column__description_text='',
                column__is_key=False,
            ).exists(),
            'key_columns':
            workflow.get_unique_columns(),
            'key_selected':
            tuples.filter(column__is_key=True).first(),
            'has_no_key':
            tuples.filter(column__is_key=False).exists()
        })
Exemple #4
0
def create_athena_connection_runtable() -> AthenaConnectionTableSelect:
    """Create the table structure with the SQL connections for Running.

    :return: SQL Connection Table Run object.
    """
    operation_column = OperationsColumn(
        verbose_name=_('Operations'),
        template_file='connection/includes/partial_select.html',
        template_context=lambda record: {
            'id':
            record['id'],
            'run_url':
            reverse('dataops:athenaupload_start', kwargs={'pk': record['id']}),
            'view_url':
            reverse('dataops:athenaconn_view', kwargs={'pk': record['id']})
        })
    return AthenaConnectionTableSelect(
        models.AthenaConnection.objects.filter(enabled=True).values(
            'id', 'name', 'description_text'),
        orderable=False,
        extra_columns=[('operations', operation_column)])
Exemple #5
0
def sql_connection_select_table(select_url: str) -> SQLConnectionTableSelect:
    """Create the table structure with the SQL connections for Running.

    :param select_url: URL to use for the select link in every row
    :return: SQL Connection Table Run object.
    """
    operation_column = OperationsColumn(
        verbose_name='',
        template_file='dataops/includes/partial_connection_select.html',
        template_context=lambda record: {
            'id':
            record['id'],
            'view_url':
            reverse('dataops:sqlconn_view', kwargs={'pk': record['id']})
        })

    return SQLConnectionTableSelect(
        models.SQLConnection.objects.filter(enabled=True).values(
            'id', 'name', 'description_text'),
        select_url=select_url,
        orderable=False,
        extra_columns=[('operations', operation_column)])