Пример #1
0
def prepMessage():
    """Prepare Message for GCM

    """
    if request.method == "GET":
        return render_template("prepmessage.html")
    elif request.method == "POST":
        outDict = MultiDict();
        params = dict();
        params['messageType'] = request.form['messageType']
        params['message'] = request.form['message']
        outString = ""
        
        q = RegIDModel.all()
        count = q.count(1000000)
        iCount = 0
        while iCount < count:
            items = q.fetch(100, iCount);            
            strings = ""
            start = ""
            stringarray = []
            for item in items:
                strings = strings + start + item.regID
                start = "," 
                stringarray.append(item.regID)
            outDict['registration_ids'] = stringarray
            outDict['data'] = params
            outString += sendMessage(outDict) +"\n"
            iCount += 100;
        return outString
    return ''
def register():
    """Register device for GCM

    """
    if request.method == 'POST':
        regIDForm = RegIDForm()
        print " data " + regIDForm.regID.data
        if regIDForm.regID != None: #regIDForm.validate_csrf_token("redID"):
            q = RegIDModel.all()
            q.filter("regID =", regIDForm.regID.data)
            result = q.get()
            if result == None:
                regID = RegIDModel(regID=regIDForm.regID.data)
                print regID.put()
                return "success"
    return 'failure'
Пример #3
0
def register():
    """Register device for GCM

    """
    if request.method == 'POST':
        regIDForm = RegIDForm()
        print " data " + regIDForm.regID.data
        if regIDForm.regID != None: #regIDForm.validate_csrf_token("redID"):
            q = RegIDModel.all()
            q.filter("regID =", regIDForm.regID.data)
            result = q.get()
            if result == None:
                regID = RegIDModel(regID=regIDForm.regID.data)
                print regID.put()
                return "success"
    return 'failure'
def prepMessage():
    """Prepare Message for GCM

    """
    if request.method == "GET":
        return render_template("prepmessage.html")
    elif request.method == "POST":
        outDict = MultiDict()
        params = dict()
        params['messageType'] = request.form['messageType']
        params['message'] = request.form['message']
        params['time'] = int(time.time())
        outString = ""

        q = RegIDModel.all()
        count = q.count(1000000)
        iCount = 0
        while iCount < count:
            items = q.fetch(100, iCount)
            strings = ""
            start = ""
            stringarray = []
            for item in items:
                strings = strings + start + item.regID
                start = ","
                stringarray.append(item.regID)
            outDict['registration_ids'] = stringarray
            outDict['data'] = params
            outString += sendMessage(outDict) + "\n"
            iCount += 100
        print "Saving message: " + params['message']
        saveMessage = MessagesModel(message=params['message'],
                                    messagetype= params['messageType'],
                                    sent_at=params['time'])
        saveMessage.put()
        return outString
    return ''
def prepMessage():
    """Prepare Message for GCM

    """
    if request.method == "GET":
        return render_template("prepmessage.html")
    elif request.method == "POST":
        outDict = MultiDict()
        params = dict()
        params['messageType'] = request.form['messageType']
        params['message'] = request.form['message']
        params['time'] = int(time.time())
        outString = ""

        q = RegIDModel.all()
        count = q.count(1000000)
        iCount = 0
        while iCount < count:
            items = q.fetch(100, iCount)
            strings = ""
            start = ""
            stringarray = []
            for item in items:
                strings = strings + start + item.regID
                start = ","
                stringarray.append(item.regID)
            outDict['registration_ids'] = stringarray
            outDict['data'] = params
            outString += sendMessage(outDict) + "\n"
            iCount += 100
        print "Saving message: " + params['message']
        saveMessage = MessagesModel(message=params['message'],
                                    messagetype=params['messageType'],
                                    sent_at=params['time'])
        saveMessage.put()
        return outString
    return ''