Commits

Anonymous committed 3201b80

added constants

Comments (0)

Files changed (6)

-Boiler plate app
+py-aggregate
 ========
+
+
+Links
+==========
+
+* http://code.google.com/p/opendatakit/source/browse/src/main/java/org/opendatakit/aggregate/servlet/SubmissionServlet.java?repo=aggregate
+* http://code.google.com/p/opendatakit/source/browse/src/main/java/org/opendatakit/aggregate/constants/ServletConsts.java?repo=aggregate
+* http://code.google.com/p/opendatakit/source/browse/src/main/java/org/opendatakit/aggregate/parser/SubmissionParser.java?repo=aggregate
+* https://bitbucket.org/javarosa/javarosa/wiki/FormSubmissionAPI
+* https://bitbucket.org/javarosa/javarosa/wiki/OpenRosaAPI
+* https://bitbucket.org/javarosa/javarosa/wiki/UserRegistrationAPI
+* https://bitbucket.org/javarosa/javarosa/wiki/OpenRosaMetaDataSchema
+
+
 Based on
+================
 
-Flask
-SQLAlchemy
-Flask-Login
-Twitter Bootstrap
-Knockout JS
+* Flask
+* SQLAlchemy
+* Flask-Login
+* Twitter Bootstrap
+* Knockout JS
 etc

constants/error_consts.py

+# Error message if the form with FORM ID is not found
+ODKID_NOT_FOUND = "Unable to find form with matching Form Id as submission"
+FORM_NOT_FOUND = "Form not found"
+FORM_DEFINITION_INVALID = "Form definition incomplete or missing"
+#Error message for if key was not successfully part of the request
+ODK_KEY_PROBLEM = "Encountered a problem receiving key"
+# Error message if the FORM ID in the form already exists
+FORM_WITH_ODKID_EXISTS = "Form Already Exists for this Namespace/Id attribute"
+
+FORM_INVALID_SUBMISSION_ELEMENT = "Attributes of submission element do not match form attributes"
+# Error message if not all information was received 
+MISSING_FORM_INFO = "Did not receive Form Name and Form XML description"
+
+# Error message if form ID was not specified
+MISSING_FORM_ID = "Form did not specify a Form ID. For information on Form ID please check the Open Data Kit FAQ"
+
+# Error message if request is not multi-part 
+NO_MULTI_PART_CONTENT = "Request does not contain Multi Part Content"
+INCOMPLETE_DATA = "Problem locating part of the submission data needed to complete request"
+# Constant error string if child does not implement a setValueFromByteArray override
+BINARY_ERROR = "System should have dispatched to a proper binary conversion method"
+PARSING_PROBLEM = "Problem parsing submission XML"
+FORM_DOES_NOT_ALLOW_SUBMISSIONS = "Submissions have been disallowed on this form"
+# Constant used to log error if string array does not match column size
+ROW_SIZE_ERROR = "Tried to add a row to result table that did not match the header size! DISCARDING!"
+# Error message if not all information was received
+INSUFFIECENT_PARAMS = "Insuffiecent Parameters Received"
+SUBMISSION_NOT_FOUND ="Did NOT find submission matching the provided parameters"
+NO_STRING_TO_BLOB_CONVERT = "Blob cannot be created from string"
+UNKNOWN_INTERFACE = "Some how did not get a SubmissionField or SubmissionRepeat"
+INVALID_PARAMS = "Parameter(s) are not valid"
+MISSING_PARAMS = "One or more required parameters are missing"
+
+# Constant string identifying XML stream
+INPUTSTREAM_ERROR = "Problem obtaining submissionXML input stream!"
+NO_IMAGE_EXISTS = "No Image Exists for this Entry!"
+NOT_A_KEY = "Incorrect type was stored, expecting a key for the view link"
+TASK_PROBLEM = "PROBLEM WITH TASK: "
+
+QUOTA_EXCEEDED = "Quota exceeded"
+PERSISTENCE_LAYER_PROBLEM = "Problem persisting data or accessing data"
+UPLOAD_PROBLEM = "Upload transmission unexpectedly failed"
+EXPORTED_FILE_PROBLEM = "Problem accessing exported datafile"
+
+JAVA_ROSA_PARSING_PROBLEM = "Problem with JavaRosa Parsing Form:"
+ERROR_OBTAINING_FUSION_TABLE_ID = "ERROR CREATING FUSION TABLE - DID NOT GET A TABLE NUMBER"
+
+# Error message if OAuth authentication failed.
+OAUTH_ERROR = "OAuth authentication failed."
+OAUTH_SECURITY_ERROR_WHILE_RETRIEVING_SESSION_TOKEN = "Security error while retrieving session token."
+OAUTH_SERVER_REJECTED_ONE_TIME_USE_TOKEN = "Server rejected one time use token."

constants/parser_consts.py

+DEFAULT_NAMESPACE = "ODK_DEFAULT"
+
+FORM_ID_ATTRIBUTE_NAME = "id"
+
+MODEL_VERSION_ATTRIBUTE_NAME = "version"
+
+UI_VERSION_ATTRIBUTE_NAME = "uiVersion"
+
+INSTANCE_ID_ATTRIBUTE_NAME = "instanceID"
+
+SUBMISSION_DATE_ATTRIBUTE_NAME = "submissionDate"
+
+IS_COMPLETE_ATTRIBUTE_NAME = "isComplete"
+
+MARKED_AS_COMPLETE_DATE_ATTRIBUTE_NAME = "markedAsCompleteDate"
+
+NAMESPACE_ATTRIBUTE = "xmlns"
+
+FORWARD_SLASH = "/"
+
+FORWARD_SLASH_SUBSTITUTION = "&frasl"
+
+VALUE_FORMATTED = "  Value: "
+
+ATTRIBUTE_FORMATTED = " Attribute> "
+
+NODE_FORMATTED = "Node: "
+
+#The max file size that can be uploaded/parsed
+FILE_SIZE_MAX = 5000000
+
+#Namespace of ODK extensions to the OpenRosa standards
+NAMESPACE_ODK = "http://www.opendatakit.org/xforms"
+
+#additional attribute used to supply the base64 public key for encrypted submissions
+BASE64_RSA_PUBLIC_KEY = "base64RsaPublicKey"

