コード例 #1
0
ファイル: workflow_ops.py プロジェクト: ubc/ontask_b
def get_operations_context(workflow: models.Workflow) -> Dict:
    """Create the context to render the operations page.

    :param workflow: Workflow being manipulated.
    :return: Dictionary with the context.
    """
    return {
        'workflow':
        workflow,
        'attribute_table':
        AttributeTable(
            [{
                'id': idx,
                'name': key,
                'value': kval
            } for idx, (key,
                        kval) in enumerate(sorted(workflow.attributes.items()))
             ],
            orderable=False,
        ),
        'share_table':
        WorkflowShareTable(
            workflow.shared.values('email', 'id').order_by('email'), ),
        'unique_columns':
        workflow.get_unique_columns(),
    }
コード例 #2
0
ファイル: survey.py プロジェクト: cliffnyendwe/ontask_b
    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()
        })