Example #1
0
 def get_groupers(self, view_id):
     groupers = []
     for grouper_form in self.groupers:
         grouper = ViewGrouper()
         grouper.column = grouper_form.column.data
         grouper.parent_id = view_id
         groupers.append(grouper)
     return groupers
Example #2
0
 def get_groupers(self, view_id):
     groupers = []
     for grouper_form in self.groupers:
         grouper = ViewGrouper()
         grouper.column = grouper_form.column.data
         grouper.parent_id = view_id
         groupers.append(grouper)
     return groupers
Example #3
0
def __add_group_by(name, view):
    col = ViewGrouper()
    col.column = name
    col.parent_id = view.id
    db_session.add(col)
    db_session.commit()
Example #4
0
def __add_group_by(name, view):
    col = ViewGrouper()
    col.column = name
    col.parent_id = view.id
    db_session.add(col)
    db_session.commit()
Example #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()