Author: humbedooh
Date: Sun Mar 22 17:48:21 2015
New Revision: 1668422

URL: http://svn.apache.org/r1668422
Log:
To make editing easier, try to accept candidates and statements as JSON, fall 
back to \n-separated values

Modified:
    steve/trunk/pytest/www/cgi-bin/rest_admin.py

Modified: steve/trunk/pytest/www/cgi-bin/rest_admin.py
URL: 
http://svn.apache.org/viewvc/steve/trunk/pytest/www/cgi-bin/rest_admin.py?rev=1668422&r1=1668421&r2=1668422&view=diff
==============================================================================
--- steve/trunk/pytest/www/cgi-bin/rest_admin.py (original)
+++ steve/trunk/pytest/www/cgi-bin/rest_admin.py Sun Mar 22 17:48:21 2015
@@ -227,15 +227,29 @@ else:
                                 with open(issuepath + ".json", "r") as f:
                                     js = json.loads(f.read())
                                     f.close()
-                                fields = 
['title','description','type','candidates','seconds','nominatedby']
+                                fields = 
['title','description','type','statements','candidates','seconds','nominatedby']
+                                statements = []
                                 for field in fields:
                                     val = form.getvalue(field)
                                     if val:
                                         if field == "candidates":
-                                            xval = val.split("\n")
+                                            try:
+                                                xval = json.loads(val)
+                                            except:
+                                                xval = val.split("\n")
                                             val = []
+                                            z = 0
                                             for entry in xval:
-                                                val.append({'name': 
entry.strip()})
+                                                val.append({'name': 
entry.strip(), 'statement': statements[z] if len(candidates) > z else ""})
+                                                z += 1
+                                        if field == "statements":
+                                            try:
+                                                xval = json.loads(val)
+                                            except:
+                                                xval = val.split("\n")
+                                            val = []
+                                            for entry in xval:
+                                                statements.append(entry)
                                         if field == "seconds":
                                             val = [x.strip() for x in 
val.split("\n")]
                                         js[field] = val


Reply via email to