Exemplo n.º 1
0
def generate_copo_publications_data(profile_id):
    # This method generates the 'json' for building the UI table
    p = Publication(profile_id)
    publications = p.get_all_publications()

    columns = []
    dataSet = []

    # headers
    for el in p.schema:
        columns.append({"title": el.label})
    columns.append({"title": " "})  # extra 'blank' header for record actions column

    # data
    for pb in publications:
        row = get_record_data(pb, p.schema)
        dataSet.append(row)

    # define action buttons for the table. ALWAYS include the class 'copo-dt' in className!!!
    action_buttons = [
        {'text': 'Edit', 'className': 'copo-dt btn btn-success', 'iconClass': 'fa fa-pencil-square-o'},
        {'text': 'Delete', 'className': 'copo-dt btn btn-danger', 'iconClass': 'fa fa-trash-o'}
    ]

    return {"columns": columns, "dataSet": dataSet, "table_id": "publication_table", "action_buttons": action_buttons}