constants/servlet_consts.py

+#copied from ODK 
+
+
+DEBUG = false
+
+APPLICATION_NAME = "ODK AGGREGATE"
+OPEN_ROSA_VERSION_HEADER = "X-OpenRosa-Version"
+OPEN_ROSA_VERSION = "1.0"
+OPEN_ROSA_DATE_HEADER = "Date"
+OPEN_ROSA_ACCEPT_CONTENT_LENGTH_HEADER = "X-OpenRosa-Accept-Content-Length"
+
+#Flag on submissions and form uploads indicating that this is 
+#a partial submission or form upload.
+TRANSFER_IS_INCOMPLETE = "*isIncomplete*"
+#Name of form field that contains XML submission
+XML_SUBMISSION_FILE = "xml_submission_file"
+#Name of form field that contains the form name value (form upload)
+public final static String FORM_NAME_PRAM = "form_name"
+# Name of form field that contains the xform xml definittion (form upload)
+public final static String FORM_DEF_PRAM = "form_def_file"
+#The name of the property that includes the form id
+FORM_ID = "formId"
+
+# For PersistentResults and MiscTasks generator gae servlets.
+# the key holding the Uri of the persistent result or misc task record.
+PERSISTENT_RESULTS_KEY = "persistentResult"
+MISC_TASKS_KEY = "miscTask"
+ATTEMPT_COUNT = "attemptCount"
+BACKEND_GAE_SERVICE = "background"
+HOST = "Host"
+
+#The name of the property that determines how to format webpage
+HUMAN_READABLE = "readable"
+
+# The name of the property that specifies the type of interaction with an
+# external service
+EXTERNAL_SERVICE_TYPE = "externalServiceType"
+
+# href link text
+BRIEFCASE_LINK_TEXT = "Download Entire Dataset (Briefcase)"
+UPLOAD_SUBMISSIONS_LINK_TEXT = "Upload Submissons"
+UPLOAD_XFORM_LINK_TEXT = "Upload a Form Definition"
+BLOB_KEY = "blobKey"
+AS_ATTACHMENT = "as_attachment"
+OAUTH_CONSUMER_KEY = "anonymous"
+OAUTH_CONSUMER_SECRET = "anonymous"
+OAUTH_TOKEN_PARAMETER = "oauth_token"
+OAUTH_TOKEN_SECRET_PARAMETER = "oauth_token_secret"
+DOWNLOAD_XML_BUTTON_TXT = "Download XML"
+CSV_FILENAME_APPEND = "_results.csv"
+KML_FILENAME_APPEND = "_results.kml"
+JSON_FILENAME_APPEND = "_results.json"
+RECORD_KEY = "record"
+EXPORT_CURSOR_CHUNK_SIZE = 100
+
+#The name of the parameter that specifies the cursor location for retrieving
+# data from the data table (fragmented Csv servlet)
+CURSOR = "cursor"
+# The name of the parameter that specifies how many rows to return from the
+# cursor (fragmented Csv servlet).
+NUM_ENTRIES = "numEntries"
+CHECK_INTERVAL_PARAM = "checkIntervalMilliseconds"
+START_DATE = "startDate"
+
+# Script path to include...
+UPLOAD_SCRIPT_RESOURCE = "javascript/upload_control.js"
+UPLOAD_STYLE_RESOURCE = "stylesheets/upload.css"
+UPLOAD_BUTTON_STYLE_RESOURCE = "stylesheets/button.css"
+AGGREGATE_STYLE = "AggregateUI.css"
 from jinja2 import Environment, FileSystemLoader
 from flask import Flask, request, session, g, redirect, url_for, abort, \
      render_template, flash, _app_ctx_stack
+from flask import Module, make_response, render_template
 
 # configuration
 DEBUG = True
         top.sqlite_db = sqlite3.connect(app.config['DATABASE'])
     return top.sqlite_db
 
+@app.before_request
+def before_request():
+    method = request.form.get('_method', '').upper()
+    if method:
+        request.environ['REQUEST_METHOD'] = method
+        ctx = flask._request_ctx_stack.top
+        ctx.url_adapter.default_method = method
+        assert request.method == method
 
 @app.teardown_appcontext
 def close_db_connection(exception):
     template = jinja_env.get_template('home.html')
     return template.render()
 
-
-
+@app.route('/submission',methods=['HEAD','POST'])
+def submission():
+    if request.environ['REQUEST_METHOD'] == 'HEAD':
+        response = make_response(render_template('head_request.txt'))
+        response.headers['X-OpenRosa-Version'] = '1'
+        return response, 204
+    elif request.environ['REQUEST_METHOD'] == 'POST':
+        response = make_response(render_template('home.html'))
+        response.headers['X-OpenRosa-Version'] = '1'
+        return response, 201
 
 if __name__ == '__main__':
     app.run()

templates/head_request.txt

Empty file added.