Commits

Chris Mutel committed c063d81

Add first draft of activity editor for web

  • Participants
  • Parent commits 6db5d28

Comments (0)

Files changed (3)

File bw2ui/web/app.py

 from jobs import JobDispatch, InvalidJob
 from utils import get_job_id, get_job, set_job_status, json_response
 import itertools
+import json
 import multiprocessing
 import os
 import urllib2
     st = SpeedTest()
     return str(250 * int(40 * st.ratio()))
 
+
+@app.route('/edit/<database>/<code>/raw', methods=["GET", "POST"])
+def raw_edit(database, code):
+    print database
+    print code
+    if database not in databases:
+        return abort(404)
+    try:
+        data = json.dumps(Database(database).load()[(database, code)], indent=2)
+    except KeyError:
+        return abort(404)
+    print data
+    return render_template("edit-raw.html", data=data)
+
 ###########
 ### LCA ###
 ###########

File bw2ui/web/templates/edit-raw.html

+{% extends "base.html" %}
+
+{% block extrahead %}
+<style type="text/css" media="screen">
+    #editor {
+        position: absolute;
+        top: 0;
+        right: 0;
+        bottom: 0;
+        left: 0;
+    }
+</style>
+{% endblock %}
+
+{% block body %}
+<div class="span-24">
+  <h1>Edit activity raw data</h1>
+  <div id="editor">{{ data|safe }}</div>
+</div>
+
+<script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
+<script type="text/javascript">
+  var data_backup={{ data|safe }};
+</script>
+<script type="text/javascript">
+    var editor = ace.edit("editor");
+    editor.setTheme("ace/theme/solarized_light");
+    editor.getSession().setMode("ace/mode/javascript");
+</script>
+{% endblock %}
   author="Chris Mutel",
   author_email="cmutel@gmail.com",
   license=open('LICENSE.txt').read(),
-  install_requires=["brightway2", "docopt", "flask", "requests", "bw-stats-toolkit", \
-    "fuzzywuzzy"],
+  install_requires=["brightway2>=0.9.0-alpha2", "docopt", "flask", \
+    "bw-stats-toolkit>=0.7", "fuzzywuzzy"],
   scripts=["bw2ui/bin/bw2-web.py", "bw2ui/bin/bw2-controller.py"],
   url="https://bitbucket.org/cmutel/brightway2-ui",
   long_description=open('README.rst').read(),