def test_bulk_delete(self, coupons, mock_stripe): """ Resource gets bulk deleted. """ params = { 'bulk_ids': [1, 2, 3], 'scope': 'all_search_results' } self.login() response = self.client.post(url_for('admin.coupons_bulk_delete'), data=params, follow_redirects=True) assert_status_with_message(200, response, _n('%(num)d coupon was scheduled to be ' 'deleted.', '%(num)d coupons were scheduled to be ' 'deleted.', num=3))
def issues_bulk_delete(): form = BulkDeleteForm() if form.validate_on_submit(): ids = Issue.get_bulk_action_ids(request.form.get('scope'), request.form.getlist('bulk_ids'), query=request.args.get('q', '')) delete_count = Issue.bulk_delete(ids) flash(_n('%(num)d issue was deleted.', '%(num)d issues were deleted.', num=delete_count), 'success') else: flash(_('No issues were deleted, something went wrong.'), 'error') return redirect(url_for('admin.issues'))
def test_bulk_delete(self, issues): """ Resource gets bulk deleted. """ old_count = Issue.query.count() params = { 'bulk_ids': [1, 2], 'scope': 'all_search_results' } self.login() response = self.client.post(url_for('admin.issues_bulk_delete'), data=params, follow_redirects=True) assert_status_with_message(200, response, _n('%(num)d issue was deleted.', '%(num)d issues were deleted.', num=2)) new_count = Issue.query.count() assert (old_count - 2) == new_count
def coupons_bulk_delete(): form = BulkDeleteForm() if form.validate_on_submit(): ids = Coupon.get_bulk_action_ids(request.form.get('scope'), request.form.getlist('bulk_ids'), query=request.args.get('q', '')) # Prevent circular imports. from catwatch.blueprints.billing.tasks import delete_coupons delete_coupons.delay(ids) flash(_n('%(num)d coupon was scheduled to be deleted.', '%(num)d coupons were scheduled to be deleted.', num=len(ids)), 'success') else: flash(_('No coupons were deleted, something went wrong.'), 'error') return redirect(url_for('admin.coupons'))
def test_bulk_delete_nothing(self): """ Last admin account should not get deleted. """ old_count = User.query.count() params = { 'bulk_ids': [1], 'scope': 'all_selected_products' } self.login() response = self.client.post(url_for('admin.users_bulk_delete'), data=params, follow_redirects=True) assert_status_with_message(200, response, _n('%(num)d user was scheduled to be ' 'deleted.', '%(num)d users were scheduled to be ' 'deleted.', num=0)) new_count = User.query.count() assert old_count == new_count