当前位置: 首页>>代码示例>>Python>>正文


Python django_tables2.Column方法代码示例

本文整理汇总了Python中django_tables2.Column方法的典型用法代码示例。如果您正苦于以下问题:Python django_tables2.Column方法的具体用法?Python django_tables2.Column怎么用?Python django_tables2.Column使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django_tables2的用法示例。


在下文中一共展示了django_tables2.Column方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_table_qsdata

# 需要导入模块: import django_tables2 [as 别名]
# 或者: from django_tables2 import Column [as 别名]
def _create_table_qsdata(
    action_id: int,
    qs,
    dt_page: DataTablesServerSidePaging,
    columns: List[models.Column],
    key_idx: int,
) -> List:
    """Select the subset of the qs to be sent as qs data to the JSON request.

    :param action_id: Action id being processed
    :param qs: Query set from where to extract the data
    :param dt_page: Object with DataTable parameters to process the page
    :param columns: List of column
    :param key_idx: Index of the key column
    :return: Query set to return to DataTable JavaScript
    """
    final_qs = []
    item_count = 0
    for row in qs[dt_page.start:dt_page.start + dt_page.length]:
        item_count += 1

        # Render the first element (the key) as the link to the page to update
        # the content.
        row = list(row)
        row[key_idx] = _create_link_to_survey_row(
            action_id,
            columns[key_idx].name,
            row[key_idx],
        )

        # Add the row for rendering
        final_qs.append(row)

        if item_count == dt_page.length:
            # We reached the number or requested elements, abandon loop
            break

    return final_qs 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:40,代码来源:survey.py

示例2: update_luser_email_column

# 需要导入模块: import django_tables2 [as 别名]
# 或者: from django_tables2 import Column [as 别名]
def update_luser_email_column(
    user,
    pk: int,
    workflow: models.Workflow,
    column: models.Column,
):
    """Update the field luser_email in the workflow.

    :param user: User making the request
    :param pk: Column ID to obtain the user id
    :param workflow: Workflow being manipulated.
    :param column: Column being used to update the luser field.
    :return:
    """
    if not pk:
        # Empty pk, means reset the field.
        workflow.luser_email_column = None
        workflow.luser_email_column_md5 = ''
        workflow.lusers.set([])
        workflow.save(update_fields=[
            'luser_email_column',
            'luser_email_column_md5'])
        return

    table_name = workflow.get_data_frame_table_name()

    # Get the column content
    emails = sql.get_rows(table_name, column_names=[column.name])

    # Verify that the column as a valid set of emails
    incorrect_email = get_incorrect_email([row[column.name] for row in emails])
    if incorrect_email:
        raise services.OnTaskWorkflowEmailError(
            message=_('Incorrect email addresses "{0}".').format(
                incorrect_email))

    # Update the column
    workflow.luser_email_column = column
    workflow.save(update_fields=['luser_email_column'])

    # Calculate the MD5 value
    md5_hash = sql.get_text_column_hash(table_name, column.name)

    if workflow.luser_email_column_md5 == md5_hash:
        return

    # Change detected, run the update in batch mode
    workflow.luser_email_column_md5 = md5_hash
    workflow.save(update_fields=['luser_email_column_md5'])

    # Log the event with the status "preparing updating"
    log_item = workflow.log(user, models.Log.WORKFLOW_UPDATE_LUSERS)

    # Push the update of lusers to batch processing
    tasks.execute_operation.delay(
        operation_type=models.Log.WORKFLOW_UPDATE_LUSERS,
        user_id=user.id,
        workflow_id=workflow.id,
        log_id=log_item.id) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:61,代码来源:workflow_ops.py

示例3: _create_rubric_table

# 需要导入模块: import django_tables2 [as 别名]
# 或者: from django_tables2 import Column [as 别名]
def _create_rubric_table(
    action: models.Action,
    criteria: List[models.ActionColumnConditionTuple],
    context: Dict
):
    """Create the table showing the rubric content."""
    if not criteria:
        return

    # Create the extra columns in the table with the categories
    extra_columns = []
    loas = criteria[0].column.categories
    # Get the extra columns for the rubric
    for idx, loa in enumerate(loas):
        extra_columns.append((
            'loa_{0}'.format(idx),
            tables.Column(verbose_name=loa)
        ))

    # Create the table data
    table_data = []
    cell_ctx = {'action_id': action.id}
    for criterion in criteria:
        cell_ctx['column_id'] = criterion.column.id
        rubric_row = OrderedDict([(
            'criterion',
            render_to_string(
                'workflow/includes/partial_criterion_cell.html',
                context={'criterion': criterion, 'action': action}))])

        cels = models.RubricCell.objects.filter(
            action=action,
            column=criterion.column)
        for idx in range(len(loas)):
            cell = cels.filter(loa_position=idx).first()
            loa_str = 'loa_{0}'.format(idx)
            cell_ctx['loa_idx'] = idx
            if cell:
                cell_ctx['description_text'] = cell.description_text
                cell_ctx['feedback_text'] = cell.feedback_text
            else:
                cell_ctx['description_text'] = ''
                cell_ctx['feedback_text'] = ''

            rubric_row[loa_str] = render_to_string(
                'action/includes/partial_rubriccell.html',
                cell_ctx
            )
        table_data.append(rubric_row)

    context['rubric_table'] = RubricTable(
        table_data,
        orderable=False,
        extra_columns=extra_columns) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:56,代码来源:rubric.py


注:本文中的django_tables2.Column方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。