From 48b8bc1747f38e76bf6a760015f7c9877f9ba3e2 Mon Sep 17 00:00:00 2001 From: Simon Pamies Date: Thu, 16 Jun 2011 22:39:07 +0200 Subject: [PATCH] First working version of new screen to list and select races for event --- TODO | 4 +- .../src/org/json/simple/JSONValue.java | 8 ++ .../sailing/web/browser/functions.py | 50 ++++++-- .../web/browser/static/css/styles.css.txt | 8 -- .../templates/java-connector-custom-race.pt | 16 +++ .../templates/java-connector-select-races.pt | 7 ++ .../web/browser/templates/java-connector.pt | 113 +++++++++--------- python/src/sailing.web/sailing/web/config.py | 1 + 8 files changed, 132 insertions(+), 75 deletions(-) create mode 100644 python/src/sailing.web/sailing/web/browser/templates/java-connector-custom-race.pt create mode 100644 python/src/sailing.web/sailing/web/browser/templates/java-connector-select-races.pt diff --git a/TODO b/TODO index bad3a2bd7fb..b2b411524cf 100644 --- a/TODO +++ b/TODO @@ -28,10 +28,8 @@ Simon + Sortierung funktioniert nicht richtig in den Legs und den Werten (der 1. Platz fehlt manchmal) + Anstatt DropDB lieber ein Removeallby eventname, racename ermöglichen (auch in der DB UI) -+ Wie kriege ich die Bars hin? + Mehrere Rennen anzeigbar und auswählbar machen + iPhone UI implementieren -+ Wenn Axel Branches eingerichtet hat, dann MongoDBs auf Server startbar machen über supervisord - ++ Speichern der URLs in MongoDB diff --git a/java/org.json.simple/src/org/json/simple/JSONValue.java b/java/org.json.simple/src/org/json/simple/JSONValue.java index 7550e47a2a5..da5531a4a60 100755 --- a/java/org.json.simple/src/org/json/simple/JSONValue.java +++ b/java/org.json.simple/src/org/json/simple/JSONValue.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.io.Writer; +import java.net.URL; import java.util.List; import java.util.Map; @@ -152,6 +153,13 @@ public class JSONValue { return; } + if (value instanceof URL) { + out.write('\"'); + out.write(value.toString()); + out.write('\"'); + return; + } + out.write(value.toString()); } diff --git a/python/src/sailing.web/sailing/web/browser/functions.py b/python/src/sailing.web/sailing/web/browser/functions.py index 108aecbff1b..905c8067e40 100644 --- a/python/src/sailing.web/sailing/web/browser/functions.py +++ b/python/src/sailing.web/sailing/web/browser/functions.py @@ -81,7 +81,19 @@ def configureListener(context, request): conf.setContext(config.ADMIN) - if request.POST.get('eventJSONURL'): + if request.POST.get('race-conf'): + # multiple races configured + + for raceurl in request.POST.getall('race-conf'): + conf.setCommand(config.ADD_RACE) + conf.setParameters(dict(paramURL=raceurl, + liveURI=request.POST.get('liveURI'), + storedURI=request.POST.get('storedURI'), + windstore=request.POST.get('windstore'))) + conf.trigger() + + + elif request.POST.get('eventJSONURL'): conf.setCommand(config.ADD_EVENT) conf.setParameters(dict(eventJSONURL=request.POST.get('eventJSONURL'), liveURI=request.POST.get('liveURI'), @@ -105,14 +117,15 @@ def configureListener(context, request): else: return view.yieldMessage('Please specify an event or race URL!') - try: - result = conf.trigger() + if not request.POST.get('race-conf'): + try: + result = conf.trigger() - if result.find('Exception')>0: - raise Exception, 'Server triggered exception: %s' % result[:550] + if result.find('Exception')>0: + raise Exception, 'Server triggered exception: %s' % result[:550] - except Exception, ex: - return view.yieldMessage('Error: %s' % str(ex)) + except Exception, ex: + return view.yieldMessage('Error: %s' % str(ex)) # can take a while until event data is ready if request.POST.get('drop_db'): @@ -132,11 +145,11 @@ def configureListener(context, request): if len(eventlist) == 0: raise Exception, 'No events configured.' + startListenerThreads(conf, eventlist) + except Exception, ex: return view.yieldMessage('Could not gather any data! Seems that Java listener is not ready yet. Please reconnect. Error: %s' % str(ex)) - startListenerThreads(conf, eventlist) - # mark all stuff done and listener running view.session['listener-started'] = True view.session.save() @@ -607,3 +620,22 @@ def moderatorLiveData(context, request): return data[int(c_range_start)-1:int(c_range_end)] +def loadRacesForEvent(context, request): + view = core.BaseView(context, request) + + host = request.params.get('host') + port = request.params.get('port') + eventJSONURL = request.params.get('eventJSONURL') + + conf = URIConfigurator(host, port) + view.session['listener-conf'] = conf + view.session.save() + + conf.setContext(config.ADMIN) + conf.setCommand(config.LIST_RACES_IN_EVENT) + conf.setParameters(dict(eventJSONURL=eventJSONURL)) + + data = jsonByUrl(conf) + + return render_to_response('templates/java-connector-select-races.pt', {'races' : data, 'view': view}, request=request) + diff --git a/python/src/sailing.web/sailing/web/browser/static/css/styles.css.txt b/python/src/sailing.web/sailing/web/browser/static/css/styles.css.txt index 8167596f7b4..f9b0960c4c6 100644 --- a/python/src/sailing.web/sailing/web/browser/static/css/styles.css.txt +++ b/python/src/sailing.web/sailing/web/browser/static/css/styles.css.txt @@ -101,14 +101,6 @@ div.field input.large { width: 687px; } -form input[type=submit] { - padding: 5px 35px; - margin: 5px 2px 2px 2px; - border: 1px solid #c8c8c8; - background-color: white; - color: black; -} - select { border: 1px solid #c8c8c8; padding: 3px 2px 3px 9px; diff --git a/python/src/sailing.web/sailing/web/browser/templates/java-connector-custom-race.pt b/python/src/sailing.web/sailing/web/browser/templates/java-connector-custom-race.pt new file mode 100644 index 00000000000..f3d110c999d --- /dev/null +++ b/python/src/sailing.web/sailing/web/browser/templates/java-connector-custom-race.pt @@ -0,0 +1,16 @@ + +
+ URL to race configuration
+ + +
+     ${eventurl}
+
+ + diff --git a/python/src/sailing.web/sailing/web/browser/templates/java-connector-select-races.pt b/python/src/sailing.web/sailing/web/browser/templates/java-connector-select-races.pt new file mode 100644 index 00000000000..7cb963f075d --- /dev/null +++ b/python/src/sailing.web/sailing/web/browser/templates/java-connector-select-races.pt @@ -0,0 +1,7 @@ + +
+ If you do not select one of the races shown the whole event will be configured
+ +  ${race['name']} (${race['ID']})
+
+
diff --git a/python/src/sailing.web/sailing/web/browser/templates/java-connector.pt b/python/src/sailing.web/sailing/web/browser/templates/java-connector.pt index 9ef8c5150a4..0f95b2df393 100644 --- a/python/src/sailing.web/sailing/web/browser/templates/java-connector.pt +++ b/python/src/sailing.web/sailing/web/browser/templates/java-connector.pt @@ -12,15 +12,14 @@ When stopping listener it will trigger two methods: If you select a race   

@@ -30,65 +29,69 @@ When stopping listener it will trigger two methods: If you select a race 2. Event Configuration
URL to event configuration
- +
-     ${eventurl}
+ ${eventurl}
-
- URL to race configuration
- - -
-     ${eventurl}
-
- -
- Live-Connection (host:port):
- - -
- -
- Data-Connection (host:port):
- - -
- -
- Store where to persist wind tracks
- -
- -
-   - Drop Database before connect (Dangerous!! Better use the selective DROP in DB tab)
-
- -   +   + + + diff --git a/python/src/sailing.web/sailing/web/config.py b/python/src/sailing.web/sailing/web/config.py index 8a910908c53..7d8030ad17e 100644 --- a/python/src/sailing.web/sailing/web/config.py +++ b/python/src/sailing.web/sailing/web/config.py @@ -15,6 +15,7 @@ SET_WIND = 'setwind' SET_WIND_SOURCE = 'selectwindsource' LIST_EVENTS = 'listevents' +LIST_RACES_IN_EVENT = 'listracesinevent' LIVE_EVENTS = 'showrace' SHOW_WAYPOINTS = 'showwaypoints'