Exemplo n.º 1
0
 def get_form(self, form_data=None, table_name=None,
              column_name=None, obj_id=None, **kwargs):
     table = blocks.get(table_name)
     column = getattr(table, column_name)
     self.form_class = column.form_class
     return super(EditColumnBlock, self).get_form(form_data=form_data,
                                                  table_name=table_name,
                                                  column_name=column_name,
                                                  obj_id=obj_id,
                                                  **kwargs)
Exemplo n.º 2
0
def table_action(transport, table_name, action_name, *args, **kwargs):
    """
    Call table action

    :param transport: achilles transport
    :param table_name: Name of the table calling this
    :param action_name: Name of the action to call
    """
    # Get TableAction item
    context = RequestContext(transport.request, {})
    table = blocks.get(table_name, context)
    action = getattr(table, action_name)

    # Call the action
    res = action.call(transport, table, *args, **kwargs)
    blocks.update(transport, table.register_name)
    return res
Exemplo n.º 3
0
def send(request, form, data):
    """
    Validate a form and call the proper callback Form.form_valid
    or Form.form_invalid

    :param request: Request object
    :param form: Form block name
    :param data: Serialized form data
    :returns: True if the form was valid, False if not
    """
    block = blocks.get(form)
    data = QueryDict(data, encoding=request.encoding)
    form = block.get_form(form_data=data)

    if form.is_valid():
        block.form_valid(request, form)
        return True
    else:
        block.form_invalid(request, form)
        return False
Exemplo n.º 4
0
def send(transport, form, args=[], kwargs={}, data={}):
    """
    Validate a form and call the proper callback Form.form_valid
    or Form.form_invalid

    :param transport: Achilles transport object
    :param form: Form block name
    :param data: Serialized form data
    :returns: True if the form was valid, False if not
    """
    block = blocks.get(form)
    data = QueryDict(data, encoding=transport.encoding)
    form = block.get_form(data, *args, **kwargs)

    if form.is_valid():
        block.form_valid(transport, form, *args, **kwargs)
        return True
    else:
        block.form_invalid(transport, form, *args, **kwargs)
        return False
Exemplo n.º 5
0
def row_action(transport, table_name, action_name, row_id, *args, **kwargs):
    """
    Call table action on the given row

    :param transport: achilles transport
    :param table_name: Name of the table calling this
    :param action_name: Name of the action to call
    :param row_id: Id of the object
    """
    # Get TableAction item
    context = RequestContext(transport.request, {})
    table = blocks.get(table_name, context)
    action = getattr(table, action_name)

    # Get the object from the row
    obj = table.get_object(row_id)

    # Call the action
    res = action.call(transport, table, obj, *args, **kwargs)
    blocks.update(transport, table.register_name)
    return res
Exemplo n.º 6
0
 def get_instance(self, table_name, column_name, obj_id, *args, **kwargs):
     table = blocks.get(table_name)
     return table.get_object(obj_id)
Exemplo n.º 7
0
 def get_instance(self, table_name, column_name, obj_id, *args, **kwargs):
     table = blocks.get(table_name)
     return table.get_object(obj_id)