def create(): data = json.loads(flask.request.form['navigation']) nav_data = _get_navigation_data(data) set_original_creator(nav_data) ids = get_resource_service('navigations').post([nav_data]) return jsonify({'success': True, '_id': ids[0]}), 201
def on_create(self, docs): super().on_create(docs) for doc in docs: set_original_creator(doc) if doc.get('password', None) and not is_hashed(doc.get('password')): doc['password'] = self._get_password_hash(doc['password'])
def create(): company = get_json_or_400() errors = get_errors_company(company) if errors: return errors new_company = get_company_updates(company) set_original_creator(new_company) ids = get_resource_service('companies').post([new_company]) return jsonify({'success': True, '_id': ids[0]}), 201
def create(): product = get_json_or_400() validation = validate_product(product) if validation: return validation if product.get('navigations'): product['navigations'] = [str(get_entity_or_404(_id, 'navigations')['_id']) for _id in product.get('navigations').split(',')] set_original_creator(product) ids = get_resource_service('products').post([product]) return jsonify({'success': True, '_id': ids[0]}), 201
def create(): section_filter = get_json_or_400() validation = validate_section_filter(section_filter) if validation: return validation section = next((s for s in current_app.sections if s['_id'] == section_filter.get('filter_type')), None) if section and section.get('search_type'): section_filter['search_type'] = section['search_type'] set_original_creator(section_filter) ids = get_resource_service('section_filters').post([section_filter]) return jsonify({'success': True, '_id': ids[0]}), 201
def create(): form = MonitoringForm() if form.validate(): new_data = form.data if form.company.data: new_data['company'] = ObjectId(form.company.data) company_users = list( query_resource('users', lookup={'company': new_data['company']})) new_data['users'] = [ObjectId(u['_id']) for u in company_users] request_updates = flask.request.get_json() process_form_request(new_data, request_updates, form) set_original_creator(new_data) ids = get_resource_service('monitoring').post([new_data]) return jsonify({ 'success': True, '_id': ids[0], 'users': new_data.get('users') }), 201 return jsonify(form.errors), 400
def create(): data = json.loads(flask.request.form['card']) card_data = _get_card_data(data) set_original_creator(card_data) ids = get_resource_service('cards').post([card_data]) return jsonify({'success': True, '_id': ids[0]}), 201