Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Construct the js config the same way we do for the poll config resour…
Browse files Browse the repository at this point in the history
…ce in the dialogue vumi app (resolves #957)
  • Loading branch information
justinvdm committed May 20, 2014
1 parent 8fd2b7d commit 0f860b9
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions go/apps/dialogue/vumi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
from go.apps.jsbox.vumi_app import JsBoxConfig, JsBoxApplication


def dialogue_js_config(conv):
config = {
"name": "poll-%s" % conv.key
}

poll = conv.config.get("poll", {})
poll_metadata = poll.get('poll_metadata', {})
delivery_class = poll_metadata.get('delivery_class')

if delivery_class is not None:
config['delivery_class'] = delivery_class

return config


class PollConfigResource(SandboxResource):
"""Resource that provides access to dialogue conversation config."""

Expand All @@ -17,19 +32,7 @@ def _get_config(self, conversation):
:returns:
JSON string containg the configuration dictionary.
"""

config = {
"name": "poll-%s" % conversation.key
}

poll = conversation.config.get("poll", {})
poll_metadata = poll.get('poll_metadata', {})
delivery_class = poll_metadata.get('delivery_class')

if delivery_class is not None:
config['delivery_class'] = delivery_class

return json.dumps(config)
return json.dumps(dialogue_js_config(conversation))

def _get_poll(self, conversation):
"""Returns the poll definition from the given dialogue.
Expand Down Expand Up @@ -72,3 +75,6 @@ class DialogueApplication(JsBoxApplication):
CONFIG_CLASS = DialogueConfig

worker_name = 'dialogue_application'

def get_jsbox_js_config(self, conv):
return dialogue_js_config(conv)

0 comments on commit 0f860b9

Please sign in to comment.