Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
beaugunderson committed Feb 8, 2014
1 parent e3cc890 commit 6bb0a7c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
35 changes: 19 additions & 16 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ def zip_gather(resp, params, campaign):


def dialing_config(params):
return dict(
timeLimit=app.config['TW_TIME_LIMIT'],
timeout=app.config['TW_TIMEOUT'],
hangupOnStar=True, # allow the user to hangup and move onto next call
action=url_for('call_complete', **params))
return {
'timeLimit': app.config['TW_TIME_LIMIT'],
'timeout': app.config['TW_TIMEOUT'],
# allow the user to hangup and move onto next call
'hangupOnStar': True,
'action': url_for('call_complete', **params)
}


def make_calls(params, campaign):
Expand Down Expand Up @@ -280,13 +282,14 @@ def call_complete():
@app.route('/call_complete_status', methods=call_methods)
def call_complete_status():
# asynch callback from twilio on call complete
params, campaign = parse_params(request)
params, _ = parse_params(request)

return jsonify(dict(
phoneNumber=request.values.get('To', ''),
callStatus=request.values.get('CallStatus', 'unknown'),
repIds=params['repIds'],
campaignId=params['campaignId']))
return jsonify({
'phoneNumber': request.values.get('To', ''),
'callStatus': request.values.get('CallStatus', 'unknown'),
'repIds': params['repIds'],
'campaignId': params['campaignId']
})


@app.route('/demo')
Expand All @@ -300,16 +303,16 @@ def count():

@app.route('/stats')
def stats():
pwd = request.values.get('password', None)
campaign = data.get_campaign(request.values.get('campaignId', 'default'))
password = request.values.get('password', None)
campaign = request.values.get('campaign', 'default')

if pwd == app.config['SECRET_KEY']:
return jsonify(aggregate_stats(campaign['id']))
if password == app.config['SECRET_KEY']:
return jsonify(aggregate_stats(campaign))
else:
return jsonify(error="access denied")


if __name__ == "__main__":
if __name__ == '__main__':
# load the debugger config
app.config.from_object('config.Config')
app.run(host='0.0.0.0')
19 changes: 13 additions & 6 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,45 @@
class Config(object):
DEBUG = True

SQLALCHEMY_DATABASE_URI = 'sqlite:///dev.db'

APPLICATION_ROOT = 'http://1cf55a5a.ngrok.com'

TW_CLIENT = twilio.rest.TwilioRestClient(
os.environ.get('TWILIO_DEV_ACCOUNT_SID'),
os.environ.get('TWILIO_DEV_AUTH_TOKEN'))

TW_NUMBER = '5005550006' # development number
SQLALCHEMY_DATABASE_URI = 'sqlite:///dev.db'
TW_NUMBER = '5005550006' # development number

TASKFORCE_KEY = os.environ.get('TASKFORCE_KEY')
SUNLIGHTLABS_KEY = os.environ.get('SUNLIGHTLABS_KEY')

# limit on the length of the call
TW_TIME_LIMIT = 60 * 4 # sec/min * min
TW_TIME_LIMIT = 60 * 4 # 4 minutes

# limit on the amount of time to ring before giving up
TW_TIMEOUT = 20 # sec
TW_TIMEOUT = 20 # seconds

SECRET_KEY = 'AOUSBDAONPSOMDASIDUBSDOUABER)*#(R&(&@@#))'


class ConfigProduction(Config):
DEBUG = strtobool(os.environ.get('DEBUG', 'false'))

SENTRY_DSN = os.environ.get('SENTRY_DSN')

SQLALCHEMY_POOL_RECYCLE = 60 * 60 # 1 hour
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI')

APPLICATION_ROOT = os.environ.get('APPLICATION_ROOT')

TW_CLIENT = twilio.rest.TwilioRestClient(
os.environ.get('TWILIO_ACCOUNT_SID'),
os.environ.get('TWILIO_AUTH_TOKEN'))
TW_NUMBER = os.environ.get('TWILIO_NUMBER')
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI')

SECRET_KEY = os.environ.get('SECRET_KEY')


class ConfigTesting(Config):
TESTING = True
APPLICATION_ROOT = ''
Expand Down

0 comments on commit 6bb0a7c

Please sign in to comment.