# GLBackend Dummy backend for testing GLClient
from flask import Flask, render_template, request, redirect, url_for, flash, jsonify

dummy_tip_form = { 'type' : 2,
                  '0' : {'title': 'Help us fight Corruption!',
                         'fields': [{'name': 'tip', 
                                     'title': 'Your tip', 
                                     'description': 'Explain the issue in less than 3000 chars',
                                      'type': 'text',
                                      'size': '3000c',
                                      }],
                         'buttons': {'next': 'Add some files'}
                        },
                  '1' : {'title': 'Load Documents',
                         'fields': [{'name': 'files',
                                     'title': 'select files',
                                     'type': 'files'
                                     },
                                    {'name': 'documentDescription', 
                                     'title': 'Describe the documents', 
                                     'description': 'Explain the content of the uploaded material in less than 100 words',
                                      'type': 'text',
                                      'size': '100w',
                                      }
                                    ],
                         'buttons': {'next': 'Add more details', 
                                     'finish': 'Finalize the submission'}
                         },
                  '2' : {'title': '',
                         'fields': [
                                    {'name': 'someText1', 
                                     'title': 'Some Text', 
                                     'description': '',
                                      'type': 'text',
                                      'size': None,
                                      },
                                    {'name': 'someText2', 
                                     'title': 'Some Text', 
                                     'description': '',
                                      'type': 'string',
                                      'size': None
                                      },
                                    {'name': 'someText3', 
                                     'title': 'Some Text', 
                                     'description': '',
                                      'type': 'select',
                                      'options': [
                                                  ['Something', 'something'],
                                                  ['Something else', 'somethingelse']
                                                  ]
                                      },
                                    {'name': 'someText4', 
                                     'title': 'Some Text', 
                                     'description': '',
                                      'type': 'date',
                                      'size': None,
                                      },
                                    {'name': 'someText5', 
                                     'title': 'Some Text', 
                                     'description': '',
                                      'type': 'radio',
                                      'options': [
                                                  ['Option 1', 'opt1'],
                                                  ['Option 2', 'opt2'],
                                                  ['Option 3', 'opt3']
                                                  ],
                                      'size': None,
                                      }
                                    ]
                         }
                  }
                    
# This is a dummy tip that gives an idea of the structure of tips
dummy_tip = { 'receipt': "1234567890",
            'form': dummy_tip_form,
            'data': None
           }

class Tip(object):
    """dummy Tip model"""
    
    def __init__(self, id = None):
        self.id = id

app = Flask(__name__)
app.config['DEBUG'] = True
app.config['SECRET_KEY'] = 's3cr3tz!'

@app.route('/tip', methods=['POST'])
def create_tip():
    tip = dummy_tip
    return jsonify(tip)
    

@app.route('/tip/<id>', methods=['GET'])
def read_tip(id):
    tip = dummy_tip
    return jsonify(tip)

@app.route('/tip/<id>', methods=['PUT'])
def update_tip(id):
    pass

@app.route('/tip/<id>', methods=['DELETE'])
def delete_tip(id):
    pass

if __name__ == '__main__':
    app.run()


@@ -69,68 +69,56 @@
 sk, 
-render_template, request, redirect, url_for, flash, jsonify%0A
+jsonify, request%0Afrom logging import FileHandler
 %0Adum
@@ -4120,16 +4120,17 @@
 _(self, 
+t
 id = Non
@@ -4146,21 +4146,23 @@
    self.
+t
 id = 
+t
 id%0A%0Aapp 
@@ -4245,16 +4245,67 @@
 r3tz!'%0A%0A
+app.logger.addHandler(FileHandler(%22logfile.log%22))%0A%0A
 @app.rou
@@ -4351,16 +4351,105 @@
 _tip():%0A
+    app.logger.debug(%22POST TIP%22)%0A    app.logger.debug(%22DATA: %25s%22, jsonify(request.form))%0A
     tip 
@@ -4500,32 +4500,33 @@
 pp.route('/tip/%3C
+t
 id%3E', methods=%5B'
@@ -4541,29 +4541,77 @@
 ef read_tip(
+t
 id):%0A
+    app.logger.debug(%22GET TIP - TID: %25s%22, tid)%0A
     tip = du
@@ -4653,32 +4653,33 @@
 pp.route('/tip/%3C
+t
 id%3E', methods=%5B'
@@ -4696,24 +4696,25 @@
  update_tip(
+t
 id):%0A    pas
@@ -4710,20 +4710,114 @@
 d):%0A    
-pass
+app.logger.debug(%22PUT TIP - TID: %25s%22, tid)%0A    app.logger.debug(%22DATA: %25s%22, jsonify(request.form))
 %0A%0A@app.r
@@ -4828,16 +4828,17 @@
 ('/tip/%3C
+t
 id%3E', me
@@ -4870,16 +4870,17 @@
 ete_tip(
+t
 id):%0A   
@@ -4884,12 +4884,53 @@
     
-pass
+app.logger.debug(%22DELETE TIP - TID: %25s%22, tid)
 %0A%0Aif

Implement some debugging