Exemplo n.º 1
0
    def post_business(payload):
        body = request.get_json()
        id = body.get('id', None)
        name = body.get('name', None)
        address = body.get('address', None)
        phone = body.get('phone', None)
        cif = body.get('cif', None)
        email = body.get('email', None)

        try:
            if id is None:
                business = Business(name=name,
                                    address=address,
                                    phone=phone,
                                    cif=cif,
                                    email=email)
            else:
                business = Business(id=id,
                                    name=name,
                                    address=address,
                                    phone=phone,
                                    cif=cif,
                                    email=email)
            business.insert()
        except:
            abort(422)

        return jsonify({
            'success': True,
            'business': business.long(),
            'status': 200
        }), 200
Exemplo n.º 2
0
    def add_business(payload):
        body = request.get_json()
        if not request.get_json():
            abort(400)

        name = body['name']
        description = body['description']
        date_added = datetime.today()

        business = Business(name=name,
                            description=description,
                            date_added=date_added)

        Business.insert(business)

        return jsonify({'success': True, 'new_business': business.format()})
Exemplo n.º 3
0
    def create_business_profile():
        if request.method == 'GET':
            return render_template('new_business_form.html',
                                   userinfo=session['business_profile'])

        body = request.get_json()
        try:
            name = body.get('name')
            email = body.get('email')
            zip_code = body.get('zip_code')
            goals = body.get('goals')
            website = body.get('website')
            address = body.get('address')
            description = body.get('description')
            skills = body.get('skills'),
            auth_id = body.get('auth_id')

            business = Business(name=name,
                                email=email,
                                zip_code=zip_code,
                                goals=goals,
                                website=website,
                                address=address,
                                description=description,
                                skills=skills,
                                auth_id=auth_id)

            if not business:
                abort(404)

            business.insert()

            return jsonify({
                'success': True,
                'name': business.name,
                'email': business.email,
                'zip_code': business.zip_code,
                'goals': business.goals,
                'website': business.website,
                'address': business.address,
                'description': business.description,
                'skills': business.skills,
                'auth_id': business.auth_id
            }), 200
        except:
            abort(422)