def post(self, filter_id): ''' Validates and updates the filter. Redirects to the new filter if successful. :param filter_id: int ''' filter_ = Filter.get(id_=filter_id) if not filter_: self.error(404, 'Filter not found') form = forms.Filter(self.request.arguments) if form.validate(): Filter.update( id_=filter_id, name=form.name.data, data_yaml=form.data.data, ) self.redirect('/filter/{}'.format(filter_.id)) return self.render( 'filter.html', title='New filter', form=form, edit=True, filter=filter_, members=Filter_team.get_teams_by_filter_id(filter_id=filter_id), teams=Teams.get(), logs_per_minute=Times_seen_by_minute.get_logs_per_minute( filter_id=filter_.id), )
def post(self, filter_id): ''' Validates and updates the filter. Redirects to the new filter if successful. :param filter_id: int ''' filter_ = Filter.get(id_=filter_id) if not filter_: self.error(404, 'Filter not found') form = forms.Filter(self.request.arguments) if form.validate(): Filter.update( id_=filter_id, name=form.name.data, data_yaml=form.data.data, ) self.redirect('/filter/{}'.format(filter_.id)) return self.render( 'filter.html', title='New filter', form=form, edit=True, filter=filter_, members=Filter_team.get_teams_by_filter_id(filter_id=filter_id), teams=Teams.get(), logs_per_minute=Times_seen_by_minute.get_logs_per_minute(filter_id=filter_.id), )
def test_update(self): filter_ = Filter.new(name=u'Test filter ø', data_yaml='') Filter.update( id_=filter_.id, name=u'Test filter 2 ø', data_yaml='{}' ) filter2 = Filter.get(id_=filter_.id) self.assertTrue(filter2.id>0) self.assertEqual(filter2.name, u'Test filter 2 ø') self.assertTrue(isinstance(filter2.data, dict)) self.check_filter_version(filter2.id, filter2.version, filter2.data)
def upgrade(): op.add_column('filters', sa.Column('data_yaml', sa.Text) ) op.add_column('filter_versions', sa.Column('data_yaml', sa.Text) ) for f in Filters.get(): Filter.update( id_=f.id, name=f.name, data_yaml=yaml.safe_dump(f.data), )