Esempio n. 1
0
def __add_column(name, view, link=""):
    col = ViewColumn()
    col.column = name 
    col.link = link
    col.parent_id = view.id
    db_session.add(col)
    db_session.commit()
Esempio n. 2
0
def __add_column(name, view, link=""):
    col = ViewColumn()
    col.column = name
    col.link = link
    col.parent_id = view.id
    db_session.add(col)
    db_session.commit()
Esempio n. 3
0
 def get_columns(self, view_id):
     columns = []
     for column_form in self.columns:
         column = ViewColumn()
         column.column = column_form.column.data
         column.parent_id = view_id
         columns.append(column)
     return columns
Esempio n. 4
0
 def get_columns(self, view_id):
     columns = []
     for column_form in self.columns:
         column = ViewColumn()
         column.column = column_form.column.data
         column.link = column_form.link.data
         column.parent_id = view_id
         columns.append(column)
     return columns
Esempio n. 5
0
def create_default_views():
    filters = ViewFilters()
    for option, col_names in cache_columns.iteritems():
        setattr(filters, option, 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.first()
    view1 = View()
    view1.title = 'All hosts'
    view1.link_name = 'allhosts'
    view1.datasource = 'hosts'
    view1.filters_id = filters.id
    view1.layout_number_columns = 2
    db_session.add(view1)
    db_session.commit()
    view1 = (View.query.filter_by(link_name=view1.link_name).first())

    col1 = ViewColumn()
    col1.column = 'host_name'
    col1.parent_id = view1.id
    db_session.add(col1)

    col2 = ViewColumn()
    col2.column = 'host_state'
    col2.parent_id = view1.id
    db_session.add(col2)

    col3 = ViewColumn()
    col3.column = 'last_check'
    col3.parent_id = view1.id
    db_session.add(col3)
    db_session.commit()

    sort1 = ViewSorter()
    sort1.column = 'host_name'
    sort1.sorter_option = '1'
    sort1.parent_id = view1.id
    db_session.add(sort1)
    db_session.commit()

    group1 = ViewGrouper()
    group1.column = 'site'
    group1.parent_id = view1.id
    db_session.add(group1)
    db_session.commit()


    filters = ViewFilters()
    for option, col_names in cache_columns.iteritems():
        setattr(filters, option, 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[1]
    view2 = View()
    view2.title = 'All services'
    view2.link_name = 'allservices'
    view2.datasource = 'services'
    view2.layout_number_columns = 1
    view2.filters_id = filters.id
    db_session.add(view2)
    db_session.commit()

    col4 = ViewColumn()
    col4.column = 'service_description'
    col4.parent_id = view2.id
    db_session.add(col4)
    db_session.commit()

    col5 = ViewColumn()
    col5.column = 'service_state'
    col5.parent_id = view2.id
    db_session.add(col5)
    db_session.commit()