Beispiel #1
0
def usage(username):
    if flask.request.method == 'GET':
        return flask.jsonify(**{ "usage": [
                       {"category": "Game", "apps" :
                              mongo_repo.find_rec(username, "Game")
                       },
                       {"category": "Social", "apps" : 
                              mongo_repo.find_rec(username, "Social")
                       }
                       ]
        })
    if flask.request.method == 'POST':
        logging.info("Received %s", flask.request.data)
        cat = categorize(flask.request.get_json(force=True))
        mongo_repo.insert(username, cat, flask.request.get_json(force=True))
        if username in curfew_time:
            if datetime.datetime.now() - curfew_time[username] > datetime.timedelta(seconds=30):
                send_parent_sms(username)
                del curfew_time[username]
        if username in active_curfew:
            active_curfew.remove(username)
            curfew_time[username] = datetime.datetime.now()

            sendgrid_api.send_msg("*****@*****.**", 'Your curfew is up!')
            return flask.jsonify(**{"curfew_expired":True})
        else:
            return flask.jsonify(**{"curfew_expired":False})
Beispiel #2
0
def send_parent_sms(username):
    msg = "%s is violating their curfew!" % username 
    sendgrid_api.send_msg("*****@*****.**", msg)