Beispiel #1
0
def __add_sort_by(name, view, order=""):
    col = ViewSorter()
    col.column = name
    col.sorter_option = order
    col.parent_id = view.id
    db_session.add(col)
    db_session.commit()
Beispiel #2
0
 def set_extra_sorters(self, sorters):
     for colname, order in sorters.items():
         sorter = ViewSorter()
         sorter.column = colname
         sorter.sorter_option = order
         [self.__sorters.remove(sorter_item) for sorter_item in self.__sorters if sorter_item.column == colname]
         self.__sorters.append(sorter)
Beispiel #3
0
def __add_sort_by(name, view, order=""):
    col = ViewSorter()
    col.column = name
    col.sorter_option = order
    col.parent_id = view.id
    db_session.add(col)
    db_session.commit()
Beispiel #4
0
 def get_sorters(self, view_id):
     sorters = []
     for sorter_form in self.sorters:
         sorter = ViewSorter()
         sorter.column = sorter_form.column.data
         sorter.sorter_option = sorter_form.sorter_option.data
         sorter.parent_id = view_id
         sorters.append(sorter)
     return sorters
Beispiel #5
0
 def get_sorters(self, view_id):
     sorters = []
     for sorter_form in self.sorters:
         sorter = ViewSorter()
         sorter.column = sorter_form.column.data
         sorter.sorter_option = sorter_form.sorter_option.data
         sorter.parent_id = view_id
         sorters.append(sorter)
     return sorters
Beispiel #6
0
 def set_extra_sorters(self, sorters):
     for colname, order in sorters.items():
         sorter = ViewSorter()
         sorter.column = colname
         sorter.sorter_option = order
         [
             self.__sorters.remove(sorter_item)
             for sorter_item in self.__sorters
             if sorter_item.column == colname
         ]
         self.__sorters.append(sorter)
Beispiel #7
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()