You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by hu...@apache.org on 2015/03/25 13:33:58 UTC

svn commit: r1669105 - /steve/trunk/pysteve/www/cgi-bin/rest_admin.py

Author: humbedooh
Date: Wed Mar 25 12:33:58 2015
New Revision: 1669105

URL: http://svn.apache.org/r1669105
Log:
allow vote plugins to parse fields themselves.
prepare for COP voting

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

Modified: steve/trunk/pysteve/www/cgi-bin/rest_admin.py
URL: http://svn.apache.org/viewvc/steve/trunk/pysteve/www/cgi-bin/rest_admin.py?rev=1669105&r1=1669104&r2=1669105&view=diff
==============================================================================
--- steve/trunk/pysteve/www/cgi-bin/rest_admin.py (original)
+++ steve/trunk/pysteve/www/cgi-bin/rest_admin.py Wed Mar 25 12:33:58 2015
@@ -156,6 +156,11 @@ else:
                                         for entry in c:
                                             candidates.append({'name': entry.strip(), 'statement': s[z] if len(s) > z else ""})
                                             z += 1
+                                    # HACK: If candidate parsing is outsourced, let's do that instead (primarily for COP)
+                                    voteType = election.getVoteType({'type': form.getvalue('type')})
+                                    if 'parsers' in voteType and 'candidates' in voteType['parsers']:
+                                        candidates = voteType['parsers']['candidates'](form.getvalue('candidates'))
+                                        
                                     f.write(json.dumps({
                                         'title': form.getvalue('title'),
                                         'description': form.getvalue('description'),
@@ -259,6 +264,12 @@ else:
                                                 statements.append(entry)
                                         if field == "seconds":
                                             val = [x.strip() for x in val.split("\n")]
+                                            
+                                        # HACK: If field  parsing is outsourced, let's do that instead (primarily for COP)
+                                        voteType = election.getVoteType(js)
+                                        if 'parsers' in voteType and field in voteType['parsers']:
+                                            val = voteType['parsers'][field](form.getvalue(field))
+                                            
                                         js[field] = val
                                 with open(issuepath + ".json", "w") as f:
                                     f.write(json.dumps(js))