Beispiel #1
0
    def set_formula(self):
        cid = request.form['id']
        calculator = Calculator.query.get(cid)
        helpers.write_template_file(calculator.template,
                                    formula=request.form['formula'])

        return json.dumps({'message': 'Saved!'})
Beispiel #2
0
    def set_formula(self):
        cid = request.form['id']
        calculator = Calculator.query.get(cid)
        helpers.write_template_file(calculator.template,
                                    formula=request.form['formula'])

        return json.dumps({'message': 'Saved!'})
Beispiel #3
0
    def new_formula(self):
        calculator = Calculator(
            name=request.form['name'],
            template=request.form['name'].lower().replace(' ', '_') +
            '.formula')

        current_app.db.session.add(calculator)
        try:
            current_app.db.session.commit()
        except:
            return Response(
                json.dumps({
                    'message':
                    'There was an error creating the new calculator'
                })), 500

        helpers.write_template_file(calculator.template)

        return [calculator]
Beispiel #4
0
    def new_formula(self):
        calculator = Calculator(
            name=request.form['name'],
            template=request.form['name'].lower().replace(' ', '_') + '.formula'
        )

        current_app.db.session.add(calculator)
        try:
            current_app.db.session.commit()
        except:
            return Response(json.dumps(
                {
                    'message': 'There was an error creating the new calculator'
                }
            )), 500

        helpers.write_template_file(calculator.template)

        return [calculator]